StudioMaker

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

11 posts in this topic

#1 ·  Posted

Yeh, how do i have the both key on hotkeyset to both start and stop a script?  Or not stop the whole script , just stop the func?

Share this post


Link to post
Share on other sites



#2 ·  Posted

Same*
xD

Share this post


Link to post
Share on other sites

#3 ·  Posted

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.

Share this post


Link to post
Share on other sites

#5 ·  Posted

Thanks! :D

Share this post


Link to post
Share on other sites

#6 ·  Posted

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

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

Or like the key can start but not stop*

Share this post


Link to post
Share on other sites

#8 ·  Posted

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

 

Share this post


Link to post
Share on other sites

#9 ·  Posted

Ye ty i did just sent a little bit of the script cus it is very big.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#11 ·  Posted

@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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.