あ、プロセス名がわかればタスクキルできるので、exe名でKillできます。パスは関係ないです。
他の手段の一覧
http://hsp.tv/play/pforum.php?mode=pastwch&num=50595
ゲームということでタイトルバーの値は一定とすると、こんな感じ
#include "user32.as"
FindWindow 0,"HSP assistant ver1.21"
if stat!=0{
tgt_hwnd=stat
pid=0
GetWindowThreadProcessId stat,varptr(pid)
exec "taskkill /f /pid "+pid
}
さて、EnumWindowsを使いたいがHSPからでは面倒なので、今回は
http://hsp.tv/play/pforum.php?mode=pastwch&num=71794
を参考に、一覧から一致するものを見つけたらKillするのを作るとする。
#uselib "user32.dll"
#cfunc GetDesktopWindow "GetDesktopWindow"
#cfunc GetTopWindow "GetTopWindow" int
#cfunc GetWindow "GetWindow" int, int
#define GW_HWNDNEXT 2
#cfunc IsWindowVisible "IsWindowVisible" int
#func GetWindowText "GetWindowTextA" int, int, int
#func global GetWindowThreadProcessId "GetWindowThreadProcessId" sptr,sptr
#define NULL 0
#define MAX_DETECT 256 //検出する最大個数
dim hwndList, MAX_DETECT //検出したウィンドウハンドルのリスト
sdim wTitleList, 256, MAX_DETECT //検出したウィンドウのタイトルのリスト
num_detected = 0 //検出カウンタ
sdim buf,256 //汎用変数
hwnd_desktop = GetDesktopWindow() //デスクトップのハンドル。(Windowsではデスクトップが他のトップレベルウィンドウの親になっているらしい。)
hwnd_ = GetTopWindow(hwnd_desktop) //デスクトップ傘下のトップレベルウィンドウで、Zオーダーが最大(ざっくり言えば「一番上に浮かんでいる」)のもの。
notesel titles
if hwnd_ { //そいつが空でない(→居る)なら
GetWindowText hwnd_,varptr(buf),256 //タイトルバー文字列
if strlen(buf) { //名無しでないなら登録する
hwndList(num_detected) = hwnd_
noteadd buf
num_detected ++
}
repeat //最下のウィンドウまで繰り返す
hwnd_ = GetWindow(hwnd_,GW_HWNDNEXT)
if hwnd_ {
if IsWindowVisible(hwnd_) {
GetWindowText hwnd_,varptr(buf),256
if strlen(buf) {
hwndList(num_detected) = hwnd_
noteadd buf
num_detected++
}
}
} else : break
if num_detected == MAX_DETECT : break //お腹一杯
loop
}
screen 0,800,800
detect=notefind("Document",notefind_instr)//検索に引っかけたいのを指定する。
mes titles
mes detect
mes hwndlist(detect)
pid=0
GetWindowThreadProcessId hwndlist(detect),varptr(pid)
mes pid
exec "taskkill /f /pid "+pid
疑問点があればまだまだ聞きますから遠慮なくどうぞ。相当に難しくなってきたので。