Jump to content

mouse click/while loop simple query


Recommended Posts

Hi all,

I just wrote a script that seems to loop until I press my specified key, as summarised below:

HotKeySet("`", "QuitLoop");
$counter = 0
Func QuitLoop()
$counter=1
EndFunc
While $counter=0
[b]BODY[/b]
WEnd

What this clearly does is, upon execution of the exe, loops the body of the while function, which was my idea. However, after pressing "`" to increment the counter variable and stop the while loop, the program ends.

My intention is to reuse the "`" key to start the while loop at my discretion, after another keypress, to the following effect:

Run exe, while loop running

hit `, while loop stops

x seconds/minutes later, hit `, while loop restarts

rinse and repeat to my joy

Thanks in advance!

Link to comment
Share on other sites

This is how I like to do my setup

HotKeySet("`", "CheckLoop")
Global $Counter
_LoopOn()
Func CheckLoop()
If $Counter = 0 Then
$Counter = 1
_LoopOff()
Else
$Counter = 0
MsgBox(0, "Test", $Counter)
_LoopOn()
EndIf
EndFunc
Func _LoopOn()
While $Counter = 0
Sleep(1000)
MsgBox(0, "Test", "Loop on")
WEnd
EndFunc
Func _LoopOff()
MsgBox(0, "Test", "Loop off")
EndFunc
While 1
Sleep(10)
WEnd

Let me know if anything is confusing!

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

This is how I like to do my setup

HotKeySet("`", "CheckLoop")
Global $Counter
_LoopOn()
Func CheckLoop()
If $Counter = 0 Then
$Counter = 1
_LoopOff()
Else
$Counter = 0
MsgBox(0, "Test", $Counter)
_LoopOn()
EndIf
EndFunc
Func _LoopOn()
While $Counter = 0
Sleep(1000)
MsgBox(0, "Test", "Loop on")
WEnd
EndFunc
Func _LoopOff()
MsgBox(0, "Test", "Loop off")
EndFunc
While 1
Sleep(10)
WEnd

Let me know if anything is confusing!

Hi!

Your code works fine but when I press "`" to turn the loop off the script terminates rather than... enters sleep, for lack of better terms lol.

I essentially want to be able to press "`" a potentially infinite amount of times before I decide to terminate the script.

In case it's my error I bunged the while body required in the LoopOn() function after sleep(1000), replacing the message box.

Please help and thanks again!

Link to comment
Share on other sites

One other thing: Shift will not register at all, the relevant code in the while loop is:

Send("{+ down}")
Sleep(5000)
Send("{+ up}") 
Sleep(5000)

For a clear example to hold the shift key down when I'm in VLC or powerDVD or powerDirector render mode etc... I've replaced that bit of the while loop with another key such as "5" to test that a key is being held down correctly, and it is - just not shift!

Are there any other alternatives to coding the holding of shift? I've tried the options KeyDelay and KeyDownDelay with no joy, more issues!

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