silwerstar Posted March 16, 2014 Posted March 16, 2014 (edited) I am writing an autoit script which tends to open an application [Vision]. When this application is open, the script intends to access an option from the menu which in turn causes another window within the same application to be opened. After configuring and saving some settings, the control is again returned back to the main window in the application [Vision]. I intend to automate this whole thing using auto-it. However, WinActivate() behaves weirdly. I am not sure how to resolve this. Can someone help with it? The following is my code:expandcollapse popupDim $num,$file_name,$opening_file $num = 1 $file_name = "Hello" $opening_file = "Vision - [" & $file_name & "]" Opt("WinTitleMatchMode", 2); AutoItSetOption ("TrayIconDebug", 1);0-off Local $pid_handle = ProcessExists("Vision.exe") If $pid_handle Then ProcessClose($pid_handle) Endif Run("C:\Program Files\Vision.exe") WinWait("Vision - [Start Page]") WinWaitActive("Vision") SendKeepActive("Vision") sleep(3000) Send("!f") Send("n") WinWait("Capture Options - ") WinWaitActive("Capture Options - ") SendKeepActive("Capture Options") ControlClick("Capture Options","",32494) sleep(1000) ControlSetText("Capture Options","",1487,$file_name,"") Send("{DOWN}") Send("{Tab}") WinActivate("Capture Options - ") ControlClick("Capture Options","",32494) sleep(1000) Send("{DOWN}{Tab}") ControlCommand("Capture Options","",1471,"ShowDropDown","") If $num = 1 Then ControlCommand("Capture Options","",1471,"SelectString","1 - here u go") Elseif $num = 2 Then ControlCommand("Capture Options","",1471,"SelectString","2 - blah blah..") EndIf sleep(2000) Send("{ENTER}") ControlClick("Capture Options", "", 1) sleep(1000) WinActivate("Vision") WinWaitActive("Vision") SendKeepActive("Vision") sleep(2000) Send("^!y")The problems that I face are as follows: a) Though the Vision.exe gets opened using the Run() command, if I happen to click on some other window [GUI/Desktop/Browser], the Vision GUI loses focus and the autoit script gets stuck up at WinWaitActive() line forever and never returns. Isn't the autoit supposed to bring the focus onto the Vision GUI by itself. This way, I see the whole of my automation script fail, if I happen to meddle with the system when it just about happened to open the Vision GUI. How do I fix this? As I said earlier, the flow that needs to happen is: Vision GUI gets opened. Using Alt F or similar commands, I happen to open another dialog box in the GUI. This causes some config settings to be applied. I save and I return back to the vision GUI main window. Now the problem that I face here is that sometimes the Vision GUI's main window is never activated by the autoit and here too I end up waiting on the WinWaitActive line. Isn;t it supposed to have activated Vision main window before reaching the second line?WinActivate("Vision") WinWaitActive("Vision") SendKeepActive("Vision") sleep(2000) Send("^!y")Please help!! Edited March 16, 2014 by Melba23 Added code tags
Moderators Melba23 Posted March 16, 2014 Moderators Posted March 16, 2014 silwerstar,Welcome to the AutoIt forum. When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
silwerstar Posted March 16, 2014 Author Posted March 16, 2014 Hi, WinActivate("Hello") WinWaitActive("Hello") send( ) ... some send commands in here Firstly, what is the difference between the two lines? Secondly, when I check the return value of WinActivate, autoit seems to have activated my application Hello but I don't see it having the focus/visible... a) Am I missing anything here? Should WinActivate be always followed by WinWaitActive? c) How do I ensure that the send commands that I give for the Hello application are executed only when the Hello GUI's main window is visible? Please help
water Posted March 16, 2014 Posted March 16, 2014 Does Vision have an API to automate it? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
silwerstar Posted March 16, 2014 Author Posted March 16, 2014 No it doesn't have any API to automate.
JohnOne Posted March 16, 2014 Posted March 16, 2014 WinWait("title") WinActivate("title") AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Developers Jos Posted March 16, 2014 Developers Posted March 16, 2014 Merged your 2 topics and please syick to one going forward. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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