Soundarya Posted April 10, 2023 Share Posted April 10, 2023 (edited) Hello All, I am automating a desktop application. In mid of the process I am getting a Pop-Up and I have to capture the Title of the popup window and do a If loop to check the title. I tried multiple ways, (To get the Title of Active Window, Title of last Window and using the Class name (CLASS:#32770)) but nothing worked. I tried to retrieve the Tittle of Class name (CLASS:#32770) and it was a different title. So doubt if there are multiple Windows with same Class name. Can any one help me to get the Title of pop up generated from my desktop application. Edited April 10, 2023 by Soundarya Link to comment Share on other sites More sharing options...
Danp2 Posted April 10, 2023 Share Posted April 10, 2023 Did you happen to try this method? Local $sText = WinGetTitle("[ACTIVE]") You may want to share some details about this desktop application. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Soundarya Posted April 10, 2023 Author Share Posted April 10, 2023 @Danp2 Yes I tried this and it is actually getting the title of my Original parent window and not the Pop-Up window Link to comment Share on other sites More sharing options...
Nine Posted April 10, 2023 Share Posted April 10, 2023 Could you post the related snippet of your code. Crystal ball is at repair shop Danp2 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mistersquirrle Posted April 10, 2023 Share Posted April 10, 2023 My suggestion without knowing more would that you could use an array of all windows (WinList() with no parameters). Each loop, get a new array of all windows and compare them both, looking for new windows. Then do whatever other checks on any new windows to see if it's the one you want. If not, store the new array to use to compare against in the next loop. Keep in mind that this approach feels fairly 'brute force'-y to me, and likely is not very performant. Other options would be to check out these functions: _WinAPI_EnumWindows https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_EnumWindows.htm _WinAPI_EnumChildWindows https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_EnumChildWindows.htm _WinAPI_EnumProcessWindows https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_EnumProcessWindows.htm These functions all allow you to keep the amount of windows that they retrieve down if you pass in the parent information, and you can do a much smaller comparison set to what is mentioned above. We ought not to misbehave, but we should look as though we could. Link to comment Share on other sites More sharing options...
Soundarya Posted April 11, 2023 Author Share Posted April 11, 2023 (edited) @Nine I want to handle the pop up displayed below and get its Title. I am also adding the Windows Info of the PopUp. I do not want to use the Title or Text to get the PopUp control. I actually do not want to give the Tittle or Text in pop up to get the handle because every time I receive different set of pop ups Edited April 11, 2023 by Soundarya Link to comment Share on other sites More sharing options...
Soundarya Posted April 11, 2023 Author Share Posted April 11, 2023 @Nine @mistersquirrle I figured the problem. The second Window takes some time to popup, so it considered my parent window always when I tried to get the text of active Window. I implemented Sleep and it worked, as I know the loading time of 2nd window is always stable. Can you share your comments on using sleep function in our code ? Link to comment Share on other sites More sharing options...
TimRude Posted April 12, 2023 Share Posted April 12, 2023 Generally, using Sleep to implement a pause to allow time for something specific to happen isn't the best option. While it may seem to always take x seconds for something to happen while you're testing your code, in real world operations your code may run on faster or slower hardware, the CPU or drive may be busy with something else, there may be a network bottleneck or interruption, or anything else to make your x second wait not work. If possible, it's best to find an event or trigger you can look for to tell you when to proceed. (For example, when you get ready to go somewhere with a friend, rather than wait an arbitrary 5 minutes for them to be in the car before you drive away, you wait as long as it takes until you see them in the seat. That's your event or trigger to know that it's safe to proceed.) The suggestion to watch for new windows to be created may provide you with just such an event. SkysLastChance 1 Link to comment Share on other sites More sharing options...
ioa747 Posted April 12, 2023 Share Posted April 12, 2023 I think that in this particular case fits WinWait("[TITLE:All Fields are Required!; CLASS:#32770]", "", 5) Pauses execution of the script until the requested window exists. I know that I know nothing Link to comment Share on other sites More sharing options...
Solution Soundarya Posted April 12, 2023 Author Solution Share Posted April 12, 2023 @ioa747 Thanks, in my case there are 2 different pop ups that occur on 2 different scenarios. I achieved by following below code Func SubmitJCL($Control) ControlClick($Control,"",'[REGEXPCLASS:WindowsForms\d+\.BUTTON\.app\.\d+\..*?; INSTANCE:4]') Sleep(1000) If WinExists("Submit JCL?","") Then Local $PopUp = WinWait("Submit JCL?","",0) ControlClick($PopUp, "","Button1") Else $Error = WinGetTitle('[Active]',"") $ErrorText = WinGetText('[Active]',"") ControlClick($Error, "","Button1") AppendToLogFile($Error,$ErrorText) EndIf EndFunc Link to comment Share on other sites More sharing options...
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