Personally I always just use PROCESS_ALL_ACCESS parameter in OpenProcess, because it always works. Your issue is that you're not treating the $pBuffer parameter in ReadProcessMemory as an AutoIt DllStruct.
$pBuf = DllStructCreate("byte")
$iRead = 0
$hProc = _WinAPI_OpenProcess(0x1F0FFF, False, @AutoItPID) //0x1F0FFF = PROCESS_ALL_ACCESS
_WinAPI_ReadProcessMemory($hProc, 0x0800000, DllStructGetPtr($pBuf), DllStructGetSize($pBuf), $iRead)
MsgBox(0, "", DllStructGetData($pBuf, 1))
Hope it helps!
AFAIK you're gonna have to do a DllCall for that.
$aRet = DllCall("gdi32.dll", "int", "GetPixel", "hwnd", $hDC, "int", $x, "int", $y)
$pixelColor = $aRet[0]oÝ÷ Ù: zÛax7¯Ç¢{^ÆØZÙ^Ó~¡'h¶¬jëh×6$hDC = DLLCall("user32.dll","long","GetDC","hwnd",WinGetHandle("Ragnarok Online"))
$hDC = $hDC[0]
Hope this helps. Remember the coordinates are still relative to the clientarea of the window.
ControlClick() will do that for you. Remember that the X and Y coordinates will be relative to the clientarea of the window though, so to find the coords using for example AutoIt Window Info Tool, look for the "ControlClick coords" instead of Mouse coords.
ControlClick("Ragnarok Online", "", "", "left", 1, 250, 250)
To click once with left mouse button at 250,250 in the RO window.
Using keystrokes like Alt+Tab to swap between different windows isn't really that reliable.
You could also just be sending the keystroke using ControlSend, then you don't have to swap windows:
ControlSend("Ragnarok Online", "", "", "{F6}")oÝ÷ Øò¢çhm}ç¥)v§ØZ¶ÚòºÈ§h§ëGjwez«¨´!Q*ºm¢¶ººÞÜ"Ú0Z)ÀrدjתºQj Ú®X§z«¨¶Ç§w*.®G²²Úèæ§vØ^h§Ëb½«^¢{az§vW«zÛ«ç[Éh§ëGjwey«¢+ØÀÌØíÑ¥Ù]¥¹½Üô]¥¹Ñ!¹± ÅÕ½Ðím
Q%YtÅÕ½Ðì¤)]¥¹Ñ¥ÙÑ ÅÕ½ÐíI¹É½¬=¹±¥¹ÅÕ½Ðì¤)M¹ ÅÕ½ÐííÙôÅÕ½Ðì¤)]¥¹Ñ¥ÙÑ ÀÌØíÑ¥Ù]¥¹½Ü¤
To call a function you have to remember the () after the name, just like in your declaration:
_spf()
To call the function. Remember that $rdlate, $spx and $spy have to be declared globally for that script to work.
ControlSend() works on windows.
For example, I can use it to send keypresses to Guild Wars if I wanted to by simply doing:
ControlSend("Guild Wars", "", "", "Testing")
So that method should work, if not, then maybe your game has some kind of protection against it.
Run("net start wuauserv", "", @SW_HIDE)
Setting the 3rd parameter of Run to @SW_HIDE will start the application hidden (not shown on status bar either).
Or...
You could simply return a value from Location(), be it the $loc variable, so instead of setting that variable within the Location function you just Return it and in nk() you will need to have a variable receiving the return from Location().
$loc = Location()
...
Return 10059975;For example
EDIT: To answer your last question, yes, it makes it permanent for use throughout the entire lifespan of the script and for use everywhere in it.
Yup, you simply need to declare $loc in Global scope, where you do it is your own choice, I like to keep my globals at the beginning of my scripts though.
Global $loc
If it is the case that there are multiple windows from the same process and you wish to get them all you can do:
Func _WinGetByPid($iPID)
Local $aWList = WinList()
Local $aRet[1] = [0]
For $iCC = 0 To $aWList[0][0]
If WinGetProcess($aWList[$iCC][1]) = $iPID AND _
BitAND(WinGetState($aWList[$iCC][1]), 2) Then
ReDim $aRet[UBound($aRet)+1]
$aRet[0] += 1
$aRet[$aRet[0]] = $aWList[$iCC][0]
EndIf
Next
If $aRet[0] = 0 Then
Return SetError(1, 0, 0)
Else
Return $aRet
EndIf
EndFunc
Remember to change $aRet[$aRet[0]] = $aWList[$iCC][0] to $aRet[$aRet[0]] = $aWList[$iCC][1] if you want the window handles.
You might wanna take a look at the IE functions which are also documented in the help file for AutoIt.
Apart from that, there are multiple topics on forum about this matter, so a quick search will probably find you some good examples.
Your function worked perfectly for me, but I think it all depends on how you're getting the PID to start with.
$aPList = ProcessList("<procname>")
For $i = 1 To $aPList[0][0]
ConsoleWrite(_WinGetByPid($aPList[$i][1])&@CRLF)
Next
Is outputting the right window handles even when I use on it multiple instances of the same process with same title.
To get the handle you need to change
Return $aWList[$iCC][0]
to
Return $aWList[$iCC][1]
of course, but you're probably already doing that.
So question is, how are you getting the PID's in the first place?