Sign in to follow this  
Followers 0
sELecTED

Preety noob looks for help

9 posts in this topic

Sleep("2400")
Send ("2")
Sleep ("1700")
Send ("3")
Sleep ("1700")
Send ("4")
Sleep("1700")
Send ("5")
Sleep("2400")
Send ("5")
Sleep("2400")
Send ("5")

This is my code. I want to start executing this loop when hotkey is pressed, and when pressed again to take the sequence from the beginning :mellow:.

can someone help me ? i must tell that im new to autoit and i think its nice

Share this post


Link to post
Share on other sites



Please have a look at "HotKeySet" in the help file. There you'll find a good example.

I understand that you can't interrupt a "blocking" function (like Sleep).

What do you want do do if the sequence is still running (due to the long sleep delays) and you hit the HotKey again?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d

;;;; Body of program would go here ;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

I dont understand how it could help me... like I told earlier im pretty noob

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Please try this script.

Alt+Shift+d starts your function, ESC exits the script .

HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "YourFunction") ;Shift-Alt-d

While 1
    Sleep(100)
WEnd

Func Terminate()
    ConsoleWrite("Exit" & @CRLF)
    Exit 0
EndFunc

Func YourFunction()
    ConsoleWrite('Starting "YourFunction"' & @CRLF)
    Sleep("2400")
    Consolewrite ("2" & @CRLF)
    Sleep ("1700")
    Consolewrite ("3" & @CRLF)
    Sleep ("1700")
    Consolewrite ("4" & @CRLF)
    Sleep("1700")
    Consolewrite ("5 - First time" & @CRLF)
    Sleep("2400")
    Consolewrite ("5 - Second time" & @CRLF)
    Sleep("2400")
    Consolewrite ("5 - Third time" & @CRLF)
    ConsoleWrite('Finished "YourFunction"' & @CRLF)
EndFunc
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

For a very basic understanding of hotkeys, functions and loops I've commented and simplified the example you posted:

HotKeySet("{ESC}", "Terminate") ;this binds the function "Terminate" to the key "ESC"
;what key do you want to use, and what name do you want to give your function?

While 1 ;This is the start of a loop. everything in here is repeated all the time
    Sleep(100) ;this is the content of the loop; the script just sleeps (waits) 100ms
WEnd ;This is the end of the loop.
;do you want your script to do anything when you don't press a hotkey?

Func Terminate() ;This is the start of function "Terminate" that is only executed when "ESC" is pressed
    Exit 0 ;This is what the function does; it exits the script
EndFunc ;This is the end of function "Terminate"
;what do you want your function to do?

Share this post


Link to post
Share on other sites

Thank you both of you. Water I modified the script you gave to me and i pretty made it work perfectly for what i need.

But now i want to do more: I want to create a simple GUI where i can insert a variable and then use the variable in the script.

HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "Rotation") ;Shift-Alt-d

While 1
    Sleep(100)
WEnd

Func Terminate()
    ConsoleWrite("Exit" & @CRLF)
    Exit 0
EndFunc

Func Rotation()
$i = 0
Do
    
    Sleep("2400")
    Send("2")
    
    Sleep ("1700")
    Send("3")
    
    Sleep ("1700")
    Send("4")
    
    Sleep("1700")
    Send("5")
    
    Sleep("2400")
    Send("5")
    
    Sleep("2400")
    Send("5")
    
    $i = $i + 1
Until $i = 10
    
EndFunc

I want to insert the variable after the "Until $i =" so my script could be repeated how many times I want. I'm testing and try to do this on my own. This script is usable in WOW (world of warcraft) and its very useful. I'll come back with update. Thank you guys!

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
    
GUICreate("Sagittaz Hunter AutoRotation v1.1", 120,50)
GUISetState(@SW_SHOW)
GUICtrlCreateLabel ("Numar Repetari", 16,2)
GUICtrlCreateInput ("", 16,20, 80,20, 0x2000)
$repeats = GuiCtrlRead


HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "Rotation") ;Shift-Alt-d

While 1
    Sleep(100)
WEnd

Func Terminate()
    ConsoleWrite("Exit" & @CRLF)
    Exit 0
EndFunc

Func Rotation()
$i = 0
Do
    
    Sleep("2400")
    Send("2")
    
    Sleep ("1700")
    Send("3")
    
    Sleep ("1700")
    Send("4")
    
    Sleep("1700")
    Send("5")
    
    Sleep("2400")
    Send("5")
    
    Sleep("2400")
    Send("5")
    
    $i = $i + 1
Until $i = $repeats
    
EndFunc

How shall i use the GuiCtrlRead to get the value inserted in the input?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

That's starting to look an awfull lot like a game bot.

Please read this.

edit:

The moderators probably won't be too bothered by this thread, so it'll just die of old age. :mellow:

Don't give up on autoit though. I learned the basics for a game bot and had allot of legitimate uses for the knowledge since.

Edited by Tvern

Share this post


Link to post
Share on other sites

oh, sry... im sorry didnt saw... waiting for moderation

Share this post


Link to post
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
Sign in to follow this  
Followers 0