Queener Posted July 21, 2013 Share Posted July 21, 2013 I notice that you can check and see if window exist, but how do you put a permanent check to see if the window close? If it close then re-open. Say for example, I use teamviewer and once in awhile it closes the connection on me if I'm idle for certain amount of time. I want it to automatic open a new session with the id and pw I provided if teamviewer close. Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
FireFox Posted July 21, 2013 Share Posted July 21, 2013 Hi,If the program re-creates a window each time, then you only need to check for its handle.Local $hWnd = WinGetHandle("My Wnd") While WinExists($hWnd) = 1 Sleep(10) WEnd ConsoleWrite("Window closed." & @CrLf)If NOT, then you will need to check for the window's state (using WinGetState).Br, FireFox. Link to comment Share on other sites More sharing options...
czardas Posted July 21, 2013 Share Posted July 21, 2013 (edited) Based on Firefox's example above, This script keeps opening notepad every time you close it, until you hit the escape key. It might help you get started. ; HotKeySet("{ESC}", "_Quit") Local $hWnd While 1 Run ("Notepad.exe") WinWait("Untitled - Notepad") $hWnd = WinGetHandle("Untitled - Notepad") While WinExists($hWnd) Sleep(10) WEnd ;ConsoleWrite("Window closed." & @CrLf) WEnd Func _Quit() Exit EndFunc Edited July 21, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Queener Posted July 21, 2013 Author Share Posted July 21, 2013 thanks firefox and czardas. Will give czardas example a try. Looks very like a very good example I can start off. Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Queener Posted July 22, 2013 Author Share Posted July 22, 2013 czardas - tested your code, but it doesn't open notepad when it's closed. I removed the ";" before consolewrite code, Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
FireFox Posted July 22, 2013 Share Posted July 22, 2013 Basic example : HotKeySet("{ESC}", "_Quit") While 1 Run("Notepad.exe") WinWait("[CLASS:Notepad]") WinWaitClose("[CLASS:Notepad]") WEnd Func _Quit() Exit EndFunc Link to comment Share on other sites More sharing options...
czardas Posted July 22, 2013 Share Posted July 22, 2013 (edited) czardas - tested your code, but it doesn't open notepad when it's closed. I removed the ";" before consolewrite code, Sorry. It worked on my machine. It was a quick example to which I didn't give much thought. Firefox's example is much better anyway. The method I used is taken from the helpfile tutorial, so I am now a little confused why it worked on my computer and not on yours. The helpfile tutorial gives this code: ; Run("notepad.exe") WinWaitActive("Untitled - Notepad") ; This is the syntax which fooled me Send("This is some text.") ; Please could someone confirm that my >earlier example is broken, because it works perfectly for me. Edit I think this has to do with language settings - and the helpfile may need amending. Edited July 22, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Queener Posted July 22, 2013 Author Share Posted July 22, 2013 (edited) can one of you guys compile that code to executable so I can try it out? The main problem atm is I switched from notepad to notepad++. But that shouldn't affect. nevermind; it works... Thanks guys Changed class to notepad++ and it worked. Edited July 22, 2013 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") 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