Getting the process ID using AutoIt.

11/01/2010 23:33 Starburst17#1
Currently I have to get the PID from memory and change the script on a per-login basis. Can anyone tell me why this AutoIt method isn't working:

Code:
$pid = WinGetProcess("[Conquer Online]")
11/01/2010 23:47 theoneofgod#2
WinGetProcess needs the correct window name/handle, are you sure the window name is [Conquer Online] ?

Try this just for a test.

Code:
$hWnd = WinGetHandle("[Conquer Online]")

If WinExists($hWnd) Then
$vPID = WinGetProcess($hWnd)
MsgBox(0, "", $vPID)
Else
MsgBox(0, "", "Window not found")
EndIf
11/02/2010 00:09 Starburst17#3
Quote:
Originally Posted by theoneofgod View Post
WinGetProcess needs the correct window name/handle, are you sure the window name is [Conquer Online] ?

Try this just for a test.

Code:
$hWnd = WinGetHandle("[Conquer Online]")

If WinExists($hWnd) Then
$vPID = WinGetProcess($hWnd)
MsgBox(0, "", $vPID)
Else
MsgBox(0, "", "Window not found")
EndIf
Using your code outputs a PID for a process called "SciTE.exe" regardless of what text you put in "WinGetHandle("HERE")".

Edit: Using "$pid = WinGetProcess("[Conquer2.0]")" or even "$pid = WinGetProcess("[Conquer Online: Raiding Clans]")" worked flawlessly in the past. I think maybe "[Conquer Online]" is what is showing up in the taskbar and the actual process name is different. Why can't they just keep the name the same?
11/02/2010 00:33 theoneofgod#4
Try this one...

Code:
$hWnd = "[Conquer Online]"

If WinExists($hWnd) Then
$vPID = WinGetProcess($hWnd)
MsgBox(0, "", $vPID)
Else
MsgBox(0, "", "Window not found")
EndIf
11/02/2010 00:44 Starburst17#5
Quote:
Originally Posted by theoneofgod View Post
Try this one...

Code:
$hWnd = "[Conquer Online]"

If WinExists($hWnd) Then
$vPID = WinGetProcess($hWnd)
MsgBox(0, "", $vPID)
Else
MsgBox(0, "", "Window not found")
EndIf
This one worked like a charm. Now the only issue is "[Conquer Online]" isn't the process name. That said is there anyway one can get the exact name of a process using knowing the PID number.
11/02/2010 01:05 theoneofgod#6
Code:
$vPID = 1111 ; your PID here

$vRet = _PIDGetProcessName($vPID)

MsgBox(0,"",$vRet)

Func _PIDGetProcessName($vPID)
	$aProcesslist = ProcessList()
	For $i = 1 To $aProcesslist[0][0]
		If $aProcesslist[$i][1] = $vPID Then Return $aProcesslist[$i][0]
	Next
EndFunc   ;==>_PIDGetProcess

; returns = 0 (pid does not exist)
11/02/2010 02:03 Starburst17#7
Quote:
Originally Posted by theoneofgod View Post
Code:
$vPID = 1111 ; your PID here

$vRet = _PIDGetProcessName($vPID)

MsgBox(0,"",$vRet)

Func _PIDGetProcessName($vPID)
	$aProcesslist = ProcessList()
	For $i = 1 To $aProcesslist[0][0]
		If $aProcesslist[$i][1] = $vPID Then Return $aProcesslist[$i][0]
	Next
EndFunc   ;==>_PIDGetProcess

; returns = 0 (pid does not exist)
Returns "Conquer.exe". Tried making "Conquer.exe" the name in your code above to find the PID and comes back as before "window not found".
11/02/2010 02:17 theoneofgod#8
Conquer.exe is not a window.
11/02/2010 02:26 Starburst17#9
Quote:
Originally Posted by theoneofgod View Post
Conquer.exe is not a window.
I know it isn't. I want to find the window name of a running Conquer client. "[Conquer Online]" doesn't want to work so need to discover what that actual window name is.
11/02/2010 02:41 theoneofgod#10
Code:
$vPID = 3560

MsgBox(0, "", _ProcessGetWin($vPID))

Func _ProcessGetWin($vPID)
	$aWinlist = WinList()
	For $i = 1 To $aWinlist[0][0]
		If $vPID = WinGetProcess($aWinlist[$i][0]) Then Return $aWinlist[$i][0]
	Next
EndFunc   ;==>_ProcessGetWin
11/02/2010 02:49 Starburst17#11
Quote:
Originally Posted by theoneofgod View Post
Code:
$vPID = 3560

MsgBox(0, "", _ProcessGetWin($vPID))

Func _ProcessGetWin($vPID)
	$aWinlist = WinList()
	For $i = 1 To $aWinlist[0][0]
		If $vPID = WinGetProcess($aWinlist[$i][0]) Then Return $aWinlist[$i][0]
	Next
EndFunc   ;==>_ProcessGetWin
When I use the PID of the Conquer client it returns "0" but any other application is returns the proper window name. I might just end up needing to enter the PID and recompiling my script on an as-needed basis. Pretty much all I'm making is an auto-hp script that pots at a given health and automatically dose the XP skill for me.

It's a "Conquer Clicky" rip-off but programmed as a macro to pot and do xp skills. I could just use Joek's but his doesn't currently auto-pot and I've been sent to botjail twice with his macro. So kinda want to play it safe and use something I know wont land me in the slammer.
11/02/2010 10:43 trash#12
cant you just use active window prolly not the best method but always worked for me.
something like...

PHP Code:
MsgBox(4096"Get PID","Select the CO window you wish to use then click ok")
Sleep(1000)
GetPID()

Func GetPID()
    
$pid WinGetProcess("[ACTIVE]") ....... 
blah de blah...
11/02/2010 16:43 Starburst17#13
Quote:
Originally Posted by trash View Post
cant you just use active window prolly not the best method but always worked for me.
something like...

PHP Code:
MsgBox(4096"Get PID","Select the CO window you wish to use then click ok")
Sleep(1000)
GetPID()

Func GetPID()
    
$pid WinGetProcess("[ACTIVE]") ....... 
blah de blah...
I could give that a whirl :P.