Jump to content

Odd Behavior - Switching States Via Variable Control


Recommended Posts

Having weird issues with switching states via variable control ($handleState)

On initial run, the ` function (pausePlay) works correctly with VLC.

However, after pressing F5 (whether once or twice) the function no longer activate correctly with VLC or Firefox.

However, if I add ToolTip() into the pausePlay function (currently commented in the code below), suddenly the script works as expected, and the function will trigger after F5 is pressed.

I've used variable to change the state of a script numerous times before (in fact, the full version of this script has another state change, which works fine), but this is the first time I've had this issue.

Global $handleState = 0
Opt("WinTitleMatchMode", 2)

HotKeySet("{F1}", "quit")

Func quit()
    Exit
EndFunc

HotKeySet("{F5}", "changeHandle")
HotKeySet("`", "pausePlay")

Func changeHandle()
    If $handleState = 0 Then
        $handleState = 1
        ToolTip("Anki Symbol Firefox" & @CRLF & "F1 Exit; F4 Help", 0, 0)
    Else
        $handleState = 0
        ToolTip("Anki Symbol VLC" & @CRLF & "F1 Exit; F4 Help", 0, 0)
    EndIf
EndFunc   ;==>changeHandle

Func pausePlay()
    ;ToolTip("", 0, 0)
    If $handleState = 0 Then
        ControlSend(WinGetHandle("VLC"), "", "", "{SPACE}")
    Else
        ControlSend(WinGetHandle("Firefox"), "", "", "{SPACE}")
    EndIf
EndFunc   ;==>pausePlay

While 1
    Sleep(10000)
WEnd

 

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