Jump to content

Preety noob looks for help


Recommended Posts

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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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?
Link to comment
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!

Link to comment
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?

Link to comment
Share on other sites

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
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...