Jump to content

Recommended Posts

Posted (edited)

Good day,

I have been employing HotKeySet scripts, and am wondering if it is all possible to have a script that creates a button|label|menu option that performs the following:

1) The button|label|menu option initially states "Enable HotKey"
2) A message is then displayed that states "HotKey enabled".
3) Upon selection of the button|label|menu option, the button|label|menu option then states "Disable HotKey".
3) Upon selection of the the button|label|menu option, the HotKey is then exited.

Any assistance in this matter would be greatly appreciated!

Edited by mr-es335
Posted
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 370, 128, 192, 114)
$Button1 = GUICtrlCreateButton("Enable Hotkey", 121, 37, 113, 40)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $HotkeKeyState=0, $HotkeKeyStateNotification=0, $HotkeKeyTimer=-1

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If $HotkeKeyState=0 Then
                $HotkeKeyStateNotification=1
                $HotkeKeyTimer=TimerInit()
                $HotkeKeyState=1
                GUICtrlSetData ($Button1,"Disable Hotkey")
            Else
                Exit
            EndIf
    EndSwitch

If $HotkeKeyStateNotification=1 Then
    IF TimerDiff($HotkeKeyTimer)<=5000 Then
        $MP=MouseGetPos()
        ToolTip ("Hotkey is enabled",$MP[0]-30,$mp[1]-50)
    Else
        $HotkeKeyStateNotification=0
        ToolTip("")
    EndIf
EndIf
WEnd

 

Some of my script sourcecode

Posted (edited)
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=

Global $HotkeKeyState = 0, $HotkeKeyStateNotification = 0, $HotkeKeyTimer = -1

Gui()

Func Gui()
    $Form1 = GUICreate("Form1", 370, 128, 192, 114)
    $Button1 = GUICtrlCreateButton("Enable Hotkey", 121, 37, 113, 40)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete ($Form1)
                Exit
            Case $Button1
                If $HotkeKeyState = 0 Then
                    $HotkeKeyStateNotification = 1
                    $HotkeKeyTimer = TimerInit()
                    $HotkeKeyState = 1
                    GUICtrlSetData($Button1, "Disable Hotkey")
                Else
                    Exit
                EndIf
        EndSwitch
        Notify()
    WEnd
EndFunc   ;==>Gui

Func Notify()
    If $HotkeKeyStateNotification = 1 Then
        If TimerDiff($HotkeKeyTimer) <= 5000 Then
            $MP = MouseGetPos()
            ToolTip("Hotkey is enabled", $MP[0] - 30, $MP[1] - 50)
        Else
            $HotkeKeyStateNotification = 0
            ToolTip("")
        EndIf
    EndIf
EndFunc   ;==>Notify

 

Edited by Dan_555

Some of my script sourcecode

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...