Jump to content

Problem with Pausing The Entire Script


Recommended Posts

Hi, I'm pretty much new here, but please help me with my little script.

HotKeySet ( "e", "click" )

While 1

Sleep ( 100 )

WEnd

Func click()

Send ( "{PGDN}" )

Sleep ( 2000 )

MouseClick ( "left", 565, 519, 1, 1 )

Sleep ( 8000 )

MouseClick ( "left", 592, 487, 1, 1 )

Sleep ( 2000 )

MouseClick ( "left", 559, 522, 1, 1 )

Sleep ( 2000 )

MouseClick ( "left", 809, 552, 1, 1 )

Sleep ( 2000 )

MouseClick ( "left", 562, 748, 1, 1 )

Sleep ( 25000 )

MouseClick ( "left", 672, 692, 1, 1 )

Send ( "t" )

Sleep ( 100 )

Send ( "z" )

EndFunc

It's for a small game. Basically if I type "e", then the mouse will move and click according to the script commands, and then push "t" and "z" as you can see. Now, the problem is that to chat in-game, I have to push "enter", to bring up the chat box, then type in my msg ex. "hello", then push "enter" again to send the msg. So... when I type "h-e-l-l-o", when I type the "e", the script executes, the mouse moves and there's the "t" and "z" at the end of my msg. So what I want to know is if there is any way that I can make the script paused when I pushed "enter" once and then resume again when I pushed "enter" the 2nd time. Now, I have read and search the forum already, as well as the help file, and came across the "Paused" command:

Global $Paused

HotKeySet("{PAUSE}", "TogglePause")

While 1

Sleep(100)

WEnd

Func TogglePause()

$Paused = NOT $Paused

While $Paused

sleep(100)

ToolTip('Script is "Paused"',0,0)

WEnd

ToolTip("")

EndFunc

I tried and it didn't work the way I wanted. I toggle the paused function on, but when I pushed "e", my script still executes. From what I understand, the Paused Function from the help file is just a loop, so it didn't help much in my case. So basically, I'm wondering if there is any command or way that will pause the whole script to pause or suspend (similar effect to if I haven't even run the script yet) when I pushed "enter", and then resume normally when I pushed "enter" again. Please help me solve this problem and thank you in advance and for your time. :)

Link to comment
Share on other sites

you had "2" while/Wend loops

Global $Paused

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("e", "click")

While 1
    Sleep(100)
WEnd

Func click()
    Send("{PGDN}")
    Sleep(2000)
    MouseClick("left", 565, 519, 1, 1)
    Sleep(8000)
    MouseClick("left", 592, 487, 1, 1)
    Sleep(2000)
    MouseClick("left", 559, 522, 1, 1)
    Sleep(2000)
    MouseClick("left", 809, 552, 1, 1)
    Sleep(2000)
    MouseClick("left", 562, 748, 1, 1)
    Sleep(25000)
    MouseClick("left", 672, 692, 1, 1)
    Send("t")
    Sleep(100)
    Send("z")
EndFunc   ;==>click

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

8)

NEWHeader1.png

Link to comment
Share on other sites

Thank you for the quick reply :) but... I'm still having the same problem. I tried running the script you posted but after I pushed "pause", and the msg at the top left says "Script is Paused", and then I pushed "e", my script still executes. To simplify the script:

Global $Paused

HotKeySet("{PAUSE}", "TogglePause")

HotKeySet("e", "click")

While 1

Sleep(100)

WEnd

Func click()

Send("t")

Sleep(100)

Send("z")

EndFunc ;==>click

Func TogglePause()

$Paused = Not $Paused

While $Paused

Sleep(100)

ToolTip('Script is "Paused"', 0, 0)

WEnd

ToolTip("")

EndFunc ;==>TogglePause

Even after I pushed "pause" and the script is supposed to be paused, when I push "e", the script still executes and it sends "t" and "z". So the question is, is there a way to pause the script so that when I pause it and push "e", it will send only "e" and not "t z". Thank you again for the reply

Link to comment
Share on other sites

In your pause function, turn off the hotkey for e, and if it is already off, turn it back on.

Global $Paused

HotKeySet("{ENTER}", "TogglePause")
HotKeySet("e", "click")

While 1
    Sleep(100)
WEnd

Func click()
    Send("{PGDN}")
    Sleep(2000)
    MouseClick("left", 565, 519, 1, 1)
    Sleep(8000)
    MouseClick("left", 592, 487, 1, 1)
    Sleep(2000)
    MouseClick("left", 559, 522, 1, 1)
    Sleep(2000)
    MouseClick("left", 809, 552, 1, 1)
    Sleep(2000)
    MouseClick("left", 562, 748, 1, 1)
    Sleep(25000)
    MouseClick("left", 672, 692, 1, 1)
    Send("t")
    Sleep(100)
    Send("z")
EndFunc   ;==>click

Func TogglePause()
    HotKeySet("{ENTER}")
    Send("{ENTER}")
    HotKeySet("{ENTER}", "TogglePause")
    $Paused = Not $Paused
    If $Paused Then
        HotKeySet("e")
    Else
        HotKeySet("e", "click")
    EndIf
EndFunc   ;==>TogglePause

This will work. I also changed the hotkey for pause to enter. This script will turn off checking for e when you press enter, then when you hit enter again, it will turn e checking back on.

Edited by Richard Robertson
Link to comment
Share on other sites

Wow, excellent help in this Forum.

Just a thought - why did you pick "e" as your hot key? Why not, say, alt-E or F12 or something that is otherwise not used by the application?

Then you wouldn't have to pause, or do ANYTHING, and -- although the proposed solution is WONDERFUL -- you could just have a tiny program that doesn't NEED to be that complex.

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...