Jump to content

Basic Functions Questions


Recommended Posts

Hey I've just recently started learning AutoIt, I've had a look through the forums/google and couldn't find anything on this; so I was wondering if it possible to EndFunc half way through code on a command.

e.g.

HotKeySet("{F9}", "Cheese stop")

Func Cheese()

Sleep(1000)

Send("a")

Sleep(1000)

Send("a")

Sleep(1000)

Send("a")

Sleep(1000)

Send("a")

EndFunc

Is there anyway to assign F9 to cancel running through the 'Cheese' function at any location throughout the code?

Any help appreciated!

Link to comment
Share on other sites

Global Run = true

HotKeySet("{F9}", "Cheese stop")

HotKeySet("{F8}", "stop")

Func Cheese()

Sleep(1000)

If not $run then

$run = $true

return

endif

Send("a")

Sleep(1000)

If not $run then

$run = $true

return

endif

Send("a")

Sleep(1000)

If not $run then

$run = $true

return

endif

Send("a")

Sleep(1000)

If not $run then

$run = $true

return

endif

Send("a")

EndFunc

Func Stop()

$run = false

end func

There may be other ways, this is only one.

You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!"
Link to comment
Share on other sites

as he said: RETURN forces your prog to jump out of the function.

HotKeySet("{F9}", "_Cheese")
HotKeySet("{F8}", "_stop")

Global $Exitfunc = False

Func _Cheese()
    
    For $a = 1 to 10
        
        Send('a')
        Sleep(1000)
        ; just put this line anywhere in the Code & if you hit F8 & when program reaches this point, it will exit the function
        If $Exitfunc = True then Return 
    Next
EndFunc

Func _Stop()
    $Exitfunc = True
EndFunc
    
    
; Infinite loop to keep program running 
While 1
    Sleep(100)
WEnd
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...