Tobytja Posted May 24, 2013 Posted May 24, 2013 Hello, I need to modify an au3 script I got. The script simulates user actions in certain software and sometime pauses for several seconds, because the software is quite slow. Sometimes the scripts sleeps for more than a minute just to be sure it doesn't go ahead of the software. Like a command is given to the software to open a dialogue window, which sometimes takes a very long time. So the script waits for a minute to be sure the window is opened. But sometimes (most of the time) the window is opened after some 10 seconds and the script waits for almost a minute in vain, which impedes work. So I need some feature to tell the script "Wait until something happens". This is the example of the script: Send("{ALTDOWN}4{ALTUP}") Send("{DOWN}{DOWN}{DOWN}{DOWN}") Send("{ENTER}") sleep(40000) Send("{ENTER}") #Add activity history sleep(1500) send("Issue is PtC: Report from SDM shows 0 violations.") sleep(200) Send("{tab}") sleep(200) Send("{space}") Anyone able to help? Thanks in advance
orbs Posted May 24, 2013 Posted May 24, 2013 instead of Sleep(), use WinWaitActive() to wait for the desired window to appear. see the AutoIt help, there are examples and totorials there, Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates WinPose - simultaneous fluent move and resize Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Magic Math - a math puzzle Demos: Title Bar Menu - click the window title to pop-up a menu
Tobytja Posted May 24, 2013 Author Posted May 24, 2013 OK, thanks. Now if the window has no title at all and only empty text field is its contents, can I just put WinWaitActive("") in the script?
orbs Posted May 24, 2013 Posted May 24, 2013 do this first: 1) use the tool "AutoIt Window Info" (installed with AutoIt), it will give you all the info you need to identify the window 2) look at the help for WinWaitActive() to see what parameters you can work with. the rest you will simply need to try. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates WinPose - simultaneous fluent move and resize Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Magic Math - a math puzzle Demos: Title Bar Menu - click the window title to pop-up a menu
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now