ウインドウを所有しているプロセスのフルパスを取得する
#include "kernel32.as"
#include "user32.as"
; win 2000 or later
#uselib "psapi.dll"
#func global EnumProcessModules "EnumProcessModules" int, sptr, int, sptr
#func global GetModuleFileNameEx "GetModuleFileNameExA" int, int, sptr, int
#module
#define PROCESS_VM_READ $10
#define PROCESS_QUERY_INFORMATION $400
#deffunc get_exe_file_name_from_hwnd int hTargetWnd
sdim fname,256
hProcess = 0
hMod = 0
nNeed = 0
processID = 0
GetWindowThreadProcessId hTargetWnd, varptr(processID)
OpenProcess PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, 0, processID
hProcess = stat
if hProcess {
EnumProcessModules hProcess, varptr(hMod), 4, varptr(nNeed)
if stat {
GetModuleFileNameEx hProcess, hMod, varptr(fname), 255
}
CloseHandle hProcess
}
return fname
#global
sdim s, 260
width 320, 240
objsize ginfo_winx, ginfo_winy
pos 0,0
mesbox s, ginfo_winx, ginfo_winy, 0
hTargetWnd = 0
*main
wait 5
WindowFromPoint ginfo_mx, ginfo_my
if hTargetWnd = stat : goto *main
hTargetWnd = stat
get_exe_file_name_from_hwnd hTargetWnd
s = refstr
objprm 0, s
; title ""+strf("%08X",hTargetWnd) + strf(":%08X",processID)
goto *main
stop