ウィンドウハンドルを検索して、終了処理を発生させる方法です。
ウィンドウハンドルを検索する方法は。
hspext の apisel や、user32 の findwindow 等色々あります。
#include "user32.as"
onexit*exit_
exec"notepad"
button gosub"メモ帳を終了",*close
*@
findwindow"notepad",0 :fw_=stat
GetForegroundWindow :fg_=stat
logmes strf("%d,%d",fw_,fg_)
if(fw_==fg_):htarget = fw_:goto*@f
wait 1
goto*@b
*@
stop
*exit_
gosub *close:end
return
*close
#define WM_SYSCOMMAND $00000112
#define SC_CLOSE $0000F060
// windowに、終了ボタンを押した際の処理を発生させる
sendmsg htarget , WM_SYSCOMMAND , (SC_CLOSE&0xFFF0),0
return