#ifndef __hsedsdk__ #define __hsedsdk__ #module "hsedsdk" // // Win32API functions #uselib "user32.dll" #func FindWindow@hsedsdk "FindWindowA" sptr, sptr #func GetWindowThreadProcessId@hsedsdk "GetWindowThreadProcessId" int, var #uselib "kernel32.dll" #func OpenProcess@hsedsdk "OpenProcess" int, int, int #func GetCurrentProcess@hsedsdk "GetCurrentProcess" #func DuplicateHandle@hsedsdk "DuplicateHandle" int, int, int, var, int, int, int #func CloseHandle@hsedsdk "CloseHandle" int #func CreatePipe@hsedsdk "CreatePipe" var, var, int, int #func ReadFile@hsedsdk "ReadFile" int, var, int, var, int #func WriteFile@hsedsdk "WriteFile" int, var, int, var, int // Win32API constants(Excluding messages) #const PROCESS_ALL_ACCESS@hsedsdk 0x001F0FFF #const DUPLICATE_SAME_ACCESS@hsedsdk 0x00000002 // // Constant strings #define HSED_INTERFACE_NAME "HspEditorInterface" // // Messages #const WM_APP@hsedsdk 0x00008000 #const _HSED_GETVER (WM_APP + 0x000) #const _HSED_GETWND (WM_APP + 0x100) // // Constants for HSED_GETVER #const global HGV_PUBLICVER 0 #const global HGV_PRIVATEVER 1 #const global HGV_HSPCMPVER 2 #const global HGV_FOOTYVER 3 #const global HGV_FOOTYBETAVER 4 // // Constants for HSED_GETWND #const global HGW_MAIN 0 #const global HGW_CLIENT 1 #const global HGW_TAB 2 #const global HGW_EDIT 3 #const global HGW_TOOLBAR 4 #const global HGW_STATUSBAR 5 // // Macros #define global ctype hsed_getmajorver(%1) (%1 >> 16 & 0xFFFF) #define global ctype hsed_getminorver(%1) (%1 >> 8 & 0xFF) #define global ctype hsed_getbetaver(%1) (%1 & 0xFF) // // Initialize ;#deffunc hsed_init ; if init: return ; CreatePipe@hsedsdk hReadPipe, hWritePipe, 0, 32000 ; return // // Uninitialize ;#deffunc hsed_uninit ; if hReadPipe: CloseHandle hReadPipe: hReadPipe = 0 ; if hWritePipe: CloseHandle hWritePipe: hWritePipe = 0 ; return // // Uninitialize a duplicate pipe handle #deffunc hsed_uninitduppipe if hReadPipe: CloseHandle hReadPipe: hReadPipe = 0 if hWritePipe: CloseHandle hWritePipe: hWritePipe = 0 if hDupReadPipe: CloseHandle hDupReadPipe: hDupReadPipe = 0 if hDupWritePipe: CloseHandle hDupWritePipe: hDupWritePipe = 0 return // // Initialize a duplicate pipe handle #deffunc hsed_initduppipe CreatePipe@hsedsdk hReadPipe, hWritePipe, 0, 32000 if hReadPipe == 0 || hWritePipe == 0: return 1 GetWindowThreadProcessID@hsedsdk hIF, dwProcessID OpenProcess@hsedsdk PROCESS_ALL_ACCESS@hsedsdk, 0, dwProcessID hHsedProc = stat GetCurrentProcess@hsedsdk hCurProc = stat DuplicateHandle@hsedsdk hCurProc, hReadPipe, hHsedProc, hDupReadPipe, 0, 0, DUPLICATE_SAME_ACCESS@hsedsdk DuplicateHandle@hsedsdk hCurProc, hWritePipe, hHsedProc, hDupWritePipe, 0, 0, DUPLICATE_SAME_ACCESS@hsedsdk CloseHandle@hsedsdk hHsedProc if hDupReadPipe == 0 | hDupWritePipe == 0: hsed_uninitduppipe: return 1 return 0 // // Capture the HSP Script Editor API Handle #deffunc hsed_capture FindWindow@hsedsdk HSED_INTERFACE_NAME, HSED_INTERFACE_NAME hIF = stat if hIF == 0: return 1 return 0 // // Check if HSP Script Editor exists #deffunc hsed_exist hsed_capture return stat == 0 // // Get the version of HSP Script Editor #deffunc hsed_getver var ret, int nType hsed_capture if stat: ret = 0: return 1 if(nType == HGV_HSPCMPVER){ sdim ret, 4096 hsed_initduppipe if stat: return 2 sendmsg hIF, _HSED_GETVER, nType, hDupWritePipe if stat < 0: ret = "Error": hsed_uninitduppipe: return 3 ReadFile hReadPipe, ret, 4096, dwNumberOfBytesRead, 0 hsed_uninitduppipe } else { sendmsg hIF, _HSED_GETVER, nType, 0 ret = stat if ret < 0: return 3 } return 0 // // Get the window handle of HSP Script Editor #deffunc hsed_getwnd var ret, int nType, int nID hsed_capture if stat: ret = 0: return 1 if nType == HGW_EDIT{ sendmsg hIF, _HSED_GETWND, nType, nID } else { sendmsg hIF, _HSED_GETWND, nType, 0 } ret = stat if ret = 0: return 2: else: return 0 // // Make a string from the version #deffunc hsed_cnvverstr int nVersion sdim _refstr, 4096 _refstr = "" + hsed_getmajorver(nVersion) + "." + strf("%02d", hsed_getminorver(nVersion)) if hsed_getbetaver(nVersion): _refstr += "b" + hsed_getbetaver(nVersion) return _refstr #global ;hsed_init #endif