Sign in to follow this  
Followers 0
jthomas07762

New to AutoIT

9 posts in this topic

#1 ·  Posted (edited)

Hey everyone i am new to auto it. I have recently downloaded the program and am trying to figure out how to get a program to "restart" its function when the pause/unpause button is used. I do not wish to have this loop, unless end loop time is long so it can be repaused without having to worry about it performing the action twice in a row rapidly. here is a script i found and edited to perform the function i need.

Opt('MouseCoordMode', 0)
Opt('PixelCoordMode', 0)
HotKeySet('{END}', 'Quit')
HotKeySet('{Home}', 'Pause')
Global $Paused

;starts paused. press home to start.
Pause()

Send ("i")
MouseClick("right",1019,604,1)
Sleep ("100")
MouseClick("right",1055,593,1)
Sleep ("100")
MouseClick("right",1091,586,1)
Sleep ("100")
MouseClick("right",1021,564,1)
Sleep ("900")
Send ("i")


Func Pause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip('Paused...', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>Pause
Edited by jthomas07762

Share this post


Link to post
Share on other sites



jthoma07762,

What is it doing / not doing for you?

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

It starts the program paused which i want. When i hit Home(unpause) it performs the operation flawlessly. but then the program exits. I wish to have the program stay open and possibly have it be able to restart and stop when i pause and unpause? if that is possible.

Share this post


Link to post
Share on other sites

Opt('MouseCoordMode', 0)
Opt('PixelCoordMode', 0)
HotKeySet('{END}', 'Quit')
HotKeySet('{Home}', 'Pause')
;HotKeySet('{PGDN}', 'start')
Global $Paused

;starts paused. press home to start.
Pause()

while 1
start()
wend

func start()
Send ("i")
MouseClick("right",1019,604,1)
Sleep ("100")
MouseClick("right",1055,593,1)
Sleep ("100")
MouseClick("right",1091,586,1)
Sleep ("100")
MouseClick("right",1021,564,1)
Sleep ("900")
Send ("i")
endfunc

Func Pause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip('Paused...', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>Pause


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

If you want to enhance your script I suggest to replace those Mouse* statements with ControlClick etc. Makes the script more reliable and independant of screen resolutions and window positions.


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

Opt('MouseCoordMode', 0)
Opt('PixelCoordMode', 0)
HotKeySet('{END}', 'Quit')
HotKeySet('{Home}', 'Pause')
;HotKeySet('{PGDN}', 'start')
Global $Paused

;starts paused. press home to start.
Pause()

while 1
start()
wend

func start()
Send ("i")
MouseClick("right",1019,604,1)
Sleep ("100")
MouseClick("right",1055,593,1)
Sleep ("100")
MouseClick("right",1091,586,1)
Sleep ("100")
MouseClick("right",1021,564,1)
Sleep ("900")
Send ("i")
endfunc

Func Pause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip('Paused...', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>Pause

Thank you for helping me. That works perfectly! Now i am just wondering, the program was able to be closed by hitting the end button. I think i may have deleted this line(s) of coding. Could you possibly Show me how to add this back? and the timing seems to be not working? Or maybe 100 is just not enough. If you could show me the code to stop my code for about 5 seconds after the final function is performed (hitting the i button) this way i wont have to be precise in hitting the unpause and pause button. I will have a little leway before it restarts.. Also I saw the forums for beginners. any suggestions on good posts to read up on?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Reference:

HotKeySet('{END}', 'Quit')

Solution:

Write the function this "HotKeySet" is referencing to: (Hint: "Quit")

Lookup "Exit" in the help file.

P.S. (It's only 3 lines of code)

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Reference:

HotKeySet('{END}', 'Quit')

Solution:

Write the function this "HotKeySet" is referencing to: (Hint: "Quit")

Lookup "Exit" in the help file.

P.S. (It's only 3 lines of code)

Thanks pretty simple once i thought about it. Thanks for the hint. I appreciate you not giving the code and making me figure it out, always better to learn that way. Thanks again! Program runs smoothly. Figure out time problem also. 100 Is a very minimal time lol.. Here is a copy of the script i found, edited; then finished for my specific task.

Opt('MouseCoordMode', 0)
Opt('PixelCoordMode', 0)
HotKeySet('{END}', 'Quit')
HotKeySet('{Home}', 'Pause')
Global $Paused

;starts paused. press home to start.
Pause()

while 1
start()
wend

func start()
Send("i")
MouseClick("right",1019,604,1)
Sleep("100")
MouseClick("right",1055,593,1)
Sleep("100")
MouseClick("right",1091,586,1)
Sleep("100")
MouseClick("right",1021,564,1)
Sleep("100")
Send("i")
Sleep("1000")
endfunc

Func Quit()
Exit
EndFunc

Func Pause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip('Paused...', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>Pause
Edited by jthomas07762

Share this post


Link to post
Share on other sites

Use Controlclick instead of Mouse click for example..........

controlclick("windows title","","[Class:........; ID:......; INTANCE:....]","Right",1)

Use Au3.info to get Class name,,, ID and INSTANCE etc...................Au3.inf is normly in C:Program FilesAutoIt3


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

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