Jump to content
Sign in to follow this  
homie

need some help with "exit"

Recommended Posts

homie

ok so I am new to autoit, but I have done basic programing before.

I have my script working fine, and I start it from a hotkey...

Global $Paused
HotKeySet("{ESC}", "start")

While 1
    Sleep(100)
WEnd


Func start()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)

$pixel1 = PixelGetColor (602, 290 )
If $pixel1 <> 16777215 Then MouseClick ("left", 602, 290 )
$pixel2 = PixelGetColor (604, 290 )
If $pixel2 <> 14333068 Then MouseClick ("left", 604, 290 )
$pixel3 = PixelGetColor (606, 290 )
If $pixel3 <> 9211020 Then MouseClick ("left", 606, 290 )
$pixel4 = PixelGetColor (608, 290 )
If $pixel4 <> 9211020 Then MouseClick ("left", 608, 290 )
$pixel5 = PixelGetColor (610, 290 )
If $pixel5 <> 9211020 Then MouseClick ("left", 610, 290 )
$pixel6 = PixelGetColor (612, 290 )
If $pixel6 <> 9211020 Then MouseClick ("left", 612, 290 )
$pixel7 = PixelGetColor (614, 290 )
If $pixel7 <> 9211020 Then MouseClick ("left", 614, 290 )
$pixel8 = PixelGetColor (616, 290 )
If $pixel8 <> 9216200 Then MouseClick ("left", 616, 290 )
$pixel9 = PixelGetColor (618, 290 )
If $pixel9 <> 10521740 Then MouseClick ("left", 618, 290 )
$pixel10 = PixelGetColor (620, 290 )
If $pixel10 <> 9211020 Then MouseClick ("left", 620, 290 )
$killed = PixelGetColor( 470 , 278 )
if $killed = 8092539 then Exit

there is a bit of the code... basically what I want it to do is

$killed = PixelGetColor( 470 , 278 )
if $killed = 8092539 then Exit

I want it to go back to being paused, and at the top of the script ready to go when I hit the hotkey again.... any suggestions?

thanks

Edited by homie

Share this post


Link to post
Share on other sites
Genos

try using "Return" instead of "Exit"

Exit will close the program, return will exit the function, normally with a value

Share this post


Link to post
Share on other sites
homie

ok I changed the exit to return... and when my script returns, it goes here:

Global $Paused
HotKeySet("{ESC}", "start")

While 1 ; <<<<<<------------------------------THIS IS WHERE IT RETURNS TOO-----------------------------------
    Sleep(100)
WEnd


Func start()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
    


$pixel1 = PixelGetColor (602, 290 )
If $pixel1 <> 16777215 Then MouseClick ("left", 602, 290 )
$pixel2 = PixelGetColor (604, 290 )
If $pixel2 <> 14333068 Then MouseClick ("left", 604, 290 )
$pixel3 = PixelGetColor (606, 290 )
If $pixel3 <> 9211020 Then MouseClick ("left", 606, 290 )
$pixel4 = PixelGetColor (608, 290 )
If $pixel4 <> 9211020 Then MouseClick ("left", 608, 290 )
$pixel5 = PixelGetColor (610, 290 )
If $pixel5 <> 9211020 Then MouseClick ("left", 610, 290 )
$pixel6 = PixelGetColor (612, 290 )
If $pixel6 <> 9211020 Then MouseClick ("left", 612, 290 )
$pixel7 = PixelGetColor (614, 290 )
If $pixel7 <> 9211020 Then MouseClick ("left", 614, 290 )
$pixel8 = PixelGetColor (616, 290 )
If $pixel8 <> 9216200 Then MouseClick ("left", 616, 290 )
$pixel9 = PixelGetColor (618, 290 )
If $pixel9 <> 10521740 Then MouseClick ("left", 618, 290 )
$pixel10 = PixelGetColor (620, 290 )
If $pixel10 <> 9211020 Then MouseClick ("left", 620, 290 )
$killed = PixelGetColor( 470 , 278 )
if $killed = 8092539 then return

how would I go about making it wait for the hotkey again?

thanks

edit ==== I figured it out, it is returning to the hotkey, i will prob run into more problems lol but atleast im learning.

Edited by homie

Share this post


Link to post
Share on other sites
Genos

You should be able to get rid of

$Paused = NOT $Paused
    While $Paused
        sleep(100)

That should solve your problem.

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.