Mbee Posted March 16, 2019 Share Posted March 16, 2019 So I'm making progress controlling the non-standard GUIs of Comodo Firewall (See thread: Updating question about manipulating non-standard GUIs) . It was tedious and annoying to get as far as I have, but now I'm at an impasse: After I MouseClick() a pseudo-button, I could get two different windows depending on an internal-to-Comodo state. How do I code my script to handle either? I'm guessing using AdLib functions, but I want to get a check from you folks on how to do it. Here's my plan: After clicking the button, I register two AdLib functions, one for each possible result. Each sets a global variable (must it be static, too?) to match which condition was met. Meanwhile, the main script waits for that global to have a non-zero value, whereupon it unregisters both AdLibs and continues the script. Does that seem right? I'm completely open to suggestions... As a side-note, because these GUIs are non-standard, I can't distinguish between the possible outcomes by the usual techniques, such as the existence of a specific class or control or different texts in the windows. The only thing that I've been able to find that's different is their window sizes, but that's enough -- unless I run into a case where both windows have exactly the same size, in which case I'm pretty sure I'm screwed. But I'll worry about that if it happens. Link to comment Share on other sites More sharing options...
Mbee Posted March 16, 2019 Author Share Posted March 16, 2019 I actually need more help: I want to wait until there's a window change, i.e., that a new window comes up on top of the others. Since I can't get the text or title or anything else, I can't use WinWait() or any of its variants! Is there something like "Wait till a new window opens on top" function or UDF that anyone knows of? Thanks! Link to comment Share on other sites More sharing options...
Nine Posted March 16, 2019 Share Posted March 16, 2019 Use the known handles of the windows, to compare to the current "[ACTIVE]" window... Mbee 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...
Mbee Posted March 16, 2019 Author Share Posted March 16, 2019 4 hours ago, Nine said: Use the known handles of the windows, to compare to the current "[ACTIVE]" window... Hey, thank you, @Nine! 😀 Just to be sure I understand, I would call WinGetHandle("[ACTIVE]", "") for the current window, then in my AdLib functions I keep calling that same function until it returns a different value, correct? Or would you recommend some other approach? Link to comment Share on other sites More sharing options...
Nine Posted March 16, 2019 Share Posted March 16, 2019 12 minutes ago, Mbee said: Hey, thank you, @Nine! 😀 Just to be sure I understand, I would call WinGetHandle("[ACTIVE]", "") for the current window, then in my AdLib functions I keep calling that same function until it returns a different value, correct? Or would you recommend some other approach? Hard to say without your code. But I suppose using AdLib is one solution. Depends if you are waiting for that window to appears, or is it appearing randomly... “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...
Mbee Posted March 16, 2019 Author Share Posted March 16, 2019 (edited) Well, what I have appears to work. Here's the relevant code snippet,,, How would you suggest I improve this? I'm completely open to advice/suggestions... ETA: Do those global static variables actually need to be static? NO! THAT'S NONSENSE! Give me a moment, please, to ix it... Edited March 16, 2019 by Mbee Completely WROMG Link to comment Share on other sites More sharing options...
Nine Posted March 16, 2019 Share Posted March 16, 2019 Here how I would do it (untested) : Local $GS_InitWinHdl = WinGetHandle("[ACTIVE]") ; Get the current ("Application Rules") Handle MouseClick( $MOUSE_CLICK_MAIN, 638, 168 ) ; Application Rules -> "Purge" Local $hTime = TimerInit () While WinGetHandle("[ACTIVE]") = $GS_InitWinHdl if TimerDiff($hTime) > 15 * 1000 then _MyUpdStatusMsg("Application Purge Timed Out") MsgBox($MB_OK, $GC_OurTitle, "FATAL: Application Purge Timed Out - Aborting") Exit -32 EndIf Sleep(200) Wend _MyUpdStatusMsg("Application Purge Button Wait Complete") Sleep( 1000 ) _MyUpdStatusMsg("Success - Exiting") MsgBox($MB_OK, $GC_OurTitle, "Success - Exiting") Exit 0 FYI : Global static are same as Global. It is usually used as Local Static. Use local (instead of global) as much as possible unless it is absolutely necessary. Mbee 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...
Mbee Posted March 16, 2019 Author Share Posted March 16, 2019 Thanks again. When I deleted my code and added "NO! THAT'S NONSENSE!", I had understood why using AdLib was pointless, as you indicated. What I coded and verified working is quite similar to what you posted above, all without AdLibs. I was always skeptical about defining those vars as Static (the code I saw using AdLibs declared them as Local Static), but even if Static was unnecessary, I thought some of them needed to be Global because of the AdLibs. Once I threw that flawed notion out, I could see that not even the Globals were needed. I very much appreciate your kind help! Link to comment Share on other sites More sharing options...
Nine Posted March 16, 2019 Share Posted March 16, 2019 1 minute ago, Mbee said: Thanks again. When I deleted my code and added "NO! THAT'S NONSENSE!", I had understood why using AdLib was pointless, as you indicated. What I coded and verified working is quite similar to what you posted above, all without AdLibs. I was always skeptical about defining those vars as Static (the code I saw using AdLibs declared them as Local Static), but even if Static was unnecessary, I thought some of them needed to be Global because of the AdLibs. Once I threw that flawed notion out, I could see that not even the Globals were needed. I very much appreciate your kind help! “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...
BrewManNH Posted March 16, 2019 Share Posted March 16, 2019 5 hours ago, Nine said: Use local (instead of global) as much as possible unless it is absolutely necessary. Except that in the code you posted, all of your variables are global. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Nine Posted March 16, 2019 Share Posted March 16, 2019 37 minutes ago, BrewManNH said: Except that in the code you posted, all of your variables are global. Except you don't understand that it is a snippet not a true program... “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...
BrewManNH Posted March 17, 2019 Share Posted March 17, 2019 Yes, I understand that, but you declared Global variables using the Local keyword. I assumed you didn't realize that using Local in a global scope is wrong, they're all Global regardless of what keyword you used to declare them. Hopefully by pointing it out to people that insist on misusing Local this way, it will eventually get through to the other people that visit the forum, that Local should only be used inside functions, anywhere else is a misuse of the declaration. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Nine Posted March 17, 2019 Share Posted March 17, 2019 39 minutes ago, BrewManNH said: I assumed you didn't realize that using Local in a global scope is wrong, they're all Global regardless of what keyword you used to declare them. You assume wrong. But if it is the best contribution you have to do in this thread, I suggest you go throw your boredom elsewhere... “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...
BrewManNH Posted March 17, 2019 Share Posted March 17, 2019 Lets just drop this one here, you're obviously taking things the wrong way and aren't particularly interested in not being an ass about it. Forgive my impudence in pointing out your ironic statement and misuse of the Local declaration. You're on your own from here on out, you're free to misuse the language in any way you'd like, I won't try and correct you. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Mbee Posted March 17, 2019 Author Share Posted March 17, 2019 21 hours ago, BrewManNH said: Lets just drop this one here, you're obviously taking things the wrong way and aren't particularly interested in not being an ass about it. Forgive my impudence in pointing out your ironic statement and misuse of the Local declaration. You're on your own from here on out, you're free to misuse the language in any way you'd like, I won't try and correct you. Respectfully sir, you can hardly blame friend @Nine for my mistake! In post 6, I had posted a snippet where all the same variables were declared Global -- in fact Global Static -- a very foolish mistake on MY part! Once I had realized how stupid that was, I went back and deleted the code snippet -- but not before @nine had copied it on his own system to examine it. So he did not declare those variables Global, I ignorantly did! Please, kind sir, direct your genuinely valuable corrective advice to He Who Screwed Up -- me! Thanks. Nine 1 Link to comment Share on other sites More sharing options...
BrewManNH Posted March 17, 2019 Share Posted March 17, 2019 14 minutes ago, Mbee said: Once I had realized how stupid that was, I went back and deleted the code snippet -- but not before @nine had copied it on his own system to examine it. So he did not declare those variables Global, I ignorantly did! Please, kind sir, direct your genuinely valuable corrective advice to He Who Screwed Up -- me! The only mistake you made was in the use of Global with Static, from what you're telling me. What he did was to change all of your correct Globals into incorrect Locals, which is what I pointed out to him. All of the variables in that snippet are global scoped, using Local with them is incorrect usage of the language. YOU didn't do anything other than use Static, you didn't screw up in declaring Global variables Global, you were correct. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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