Jump to content

Variable Sleep input from Edit Box?


SXGuy
 Share

Recommended Posts

Hi im stuck on somthing and wonderd if you can help

I wish to set F12 as a hotkey, which will press the Home key and then call on the edit box on my gui for a number, and then place it in my function as a sleep variable, so it sleeps for that set time before repeating the key press.

Here is what ive got so far, i wonder if anyone can give me some tips.

#include <GUIConstants.au3> 


Opt("GUIOnEventMode", 1) 
GuiCreate("SX Bot V2 - SXGuy", 512, 410,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) 
$Inst = GUICtrlCreateButton("Instructions", 424, 8, 81, 25, 0)
$Wait = GUICtrlCreateEdit("00000", 424, 300, 81, 25, 0)   ;new
GUICtrlCreateLabel("AUTOSKILL [F12]                           Set Skill Length In Milliseconds - 1000m/s = 1 Sec", 1, 310)
GUISetState(@SW_SHOW) 



#NoTrayIcon 

HotKeySet("{F12}", "ToggleAutoSkill")
HotKeySet("{ESC}", "OnAutoItExit")

Global $AutoSkill = 0 
While 1 
    Sleep(5)

If $AutoSkill = 1 then
        send("{HOME}")
        Sleep ( $Wait )
    EndIf
WEnd

Func ToggleAutoSkill()
    $AutoSkill = Not $AutoSkill
EndFunc

Func OnAutoItExit ()
Exit(0)
EndFunc

Im sure you can see what im trying to do with this script, am i heading in the right direction?

Link to comment
Share on other sites

Thanks

Im not sure if this is working though,

Do i need to add anything else to the script for it to store the value of $Wait first?

is this correct

$Wait = GUICtrlCreateEdit("00000", 424, 300, 81, 25, 0)

Do i need anything else, besides

If $AutoSkill = 1 then 
        send("{HOME}")
        Sleep ( GUICtrlRead($Wait) )
EndIf
Edited by SXGuy
Link to comment
Share on other sites

ok i changed it a little, and it works, however, it now continiously sends home once the gui has loaded, rather than waits for the hotkey to be pressed. i dont know what ive done wrong, can someone take a look?

If $AutoSkill = 1 then GUICtrlRead ( $Wait )
        send("{HOME}")
        Sleep ( $Wait )
EndIf

Obviously it continuiously sends "home" because $Wait is equal to no delay until i add a value in the edit box, however, how do i get it to only function once the hot key is pressed? and not beforehand.

Should i be doing this instead?

If $Wait > 0 then GUICtrlRead ($Wait)
Send ("{HOME}")
Sleep ($Wait)
Edited by SXGuy
Link to comment
Share on other sites

ok i changed it a little, and it works, however, it now continiously sends home once the gui has loaded, rather than waits for the hotkey to be pressed. i dont know what ive done wrong, can someone take a look?

If $AutoSkill = 1 then GUICtrlRead ( $Wait )
        send("{HOME}")
        Sleep ( $Wait )
EndIf

Obviously it continuiously sends "home" because $Wait is equal to no delay until i add a value in the edit box, however, how do i get it to only function once the hot key is pressed? and not beforehand.

Should i be doing this instead?

If $Wait > 0 then GUICtrlRead ($Wait)
Send ("{HOME}")
Sleep ($Wait)

If $AutoSkill = 1 then 
  $value = GUICtrlRead ( $Wait )
        send("{HOME}")
        Sleep ( $value )
EndIf
Link to comment
Share on other sites

thanx that works great, however i now have a new problem

how can i make a script, press x and y continiously, but breaks to press z, after a certain amount of times, then goes back to x and y until the next time.

While 1 
    Sleep(5) 
    
    if $AL = 1 then send("x") 
    if $AA = 1 then send("y)
    If $AS = 1 then send("z")
    Sleep (GUICtrlRead ($Wait)
EndIf 
WEnd

As you can see, it will send x and y together if i toggle the hotkeys, however, when i toggle the hotkey for z, it will sleep until $wait and then press xy and z, but what i would like is, for it to send x and y continiously until $wait, and then press z, and then revert back to x and y until $wait again, if that makes sense?

i thought maybe somthing like making it press z, then jump out of the while statment, and pres x and y until the loop has ended, and then go back to the while statment after a period of time i.e $wait. is this the right method to go by?

im not sure if this would work,

_1()
While 1 
    Sleep(5) 
    
    if $AL = 1 then send("x") 
    if $AA = 1 then send("y)
    If $AS = 1 then send("z")
    Call _2
           EndIf 
    EndIf 

_2()
GUICtrlRead ($Wait)
Loop $Wait
send ("x")
send ("y")
End

While 1
Call _1
WEnd

im sure you can see what im trying to do, can anyone give me some tips?

Edited by SXGuy
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...