Edun Posted December 4, 2016 Share Posted December 4, 2016 (edited) Hello. It's me asking stupid questions once again : ) Now I'm kinda stuck with some really basic things. My script just loops and wait for existing windows and if the conditions are met, run function. Mainly it is as simple as this: While 1 If WinExists("Title","") AND WinExists("[CLASS:Notepad]") Then function() WEnd If I'm not mistaken, right now it checks separately if there is a window named Title and if there is a window of notepad class. How can I check if those conditions met for the same spesific window? I feel kinda stupid asking questions like these :facepalm: -Edun Edited December 4, 2016 by Edun Link to comment Share on other sites More sharing options...
l3ill Posted December 4, 2016 Share Posted December 4, 2016 (edited) Just remove the 'AND' and the second 'WinExists' and then have a look at the page in the help file that this link sends you to: Okay - I see, you want both conditions met for the same window... disregard. Edited December 4, 2016 by l3ill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
Edun Posted December 4, 2016 Author Share Posted December 4, 2016 18 minutes ago, l3ill said: Just remove the 'AND' and the second 'WinExists' and then have a look at the page in the help file that this link sends you to: Oh dear... Thank you. I've actually got pretty decent and well working script here and then I can't figure problem like this by myself. Shame on me. -Edun Link to comment Share on other sites More sharing options...
l3ill Posted December 4, 2016 Share Posted December 4, 2016 $sVar = "Test_Window - Notepad" $hWnd = WinGetHandle($sVar) If WinExists("[CLASS:Notepad]") And WinGetTitle($hWnd) = $sVar Then MsgBox(64, "", "it's there") EndIf Sevwren 1 My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
Edun Posted December 4, 2016 Author Share Posted December 4, 2016 15 minutes ago, l3ill said: $sVar = "Test_Window - Notepad" $hWnd = WinGetHandle($sVar) If WinExists("[CLASS:Notepad]") And WinGetTitle($hWnd) = $sVar Then MsgBox(64, "", "it's there") EndIf This was the first idea that came to my idea and I was actually able to figure it out by myself (Hurray!). Unfortunately this didn't fit too well for my script since it's repeatingly detecting multiply Windows so I had to find alternative method. Still thank you for the reply. -Edun Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 4, 2016 Moderators Share Posted December 4, 2016 Edun, When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - responders know what they wrote and it just pads the thread unnecessarily. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Malkey Posted December 4, 2016 Share Posted December 4, 2016 You could try this. HotKeySet("{ESC}", "Terminate") Run("NOTEPAD.EXE") Local $hWnd = WinWaitActive("[CLASS:Notepad]") WinSetTitle($hWnd, "", "My Window") ; <<< Change title to "My Window1" to not detect the NOTEPAD window. While 1 Sleep(100) If WinExists("[REGEXPTITLE:^My Window$;CLASS:Notepad]") Then MsgBox(0, "", "Window Exists") ; The regular expression pattern above (to match the title) is "^My Window$". Where "^" specifices the start of the title matching, ; and, "$" specifices the end of the title matching. WEnd Func Terminate() Exit EndFunc ;==>Terminate Link to comment Share on other sites More sharing options...
Edun Posted December 5, 2016 Author Share Posted December 5, 2016 Seems simple enough and you guys have been really helpful, but for some weird reason I'm still doing this wrong. So notepad isn't actually the program I'm using here. This is more like the information I use: Title: Window something here Class: WindowsForms10.Window.208.app.0.f7e717_r12_ad2 For the Class it can be exact match but I'd like to use it WindowsForms10* because after that it might changes at some point. But for name it should be a match only for the first word and random text after that. I've tried to make this work using TITLE, REGEXPTITLE and REGEXPCLASS and a lot of different variations of these. Shouldn't it be working with something as simple as this: Opt("WinTitleMatchMode", 1) If WinExists("[TITLE:Window;CLASS:WindowsForms10.Window.208.app.0.f7e717_r12_ad2]") Link to comment Share on other sites More sharing options...
Edun Posted December 5, 2016 Author Share Posted December 5, 2016 Okay I think I got it fixed, not sure how though since I've been struggling with this so much. Maybe it has something to do with WinTitleMatchmode and using REGEXPCLASS? Well I got a lot of helpful information here, thank you all. -Edun Link to comment Share on other sites More sharing options...
Malkey Posted December 5, 2016 Share Posted December 5, 2016 1 hour ago, Edun said: .... For the Class it can be exact match but I'd like to use it WindowsForms10* because after that it might changes at some point. .... It appears you are familiar with the wildcard character "*". in "WindowsForms10*" above. The Regular Expression (RE) equivalent is "WindowsForms10.*". Where "." represents any one character, and the "*" is a quantifiers that specifies the preceding character is matched zero to many times. Try If WinExists("[REGEXPTITLE:^Window.*;REGEXPCLASS:^WindowsForms10.*]") ; Title RE pattern, "^Window.*" means match the window title that starts with "Window" and is followed by either no characters or many characters. ; Class RE pattern, "^WindowsForms10.*" means match the window class that starts with "WindowsForms10" and is followed by either no characters or many characters. 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