Jump to content

How can i have the same hotkey to both start and stop?


Recommended Posts

the operation of doing both start and stop depending on current status is called "toggle".

assign the desired key to a function which holds a global (or local static) boolean var. the script is running and initializing said var to True. when the function is called, it checks for the var, if True it stops the script and sets the var to False, and vice-versa.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Or actuually, In my script thing that i currently have it did not work, I have so that you have to write an key and Click a checkbox and the key you writed is the hotkey and for some reason, it did not work 

Global $iToggle = 0

Func _Key()
    $Var1 = GUICtrlRead($Input2)
    HotKeySet($Var1, "_Toggle")
    while 1
        sleep(10)
        WEnd

EndFunc

While 1
    Sleep(10)
WEnd

Func _Toggle()
        While 1
    send("{SPACE UP}")
    sleep(27)
    send("{SPACE DOWN}")
    sleep(15)
Wend

    If Mod($iToggle, 2) = 0 Then
        SplashTextOn("", "Currently On")
        $iToggle +=1
    Else
        SplashOff()
        $iToggle +=1
    EndIf
EndFunc

 

Link to comment
Share on other sites

Your script as posted either isn't complete or doesn't make sense. I'm guessing you only posted a portion of the code because you've defined a function _key, but it never gets executed. Also, once _Toggle gets called, it will get stuck in the While loop. You should move this loop to some other portion of your script, something like --

Global $iToggle = 0

_Key()

While 1
    sleep(10)
    
    If $iToggle Then
      send("{SPACE UP}")
      sleep(27)
      send("{SPACE DOWN}")
      sleep(15)
    Endif
WEnd

Func _Key()
    $Var1 = GUICtrlRead($Input2)
    HotKeySet($Var1, "_Toggle")
EndFunc

Func _Toggle()
    $iToggle = Not $iToggle
EndFunc

 

Link to comment
Share on other sites

Doe, It dont seems to work correctly. When i type in the key and then click the checkbox and then click the key the whole thing just shuts.. I would really need help. 

GUICtrlSetData(-1, "| By StudioMakerVFX! :)|(Notice, If you use any of these hacks, there is a risk to get banned)|here"&Chr(39)&"s my tradelink: https://steamcommunity.com/tradeoffer/new/?partner=120292336&token=6aPnqwgi|If u want to support me with skins (Donations are very appreciated)|MOTD: Have fun with xD :)  /StudioMaker")

 

Edited by Jos
Link to comment
Share on other sites

  • Developers

@StudioMaker,

Welcome to the AutoIt forum. :)

Unfortunately you appear to have missed the Forum rules on your way in. (there is also a link in my signature) 
Please read them now particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. :naughty:

See you soon with a legitimate question I hope. :)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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