tantrim Posted November 6, 2022 Share Posted November 6, 2022 (edited) I'm attempting to find either of 2 different windows via regex and WinList(). The first window I would like to get by REGEXPTITLE, the 2nd by REGEXPCLASS. Alone both statements work. I'm required to use Title and Class in some scenario's so that is the solution I'm looking for. Sometimes one window requires a Title search and another requires a Class search, but I'd like them to be in the same WinList object. Below is how I would like to accomplish it. But the syntax isn't valid to my knowledge ; OR statement doesn't work. Local $regex = "[REGEXPTITLE:(?i)(.* — Mozilla Firefox)|REGEXPCLASS:(?i)(SunAwtFrame)]" Local $winList = WinList($regex) Other solutions that come with inherent flaws. ; other possible solutions ; Join 2 lists - doesn't retain history accurately local $winListOne = WinList("[REGEXPTITLE:(?i)(.* — Mozilla Firefox)]") Local $winListTwo = WinList("[REGEXPCLASS:(?i)(SunAwtFrame)]") ; TODO - add count together to first array and remove count row from 2nd array. Join both arrays ; Returns over 200 windows $windows = WinList() For $i = 1 To $windows[0][0] If StringRegExp($windows[$i][0], "[REGEXPTITLE:(?i)(.* — Mozilla Firefox)]") = 1 Then MsgBox(0,0,$windows[$i][0]) EndIf Next ; Correctly returns titles with Mozilla, but could return undesirable windows ; MAIN ISSUE is I'm unsure how to use CLASS regex with this method $windows = WinList() For $i = 1 To $windows[0][0] If StringRegExp($windows[$i][0], "(.* — Mozilla Firefox)") = 1 Then MsgBox(0,0,$windows[$i][0]) EndIf Next Another questions, how does REGEXPCLASS work on WinList() whenever it only returns a Title and Handle column? Similar Thread: using winlist to create array with multiple titles Edited November 6, 2022 by tantrim Link to comment Share on other sites More sharing options...
Nine Posted November 6, 2022 Share Posted November 6, 2022 (edited) Maybe this ? #include <Array.au3> Local $aWinList = WinList("[REGEXPTITLE:(?i)(.*Google Chrome.*)]") _ArrayDisplay($aWinList) Local $aTemp = WinList("[CLASS:Chrome_WidgetWin_1]") _ArrayDisplay($aTemp) _ArrayConcatenate($aWinList, $aTemp, 1) $aWinList = _ArrayUnique($aWinList, 0, 1, 1, $ARRAYUNIQUE_COUNT) _ArrayDisplay($aWinList) Edit : you do not need to use REGEXPCLASS if you search for a specific class Edited November 6, 2022 by Nine “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...
tantrim Posted November 6, 2022 Author Share Posted November 6, 2022 (edited) 31 minutes ago, Nine said: Maybe this ? #include <Array.au3> Local $aWinList = WinList("[REGEXPTITLE:(?i)(.*Google Chrome.*)]") _ArrayDisplay($aWinList) Local $aTemp = WinList("[CLASS:Chrome_WidgetWin_1]") _ArrayDisplay($aTemp) _ArrayConcatenate($aWinList, $aTemp, 1) $aWinList = _ArrayUnique($aWinList, 0, 1, 1, $ARRAYUNIQUE_COUNT) _ArrayDisplay($aWinList) Edit : you do not need to use REGEXPCLASS if you search for a specific class 1. Thanks for the reply and help. 2. CLASS should suffice then. 3. The solution is close, but it doesn't retain the Order Active/Focused History that a single WinList() will. The order active/focused history is important for me as I want traverse through past used applications and would like to go in order of history Edited November 6, 2022 by tantrim Link to comment Share on other sites More sharing options...
Nine Posted November 6, 2022 Share Posted November 6, 2022 (edited) I don't understand Order History. Edited November 6, 2022 by Nine “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...
tantrim Posted November 6, 2022 Author Share Posted November 6, 2022 (edited) bad terminology on my part, sorry. The list is built in the order the windows were last active. The more recent the window was active/focused, the lower the index.WinList() acts in the same way as your browser does with "go forward one page" and "go backwards one page". - Confusing Edited November 6, 2022 by tantrim Link to comment Share on other sites More sharing options...
Nine Posted November 6, 2022 Share Posted November 6, 2022 If I understand you correctly, you would like to have the list of all instances of your browser in the order of their creation (date/time start of the instance), right ? “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...
tantrim Posted November 6, 2022 Author Share Posted November 6, 2022 (edited) Not the creation time, it's active/focused order. in order of date/time since the window was last active Edited November 6, 2022 by tantrim Link to comment Share on other sites More sharing options...
tantrim Posted November 6, 2022 Author Share Posted November 6, 2022 if the results of WinList() stored the CLASS information of the windows this would be possible iterating through a For loop. Link to comment Share on other sites More sharing options...
Nine Posted November 6, 2022 Share Posted November 6, 2022 Sorry I am not following you at all. The CLASS information is always the same, how would it be useful ? Why do need to search by class and by title, is only one of them enough since you are looking at the exact same windows ? WinList always give you in order of last active, isn't that what you want ? “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...
tantrim Posted November 6, 2022 Author Share Posted November 6, 2022 (edited) I use 2 IDE's. Rider and Visual Studio. Visual Studio Window Info: Rider Window Info: I want to target Rider with it's Class, and Visual Studio with it's title. I want to put all of my IDE's in the same WinList() so I can iterate through the list and Activate my IDE's 1 by 1 until I arrive at the IDE I want active. The history is important to me because I don't want to open up an IDE I haven't opened recently as my first item. ; Join 2 lists - doesn't retain history accurately local $winListOne = WinList("[REGEXPTITLE:(?i)(.*- Microsoft Visual Studio)]") Local $winListTwo = WinList("[REGEXPCLASS:(?i)(SunAwtFrame)]") ; TODO - add count together to first array and remove count row from 2nd array. Join both arrays ; MAIN ISSUE is I'm unsure how to use CLASS regex with this method $windows = WinList() ; $windows object no longer contains class data (to my knowledge) so this doesn't work for class search For $i = 1 To $windows[0][0] If StringRegExp($windows[$i][0], "CLASS:SunAwtFrame") = 1 Then MsgBox(0,0,$windows[$i][0]) EndIf Next EDIT: okay so after rereading what you said about WinList always have the class info I didn't really understand. The for loop statement checks the Title value and not the handle. Upon further research I see that _WinAPI_GetClassName exists and I might be able to get the class from the handle this way. Edited November 6, 2022 by tantrim Link to comment Share on other sites More sharing options...
Solution tantrim Posted November 6, 2022 Author Solution Share Posted November 6, 2022 (edited) So I think I figured it out. Thanks for your help @Nine. I would of preferred one line regex expression so I don't have to rework my other code but I can't think of a way. Local $newWinList[1][2] $windows = WinList() For $i = 1 To $windows[0][0] $class = _WinAPI_GetClassName($windows[$i][1]) $title = $windows[$i][0] If StringRegExp($class, "SunAwtFrame") = 1 Or StringRegExp($title, "- Microsoft Visual Studio") = 1 Then $newWinList[0][0] += 1 _ArrayAdd($newWinList, $windows[$i][0] & "|" & $windows[$i][1]) EndIf Next When pulling the handle from the list it is stored as a string. If you want to reuse the handle make sure to cast it into an HWnd object like below $hWndString = $newWinList[1][1] $hWnd = HWnd($hWndString) WinActivate($hWnd) Edited November 6, 2022 by tantrim 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