AutoHotkey Community

It is currently May 26th, 2012, 9:40 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: PixelSearch crash
PostPosted: August 13th, 2005, 6:50 am 
Offline

Joined: June 6th, 2005, 11:35 pm
Posts: 179
Location: Northern Virginia
I have a loop with 2 pixelsearches. It crashes and then when Windows gives me the pop up that an error occured. When its there my machine plays a very weird sound when i click or move the mouse. Anyway, is it possible that if pixelsearches are using too many resources it will cause it to crash?

My script:
Code:
Hotkey, $Up, UpKey
Hotkey, $Down, DownKey
Hotkey, $Left, LeftKey
Hotkey, $Right, RightKey
Hotkey, $NumPadUp, NumPadUpKey
Hotkey, $NumPadDown, NumPadDownKey
Hotkey, $NumPadLeft, NumPadLeftKey
Hotkey, $NumPadRight, NumPadRightKey
return

Gosub, SeaRubySearch
SeaRubySearch: ; has a g-label so it can be "gone to" with 'gosub' later on
$Insert::
Loop
  {
    PixelSearch, XSeaColor, YSeaColor, 206, 166, 227, 188, 0xC77314, 0, Fast|RGB
      SeaErrorLevel = %ErrorLevel%
        If SeaErrorLevel = 0 ; color was found so preform next line
          gosub, StopWalk
else
  gosub, AllowWalk

    PixelSearch, XRubyColor, YRubyColor, 206, 166, 227, 188, 0x0B078E, 0, Fast|RGB
      if ErrorLevel = 0 ; color was found so preform next line
        gosub, StopWalk
else
  gosub, AllowWalk
}
return

StopWalk:
  Hotkey, $Up, On
  Hotkey, $Down, On
  Hotkey, $Left, On
  Hotkey, $Right, On
  Hotkey, $NumPadUp, On
  Hotkey, $NumPadDown, On
  Hotkey, $NumPadLeft, On
  Hotkey, $NumPadRight, On
    gosub, SeaRubySearch
return

AllowWalk:
  Hotkey, $Up, Off
  Hotkey, $Down, Off
  Hotkey, $Left, Off
  Hotkey, $Right, Off
  Hotkey, $NumPadUp, Off
  Hotkey, $NumPadDown, Off
  Hotkey, $NumPadLeft, Off
  Hotkey, $NumPadRight, Off
    gosub, SeaRubySearch
return

UpKey:
gosub, SeaRubySearch
return
DownKey:
gosub, SeaRubySearch
return
LeftKey:
gosub, SeaRubySearch
return
RightKey:
gosub, SeaRubySearch
return
NumPadUpKey:
gosub, SeaRubySearch
return
NumPadDownKey:
gosub, SeaRubySearch
return
NumPadLeftKey:
gosub, SeaRubySearch
return
NumPadRightKey:
gosub, SeaRubySearch
return


Thanks.

_________________
_AiK


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 13th, 2005, 3:26 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
In this case, it seems likely that there are gosubs without returns, which would cause a crash due to "stack overflow".

For example, if the SeaRubySearch subroutine does "gosub, AllowWalk" and the AllowWalk subroutine always does "gosub, SeaRubySearch", they will continue to call each other without ever returning. This results in infinite recursion, which in turn causes a crash due to stack overflow.

The solution is usually to redesign the script to avoid infinite gosubing.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group