cag8f Posted September 4, 2023 Share Posted September 4, 2023 Hi all. I'm having issues understanding a regular expression when used with ControlGetHandle. If I call ControlGetHandle and pass it a string value for the third parameter, it returns a valid ID (0x00150BE8). But if I change that parameter from a string to a regular expression that I think should match, the function returns an invalid ID and an error code 1. What am I misunderstanding? My code is below. $cWnd = WinWait("ShareX - Color picker", "", 3) ControlClick($cWnd, '', ControlGetHandle($cWnd, "", 'WindowsForms10.BUTTON.app.0.1a52015_r6_ad14')) ControlGetHandle($cWnd, "", 'WindowsForms10.BUTTON.app.0.1a52015_r6_ad142'); Returns: 0x00150BE8 ;~ ControlGetHandle($cWnd, "", '[REGEXPCLASS:^WindowsForms10\.BUTTON\.app\.0\.1a52015_r6_ad142$]'); Returns: 0x00000000 (error code 1) Link to comment Share on other sites More sharing options...
Solution ioa747 Posted September 4, 2023 Solution Share Posted September 4, 2023 (edited) couldn't find which button that is the WindowsForms10.BUTTON.app.0.1a52015_r6_ad142 but i made an example with the button pick color from screen $hWnd = WinWait("ShareX - Color picker", "", 3) ConsoleWrite("$hWnd=" & $hWnd & @CRLF) ;pick color from screen $hPickColorFromScreen = ControlGetHandle($hWnd, "", '[REGEXPCLASS:WindowsForms10\.BUTTON\.app\.0\..+_r\d+_ad1; INSTANCE:36]') ConsoleWrite("$hPickColorFromScreen=" & $hPickColorFromScreen & @CRLF) ControlClick($hWnd, '', $hPickColorFromScreen) ControlGetHandle($hWnd, "", "[REGEXPCLASS:<>; INSTANCE:<>]") Edited September 4, 2023 by ioa747 cag8f 1 I know that I know nothing Link to comment Share on other sites More sharing options...
Nine Posted September 4, 2023 Share Posted September 4, 2023 REGEXPCLASS uses CLASS not CLASSNN ! See @ioa747 example. cag8f 1 “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...
cag8f Posted September 10, 2023 Author Share Posted September 10, 2023 @ioa747 @Nine Thanks for that. Using CLASS instead of CLASSNAMENN, and adding the INSTANCE, resolved my issue. Thanks very much. But what about the value for instance? In my case it is `42` which I've hardcoded. What if that changes in the future? Can I use a regex pattern to match on it in my code? Or maybe it is something that shouldn't change very often? Link to comment Share on other sites More sharing options...
Nine Posted September 10, 2023 Share Posted September 10, 2023 If you do not need the instance, just drop it. It is not necessary to add INSTANCE with regex pattern. “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...
cag8f Posted September 10, 2023 Author Share Posted September 10, 2023 It looks like I need to add the INSTANCE in this case. If I remove it, ControlGetHandle still returns the correct handle ID. But the click from ControlClick doesn't seem to occur 😕 Link to comment Share on other sites More sharing options...
ioa747 Posted September 10, 2023 Share Posted September 10, 2023 (edited) @Nine how can catch with regex pattern, e.g. one click on the control 0x001D0E6A WindowsForms10.BUTTON.app.0.1a52015 _r22_ad1 20 1904234 so as not to catch any of the rest, without the use of INSTANCE ? $hWnd = WinWait("ShareX - Color picker", "", 3) ConsoleWrite("$hWnd=" & $hWnd & @CRLF) ;pick color from screen WindowsForms10.BUTTON.app.0.1a52015 _r22_ad1 $hPickColorFromScreen = ControlGetHandle($hWnd, "", '[REGEXPCLASS:WindowsForms10\.BUTTON\.app\.0\..+_r\d+_ad1; INSTANCE:20]') ConsoleWrite("$hPickColorFromScreen=" & $hPickColorFromScreen & @CRLF) ControlClick($hWnd, '', $hPickColorFromScreen) Edit: or this is a need case ? Edited September 10, 2023 by ioa747 cag8f 1 I know that I know nothing Link to comment Share on other sites More sharing options...
Nine Posted September 21, 2023 Share Posted September 21, 2023 On 9/10/2023 at 9:40 AM, ioa747 said: or this is a need case ? yes it is. ps. sorry for late reply, was out of town without access to internet... cag8f 1 “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...
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