2013-12-23 23 views
0

如何通過PID定位進程?我有同一個程序在同一時間活動的多個實例,但我的代碼只適用於一個。我想定位所有實例。區分同一程序的多個實例

那麼在哪裏把PID(我的意思是第一行)或如何區分多個實例?

Global $WindowTitle = "World of Warcraft" 

Global $PauseKey = "{F7}" 
Global $TerminateKey = "{F8}" 
Global $PVPOpenKey = "{h}" 
Global $MacroBindKey = "{8}{a}" 

Global $Paused = False 

HotKeySet($PauseKey, "Pause") 
HotKeySet($TerminateKey, "Terminate") 

While 1 
    If Not $Paused Then 
     ControlSend($WindowTitle, "", 0, $PVPOpenKey) 
     Sleep(5000) 
     ControlSend($WindowTitle, "", 0, $MacroBindKey) 
    EndIf 

    Sleep(500) 
WEnd 

Func Pause() 
    $Paused = Not $Paused 
EndFunc 

Func Terminate() 
    Exit 
EndFunc 

回答

5

爲了讓你可以使用ProcessList()某些處理所有的PID。

; List PIDs for wow.exe processes 
$list = ProcessList("wow.exe") 
For $i = 1 To $list[0][0] 
    MsgBox(0, "Hi!", $list[$i][1]) 
Next 
相關問題