Jump to content

Hotkey question


MrJambix
 Share

Recommended Posts

I'm not to sure that i'm posting in the right section but just let me know if I'm not.

My question / problem :

I'm making this hotkey to enable / toggle pause on the script... but not for a specific amount of time, but just until i decide to press the hotkey again to resume . So far i think I've written it correctly but I'm missing something and I'm not to sure what it is.

Take in mind that I'm still not that great writing functions this is my first Hotkey function that I'm doing, and i appreciate all the help i get.

The function works great to start it, but it doesn't work to pause it. In other words the Hotkey function works fine when i press numberpad 0 the script Starts, but if i want to pause it i press it again and it doesn't pause.

Here is what i got.

Global $pause = "pause"

;HotKeySet
HotKeySet("{NUMPAD0}","pause")

$start = GUICtrlCreateButton("Start", 120, 85, 50,30)
$pause = GuiCtrlCreateButton("Pause", 180, 85, 50,30)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Start
   GUICtrlSetState($Combo1, $GUI_DISABLE)
   GUICtrlSetState($Combo2, $GUI_DISABLE)
   GUICtrlSetState($Combo3, $GUI_DISABLE)
   GUICtrlSetState($start, $GUI_DISABLE)
   GUICtrlSetState($pause, $GUI_DISABLE)
   bot()
EndSwitch
WEnd

Func pause()
$pause=GUICtrlRead($pause)
If $pause= "Stop= 'Pause'" Then
   GUICtrlSetData($start,"Start")
    GUICtrlSetState ( $start, $GUI_ENABLE )
    GUICtrlSetState ( $pause, $GUI_ENABLE )
    $start=GUICtrlRead($start)
     if $start=("Start") Then
      $start=0
     EndIf
ElseIf $start= "Start" Then
   GUICtrlSetData($pause,"Stop= 'Pause'")
    GUICtrlSetState ( $start, $GUI_DISABLE )
    GUICtrlSetState ( $pause, $GUI_DISABLE  )
    $pause=GUICtrlRead($pause)
     if $pause=("Pause") Then
      $start=1
     EndIf
EndIf
EndFunc
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...