Sign in to follow this  
Followers 0
newman001

pause script function help!

8 posts in this topic

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

Share this post


Link to post
Share on other sites



then instead.. what should i do.. define it a variable, and while its =to 1, make it run set it to 0 would pause it...? sorry.. im still new at this, so please bare w/ me.

Share this post


Link to post
Share on other sites

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

[center]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.[/center]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

HotKeySet("Key") disables a function

You are specifying a null function with this: HotKeySet("Key", "")

Larry just means dont unset it ten times a second in the pause

Edited by gamerman2360

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

[center]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.[/center]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

ahh thanks so much for ur help! the script works perfectly now :D

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  
Followers 0