Jump to content

pause script function help!


Recommended Posts

ok.. ive only quite recently learned about AutoIT.. so im still quite new... im trying to write a script that will repetedly click the left mouse button, as well as every half hour, press the "1" number key. i have the program working fine except for the pause function.. it keeps giving me error saying that:

line 0 (file "c:\test.exe"):

hotkeyset("{end}","")

Error: Unknown Function name.

i cant figure out why it says that though.. can anyone help me through it.. heres my code below:

Global $Paused
hotkeyset("{end}", "_run")
hotkeyset("{home}", "_stop")
HotKeySet("{del}", "_pause")

while 1
sleep(1)
wend

func _mouseclick()
while 1
MouseClick("left")
sleep(10)
wend
EndFunc

Func _keypress()
while 1
send("1")
sleep(30000)
WEnd
EndFunc

Func _run()
    _mouseclick()
    _keypress()
EndFunc

Func _pause()
    $Paused = NOT $Paused
    While $Paused
        hotkeyset("{end}", "")
        hotkeyset("{home}", "")
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    hotkeyset("{end}", "_run")
    hotkeyset("{home}", "_stop")
    ToolTip("")
    EndFunc
Func _stop()
    Exit
;need pause
EndFunc

any help will be appreciated :D

Link to comment
Share on other sites

  • Moderators

You set a blank as a function name in the hotkey parameter

hotkeyset("{end}", "")
Try removing the , '' like this:
hotkeyset("{end}")

Also I wouldn't put that in the loop like that because you only need to tell it once:

Func _pause()
    $Paused = Not $Paused
    If $Paused Then
        HotKeySet("{end}")
        HotKeySet("{home}")
        While $Paused
            Sleep(10)
            ToolTip('Script is "Paused"',0,0)
        WEnd
    EndIf
    HotKeySet("{end}", "_run")
    HotKeySet("{home}", "_stop")
    ToolTip("")
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

You also might not want to show the tooltip that many times either.

And since the loop in _mouseclick() never ends you never get to the _keypress()

Ha, I never looked at anything but the function in question, nice catch :D

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

You might want to look at Opt() to set the speed at which you type(wouldnt recommend making it as fast as you can), try

AdlibEnable("_keypress", 30000)

Another thing, a sleep time of 1ms is 1/1000 of a second. So to get 30 mins you need to take 1000ms times 60 seconds times 30 minutes.

1000*60*30... 1800000

You may find another problem with the _mouseclick() loop and the way the function is called.

Edited by gamerman2360
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...