BryanWall Posted December 14, 2023 Posted December 14, 2023 I am trying to automate a process. I can control click on the "Smart Select" object and sometimes sending a down arrow right after works just fine to select "SmartBase". However other times, a down arrow goes to a different object in the main window entirely and so far no combinations of button presses gets focus on that...thing. No idea what the technical name is for it. Window? Submenu? Control? Doesn't seem to be a dropdown. Sometimes that submenu/popup thing stays up when I use window info tool but all that is there is class and handle: I was able to use WinActivate("[CLASS:WindowsForms10.Window.808.app.0.b8acac_r18_ad1]") and it did work, at least until I restarted the machine and now the class has changed. I am trying to avoid MouseClick as much as possible. Any help would be apprecited. The potential solutions I can think of are below. Don't know if some would be possible much less the how. 1) I tried setting match mode to exact and using WinActive("") but that doesn't work unless I'm doing something wrong. 2) While writing this I noticed that Class info for the main window is similar. Main window class : WindowsForms10.Window.8.app.0.365bd83_r18_ad1 Desired window class : WindowsForms10.Window.808.app.0.365bd83_r18_ad1 So maybe I can dynimcally pull the class of a window similar to how WinGetHandle works. Maybe WinGetClassList? But I haven't investigate that yet. 3) If it is a window like it seems to maybe be, and if possible to get a list of windows, I should be able to get a list of windows before clicking the button, then get the list again and select the new one. Is that possible. 4) Worst case, I get position of control and MouseClick with a small y offset.
BryanWall Posted December 14, 2023 Author Posted December 14, 2023 (edited) For potential solution 2), I ended up with the below code and so far it works. My assumptions are that the only changes are that the 8 becomes 808, based on the two cases I've seen so far, that that number is always an 8, and that the second class is always one of the windows. I'll replace those assumptions with dynamically finding as needed with testing. Worst case scenario I will change the stringReplace to either a slip and find and change the element right after "window" or look into Regex and avoid the extra lines of code. WinActivate("Find Base Stations") $temp = StringSplit(WinGetClassList("Find Base Stations"),@LF) $SubwindowClass = "[CLASS:" & StringReplace($temp[2],".8.",".808.") & "]" ControlClick("Find Base Stations","","[NAME:sbtSmartSelect]") sleep(100) WinActivate($SubwindowClass) sleep(100) send("{down}") Any posts for the feasibility on the other solutions would be appreciated in case what worked this time doesn't work for other cases. Edited December 14, 2023 by BryanWall
argumentum Posted December 14, 2023 Posted December 14, 2023 here Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
ioa747 Posted December 15, 2023 Posted December 15, 2023 (edited) 210720-how-can-i-future-proof-my-code-so-changes-to-windows-handlesids-dont-require-new-edits 210779-controlgethandle-not-matching-on-regex Edited December 15, 2023 by ioa747 I know that I know nothing
junkew Posted December 17, 2023 Posted December 17, 2023 (edited) Use winlist to see which window comes new. With uiautomation you can catch new window events. More complex but there are excellent examples in the forum. To determine more from your popupped menu you could use mousemove to hover over it and then get window from position where mouse is. Try simplespy as described in iuiautomation see links below my signature. Edited December 17, 2023 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
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