helpplx Posted June 4, 2010 Share Posted June 4, 2010 This does what it needs to do. But whilst it runs it uses about 20+% of the cpu.. and when you press 2 to start the pixelsearch it gets even worse. My knowledge of autoit is nonexistent so I was wondering if it's possible to make this do what it does without taking up a 5th of my cpu? Thanks in advance. expandcollapse popupFunc _IsPressed($hexKey) Local $aR, $bO $hexKey = '0x' & $hexKey $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey) If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then $bO = 1 Else $bO = 0 EndIf Return $bO EndFunc $colorred = 0xEE405A $colorgold = 0xFCFB52 $colorblue = 0x42B5F9 $color = 0xEE405A While 1 If _IsPressed('61') = 1 Then $color = $colorblue If _IsPressed('62') = 1 Then $color = $colorred If _IsPressed('63') = 1 Then $color = $colorgold If _IsPressed('32') = 1 Then while 1 $coord = PixelSearch(555, 928, 588, 965, $color, 40, 2) If IsArray($coord) = 1 Then send ("2") sleep (100) exitloop endif wend endif wend Link to comment Share on other sites More sharing options...
Yoriz Posted June 4, 2010 Share Posted June 4, 2010 Hey, welcome to the forum, if you was to put a Sleep(100) in your main While loop it would give your cpu chance to have a breather. GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
Zibit Posted June 4, 2010 Share Posted June 4, 2010 you can manipulate cpu usage using memory... Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
NinjaGeek Posted June 5, 2010 Share Posted June 5, 2010 The reason it is using so much memory is that you are opening and closing the DLL every time _IsPressed is called - instead use DllOpen before your loop and then pass in the handle returned from that function: expandcollapse popupFunc _IsPressed($hexKey,$dll) Local $aR, $bO $hexKey = '0x' & $hexKey $aR = DllCall($dll, "int", "GetAsyncKeyState", "int", $hexKey) If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then $bO = 1 Else $bO = 0 EndIf Return $bO EndFunc $colorred = 0xEE405A $colorgold = 0xFCFB52 $colorblue = 0x42B5F9 $color = 0xEE405A $dll = DllOpen("user32.dll") While 1 If _IsPressed('61',$dll) = 1 Then $color = $colorblue If _IsPressed('62',$dll) = 1 Then $color = $colorred If _IsPressed('63',$dll) = 1 Then $color = $colorgold If _IsPressed('32') = 1 Then while 1 $coord = PixelSearch(555, 928, 588, 965, $color, 40, 2) If IsArray($coord) = 1 Then send ("2") sleep (100) exitloop endif wend endif wend You may also want to replace IsArray($coord) = 1 with simply @error, as it is set to 1 if the pixelsearch fails. 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