Jump to content
Sign in to follow this  
silwerstar

WinWaitActive/Winactivate issues

Recommended Posts

silwerstar

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

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?

WinActivate("Vision")
WinWaitActive("Vision")
SendKeepActive("Vision")
sleep(2000)
Send("^!y")
Please help!! Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

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

 

Share this post


Link to post
Share on other sites
silwerstar

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?

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

Share this post


Link to post
Share on other sites
water

Does Vision have an API to automate it?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
silwerstar

No it doesn't have any API to automate.

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  

×