MaxU77 Posted March 1, 2011 Share Posted March 1, 2011 I'm having problems with referencing window with variable Title and Class in my script.The window I want to interact with is the main window of application.As far as application could be in the state when document is open it's title could be something more then just name of app.Window Class is every time new - it is almost same but last 6 characters are different when app is restarted and looks like:Afx:0000000140000000:8:0000000000010005:0000000000000000:0000000000XXXXXXI guess I should use regular expression, but not sure.Any ideas how to reference windows like this?Tanks in advance. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 1, 2011 Moderators Share Posted March 1, 2011 MaxU77,You could use "[REGEXPCLASS:]" instead of "Title" to identify the window. In your case I would try:("[REGEXPCLASS:Afx:0000000140000000:8:0000000000010005:0000000000000000:0000000000.{4}]")Let us know how you get on. 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...
MaxU77 Posted March 1, 2011 Author Share Posted March 1, 2011 MaxU77, You could use "[REGEXPCLASS:]" instead of "Title" to identify the window. In your case I would try: ("[REGEXPCLASS:Afx:0000000140000000:8:0000000000010005:0000000000000000:0000000000.{4}]") Let us know how you get on. M23 Thanks a lot. I can't say I clearly understand why ".{4}" makes sence, but it works. Could you, please, comment why 4? Anyway my script now has another issue. Before trying to switch to REGEX script contained lines: $WinPos = WinGetPos("[CLASS:Afx:0000000140000000:8:0000000000010005:0000000000000000:0000000000150589]","") MsgBox(0, "Window Stats:", "POS: " & $WinPos[0] & "," & $WinPos[1] & "SIZE: " & $WinPos[2] & "," & $WinPos[3] ) and there was a message Now lines: $WinPos = WinGetPos("[REGEXPCCLASS:Afx:0000000140000000:8:0000000000010005:0000000000000000:0000000000.{4}]","") MsgBox(0, "Window Stats:", "POS: " & $WinPos[0] & "," & $WinPos[1] & "SIZE: " & $WinPos[2] & "," & $WinPos[3] ) Return error "Subscript used with non-Array variable." Could you, please, give some hint on how to debug this? Thank in advance. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 1, 2011 Moderators Share Posted March 1, 2011 (edited) MaxU77,A whole tutorial on SREs is a bit much to ask! Suffice to say that .{4} means exactly 4 characters of any sort. You can find a lot more about SRE syntax in the Help file under StringRegExp - and that page is just touching the surface of the wide and wacky world of SREs. As to the error, it means just what it says - $WinPos is not an array. This is undoubtedly because the window you are using did not exist when you called the function. You need to add some error checking to confirm that you have an array in the variable before trying to address it. All clear. M23Edit: Looking more carefully at your first post I now see 6 Xs - so perhaps you could try using .{6} instead. Edited March 1, 2011 by Melba23 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...
MaxU77 Posted March 1, 2011 Author Share Posted March 1, 2011 MaxU77, As to the error, it means just what it says - $WinPos is not an array. This is undoubtedly because the window you are using did not exist when you called the function. You need to add some error checking to confirm that you have an array in the variable before trying to address it. All clear. M23 Edit: Looking more carefully at your first post I now see 6 Xs - so perhaps you could try using .{6} instead. Indeed when I reported that it works I was judjing by WinActivate ("[REGEXPCLASS:Afx:0000000140000000:8:0000000000010005:0000000000000000:0000000000.{4}]") But in fact that line works for all from .{1} to .{6} Im right now browse help subclause you are referencing. Any single character repeated {x} times is now clear for me. I swear without your hint I would never understand the syntax (One more thanks). But I still dont understand how using REGEX (the only change) spoiled that variable array. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 1, 2011 Moderators Share Posted March 1, 2011 MaxU77, in fact that line works for all from .{1} to .{6}Which of course it will as it matches with 1-6 additional characters - it just ignores those that are left over. As to your problem, I do not think it is the REGEX that is the problem - if it activates the GUI it can certainly find it to get its position. Normally WinGetPos fails because the GUI does not exist - are you sure that it does when you call the function? I would also suggest using the GUI handle rather than the REGEX once the window is created. Use: $hGUI = WinGetHandle(("[REGEXPCLASS:Afx:0000000140000000:8:0000000000010005:0000000000000000:0000000000.{6}]") to get the handle and then use that in other cases where you want to identify that particulr window - like this: WinGetPos($hWin) Saves a lot of wear and tear on the typing fingers. 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...
MaxU77 Posted March 1, 2011 Author Share Posted March 1, 2011 (edited) Wow! WinActivate ("[REGEXPCLASS:Afx:0000000140000000:8:0000000000010005:0000000000000000:0000000000]") works as well (who could think) thus I need no count those character just trim works fine Thanks for advice regarding handle I'll try it. Error is solved - there was a misprint. doulble C. That was wery kind of you to help me. Edited March 1, 2011 by MaxU77 Link to comment Share on other sites More sharing options...
MaxU77 Posted March 1, 2011 Author Share Posted March 1, 2011 (edited) Excuse me, Just couple more tiny-little questions: 1. Regarding REGEXP: Could REGEXP be used alike leading wildcard? You know "*book" to find all of: Ebook Notebook Facebook etc. ? 2. If my script interacts with window control which is drop-down list of options..does that mean there is no way to do it on locked workstation? Edited March 1, 2011 by MaxU77 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 1, 2011 Moderators Share Posted March 1, 2011 (edited) MaxU77,You really want that tutorial! The short answer is "Yes".The longer answer is - look at this website and get ready for a very long journey. As I have often said, SREs are the hardest thing I have ever tried to learn in computing terms (they make my brain bleed sometimes), but also among the most useful. Good luck! M23Edit: Sneaky edit on your part there! Search on the forum for "+locked +workstation" topics - I seem to remember that the answer is that you cannot do anything, but I am not altogether sure. Edited March 1, 2011 by Melba23 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...
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