OKIA Posted July 8, 2010 Share Posted July 8, 2010 (edited) Hello all! I just registered (though I've been lurking around for examples and help for some time now[few months])I didn't find an answer to this topic, so, I registered to ask So I made this script that uses mainly pixelgetcolor() function, if the return of this function == the color I'm looking for, it simulates keystrokes (send() and I also tested controlsend() but it seems these functions aren't the ones making troubles). I also have other functions, such as: _kill(), to exit script and another to select the color.The problem I've been having is that after a few minutes of using it, the operating system freezes for a short amount of time (around 10 seconds) whiles this is happening I can only move the mouse pointer, I cannot change between windows, etc. It keeps doing this forever.I commented out parts of the script at a time and do tests, the only thing that seems to be problematic is pixelgetcolor(), I don't know why, I've used it before with no problems.If someone has the answer please do! I'd appreciate it!A few specs of my computer:OS: Win7RAM: 2Gb DDR2AMD Athlon 64Here is the code. Sorry about the mess! I left it as is so you people can see what I've tried.expandcollapse popup#include <WinAPI.au3> #include <Misc.au3> $dll = DllOpen("user32.dll") Global $status = 0 Global $window = "Galactic" Global $sleep = 100 Global $keephp = 0 Global $keepmp = 0 Global $xx = 1, $yy = 1, $colorftw = 0x000000 $PID = _WinAPI_GetCurrentProcessID() ProcessSetPriority($PID, 3) WinMove($window, "", 0, 0) WinActivate($window) ;~ HotKeySet("{INS}", "_kill") ;~ HotKeySet("{PGUP}", "_status") ;~ HotKeySet("{PGDN}", "_select") ;~ Global $timer = TimerInit() While 1 $mhp = PixelGetColor($xx, $yy) ;~ _hp() If _IsPressed("2D", $dll) Then _kill() EndIf If _IsPressed("22", $dll) Then _select() EndIf ;~ If $mhp == $colorftw Then Send("1") Sleep($sleep) Send("2") Sleep($sleep) Send("3") Sleep($sleep) Send("4") ;~ _attack("1") ;~ _attack("2") ;~ _attack("3") ;~ _attack("4") ;~ Else ;~ _attack("1") EndIf ;~ EndIf ;~ $mhp = 0 Sleep(100) WEnd DllClose($dll) Func _select() $mousecoords = MouseGetPos() $xx = $mousecoords[0] $yy = $mousecoords[1] $colorftw = PixelGetColor($xx, $yy) EndFunc ;~ Func _hp() ;~ local $diff = TimerDiff($timer) ;~ if $diff >= $keephp Then ;~ local $hp = PixelGetColor(175, 38) ;~ If $hp == 0x181718 Then ;~ ControlSend($window, "", "", "{F1}") ;~ Sleep(50) ;~ ControlSend($window, "", "", "0") ;~ EndIf ;~ Local $hp = 0 ;~ $keephp = $diff + 1500 ;~ EndIf ;~ ;~ If $diff >= $keepmp Then ;~ Local $mp = PixelGetColor(174, 54) ;~ If $mp == 0x131313 Then ;~ ControlSend($window, "", "", "{F1}") ;~ Sleep(50) ;~ ControlSend($window, "", "", "9") ;~ EndIf ;~ $mp = 0 ;~ $keepmp = $diff + 1500 ;~ EndIf ;~ ;~ If $diff >= 30000 Then ;~ $timer = TimerInit() ;~ $keephp = 0 ;~ $keepmp = 0 ;~ EndIf ;~ EndFunc ;~ Func _attack($vara) ;~ Send($vara) ;~ ControlSend($window, "", "", $vara) ;~ Sleep($sleep) ;~ EndFunc ;~ Func _status() ;~ If $status == 0 Then ;~ $status = 1 ;~ Else ;~ $status = 0 ;~ EndIf ;~ EndFunc Func _kill() DllClose($dll) Exit EndFuncThanks in advanced! Edited July 8, 2010 by OKIA Link to comment Share on other sites More sharing options...
LarryDalooza Posted July 8, 2010 Share Posted July 8, 2010 Not sure if it is documented in the help file, but PixelGetColor used without the [hwnd] parameter is problematic on Vista and up... it has been discussed here before. Get the handle of the window that contains the pixel and use that handle in the function. Lar. AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now