Jump to content
Sign in to follow this  

Script freezing everything!

Recommended Posts


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 :blink:

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: Win7
  • RAM: 2Gb DDR2
  • AMD Athlon 64

Here is the code. Sorry about the mess! I left it as is so you people can see what I've tried.

#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)

;~ HotKeySet("{INS}", "_kill")
;~ HotKeySet("{PGUP}", "_status")
;~ HotKeySet("{PGDN}", "_select")

;~ Global $timer = TimerInit()
While 1
    $mhp = PixelGetColor($xx, $yy)
;~  _hp()
    If _IsPressed("2D", $dll) Then
    If _IsPressed("22", $dll) Then

        If $mhp == $colorftw Then
;~          _attack("1")
;~          _attack("2")
;~          _attack("3")
;~          _attack("4")
;~      Else
;~          _attack("1")
;~  EndIf
;~  $mhp = 0


Func _select()
    $mousecoords = MouseGetPos()
    $xx = $mousecoords[0]
    $yy = $mousecoords[1]
    $colorftw = PixelGetColor($xx, $yy)

;~ 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()

Thanks in advanced!

Edited by OKIA

Share this post

Link to post
Share on other sites

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.


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.