作ってみましたが多分確実ではありません。
#module
#uselib "user32.dll"
#cfunc GetDesktopWindow "GetDesktopWindow"
#cfunc GetWindow "GetWindow" int,int
#cfunc GetWindowText "GetWindowTextA" int,int,int
#cfunc IsWindowVisible "IsWindowVisible" int
#uselib "kernel32.dll"
#cfunc lstrcmp "lstrcmp" int,int
#define MAX_PATH 260
#define GW_OWNER $00000004
#define GW_HWNDNEXT $00000002
#define GW_CHILD $00000005
#deffunc getproclist var prm1
WndDesk=GetDesktopWindow()
if WndDesk!0 {
WndCurWin=GetWindow(WndDesk,GW_CHILD)
}else{
return -1
}
buf="" : sdim szClassName,MAX_PATH : sdim chWinTxt,MAX_PATH
count=0
while WndCurWin!0
await
ret=GetWindowText(WndCurWin,varptr(chWinTxt),MAX_PATH)
i=WndCurWin : buf+=str(i)+","+chWinTxt+"\n"
count++
WndCurWin=GetWindow(WndCurWin,GW_HWNDNEXT)
wend
while WndCurWin!0
await
ret=GetWindowText(WndCurWin,varptr(chWinTxt),MAX_PATH)
if chWinTxt!"" {
vs=IsWindowVisible(WndCurWin)
if vs!0 {
owhwnd=GetWindow(WndCurWin,GW_OWNER)
if owhwnd==0 {
if chWinTxt!"Program Manager" {
lpString="Progman"
cp=lstrcmp(varptr(szClassName),varptr(lpString))
if cp!0 {
i=WndCurWin : buf+=str(i)+","+chWinTxt+"\n"
count++
}
}
}
}
}
WndCurWin=GetWindow(WndCurWin,GW_HWNDNEXT)
wend
prm1=buf
sdim szClassName,0 : sdim chWinTxt,0 : sdim buf,0
return count
#uselib "user32.dll"
#func f_GetWindowThreadProcessID "GetWindowThreadProcessId" sptr , sptr
#cfunc c_GetWindowLong "GetWindowLongA" sptr , sptr
#uselib "kernel32.dll"
#func f_OpenProcess "OpenProcess" sptr , sptr , sptr
#func f_CloseHandle "CloseHandle" sptr
#cfunc c_GetLastError "GetLastError"
#uselib "psapi.dll"
#func f_GetModuleFileNameEx "GetModuleFileNameExA" sptr , sptr , sptr , sptr
#define GWL_HINSTANCE 0xFFFFFFFA
#define PROCESS_ALL_ACCESS 0x001F0FFF
#deffunc GetExeFileName int gefn_hwnd_ , var gefn_filename_
dim returnx
sdim gefn_filename_ , 2048
hMod = c_GetWindowLong( gefn_hwnd_ , GWL_HINSTANCE )
f_GetWindowThreadProcessId gefn_hwnd_ , varptr( PId )
sledID = stat
f_OpenProcess PROCESS_ALL_ACCESS , 1 , PId
hProcess = stat
if hProcess ! 0 {
f_GetModuleFileNameEx hProcess , hMod , varptr( gefn_filename_ ) , 2048
slen = stat
if slen = 0 {
returnx |= (1<<31) | (1<<0)
return -1
}else{
returnx = slen
}
}else{
returnx |= (1<<31) | (1<<1)
return -1
}
f_CloseHandle hProcess
return returnx
#global
//ここに起動するファイルを入れる
PATH="C:\\WINDOWS\\system32\\notepad.exe"
exec path,16
mes ""+PATH+"\nこのファイルを起動しました"
wait 100
*main
temp=str(temp) : work=str(work)
getproclist temp : num=stat
notepos=0 : count=0
sdim mhwnd,8,num : sdim proctitle,260,num
repeat num
await
repeat 2
getstr work,temp,notepos,',' : notepos+=strsize
if cnt==0 : mhwnd(count)=work
if cnt==1 : proctitle(count)=work
loop
GetExeFileName int(mhwnd(count)),filename
if stat!-1{
if getpath(filename,16)=getpath(PATH,16):flug=1
}
count++
loop
if flug=1:flug=0:else:dialog "操作対象が終了したので終了します",1,"確認":end
await 20
goto *main