Jump to content

WinWaitActive/Winactivate issues

Recommended Posts

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:

Dim $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
Run("C:\Program Files\Vision.exe")
WinWait("Vision - [Start Page]")
WinWait("Capture Options - ")
WinWaitActive("Capture Options - ")
SendKeepActive("Capture Options")
ControlClick("Capture Options","",32494)
ControlSetText("Capture Options","",1487,$file_name,"")
WinActivate("Capture Options - ")
ControlClick("Capture Options","",32494)
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..")

ControlClick("Capture Options", "", 1)

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?

B) 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?

Please help!! Edited by Melba23
Added code tags
Link to comment
Share on other sites

  • Moderators


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


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Link to comment
Share on other sites




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?

B) 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

Link to comment
Share on other sites

Does Vision have an API to automate it?

My UDFs and Tutorials:


Active Directory (NEW 2022-02-19 - Version - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version - Download
Outlook Tools (2019-07-22 - Version - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version - Download - General Help & Support - Wiki

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

ADO - Wiki
WebDriver - Wiki


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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...