Bagel Posted November 26, 2018 Share Posted November 26, 2018 (edited) This should be easy enough but I haven't been able to find the answer searching on my own. What I want to do is something like this: #include <WinAPISysWin.au3> #include <Array.au3> $aWin = WinList("[TITLE:TEXT 1; TITLE:TEXT 2]") This returns $aWin with the window that has title TEXT 2 but excludes the first one. I need both. I'm trying here to follow the example located athttps://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm Edited November 26, 2018 by Bagel Link to comment Share on other sites More sharing options...
mikell Posted November 26, 2018 Share Posted November 26, 2018 Try this WinList("[REGEXPTITLE:(?i)(.*text 1.*|.*text 2.*)]") FrancescoDiMuro 1 Link to comment Share on other sites More sharing options...
Bagel Posted November 27, 2018 Author Share Posted November 27, 2018 No bueno. I can get a REGEX expression to work like that by itself but what I really need is to combine it with another condition like so: #include <WinAPISysWin.au3> #include <Array.au3> $aWin = WinList("[REGEXPCLASS:(?i)(.*WindowsForms10.Window.8.app.0.1ca0192_r6_ad1.*|.*AfxFrameOrView42d.*); REGEXPTITLE:(?i)(.*text 1.*|.*text 2.*)]") Which fails as before by returning an empty array. I just used the simplest case first as I suspected the full line wouldn't work either. There has to be a way to do this. I refuse to believe that it's impossible to have more than one condition in WinList. As far as I can tell I'm following the example in the documentation exactly. Either I'm making a mistake there, or the documentation is incorrect/outdated, or there is something seriously broken here. I can't be the only person who's ever wanted to do this. Thanks for the input though. Link to comment Share on other sites More sharing options...
TheXman Posted November 27, 2018 Share Posted November 27, 2018 (edited) You are aware that WinList() without any parameters will pass back an array of all top-level windows, correct? Why don't you do that and then spin through the array looking for the windows of interest? Or better yet, use WinList() using REGEXPCLASS and then you just have to spin thru the arrary to find the titles that you want. Edited November 27, 2018 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Aether Posted November 27, 2018 Share Posted November 27, 2018 But running thru a whole array of titles is so exhausting ! So this is the reason why help is needed. Link to comment Share on other sites More sharing options...
Bagel Posted November 27, 2018 Author Share Posted November 27, 2018 Well, the idea was to use the innate functionality of WinList to avoid having to invent a massive Rube-Goldberg-esque pile of code to achieve an extremely simple task and in the process improve efficiency, reduce the complexity of the script and the number of function calls I have to make. So I was just looking for the most direct approach. If the way I'm trying to do it is impossible then the documentation seriously needs to be revamped to remove any reference to this non-existent functionality. I can only imagine how much time and energy has been wasted by people attempting the implementation found there. I suppose that I could use two separate WinList calls, one for each condition, then try to append one array to the other. Of course, then I will have to cycle through the elements of the array and try to remove some windows while retaining the others based upon other criteria... This is highly undesirable though as any excessive operations with arrays is very time consuming and I'm very concerned with the performance of this script. Link to comment Share on other sites More sharing options...
careca Posted November 27, 2018 Share Posted November 27, 2018 On 11/26/2018 at 1:42 AM, Bagel said: This returns $aWin with the window that has title TEXT 2 but excludes the first one. I confirm this, help file says it should work, possible bug? Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
mikell Posted November 27, 2018 Share Posted November 27, 2018 Bagel, Your previous code should return windows matching both conditions, as the semicolon in there means and (not or ) as clearly specified in the helpfile pixelsearch 1 Link to comment Share on other sites More sharing options...
careca Posted November 27, 2018 Share Posted November 27, 2018 Quote e.g. Wait for the 2nd instance of a window with title "My Window" and classname "My Class" WinWaitActive("[TITLE:My Window; CLASS:My Class; INSTANCE:2]", "") It does say that here, i missed it, not mentioned clearly enough for me. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
pixelsearch Posted November 27, 2018 Share Posted November 27, 2018 (edited) Hi all I just did a test after creating 4 files : * 2 files created with Notepad, named aaaaa.txt and bbbbb.txt * 1 file with Excel, named aaaaa.xls * 1 file with Wordpad, named bbbbb.rtf Then I run this script, while 4 files are opened : #include <Array.au3> Opt("WinTitleMatchMode", -2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase ; $aWin = WinList("[REGEXPTITLE:(?i)(.*aaaaa.*|.*bbbbb.*)]") ; _ArrayDisplay($aWin, "REGEXPTITLE only") $aWin = WinList("[REGEXPTITLE:(?i)(.*aaaaa.*|.*bbbbb.*); REGEXPCLASS:(?i)(Notepad|WordPadClass)]") _ArrayDisplay($aWin, "REGEXPTITLE ; REGEXPCLASS") Here are the results, depending on the uncommented WinList() line : So everything seems to work fine : the excel file is eliminated from the 2nd list as soon as the REGEXPCLASS clause appears. Edited November 27, 2018 by pixelsearch dot star not needed in RegexpClass (in this script) Link to comment Share on other sites More sharing options...
Bagel Posted November 30, 2018 Author Share Posted November 30, 2018 Okay, I now understand what is going on. The semicolon instructs the function to return matches (in my use case) for windows that have at least one of the classes in my REGEX expression while simultaneously possessing one of the titles in the other REGEX expression. Once I understood that I was able to expand both expressions to get the results that I want. I've also been able to eliminate the need to do any further processing on the array to eliminate windows that were being picked up previously. Thanks for the input! 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