Jump to content
Sign in to follow this  
thepaulguy

Simple Window Closing Madness

Recommended Posts

thepaulguy

I am having some issues with what should be the simplest of scripts. I have a program that records internet tv. If the network drops for some reason, an error window pops up and it will not record anything that is scheduled from that point on until the error is closed. So if this occurs at night when I am sleeping, I could miss recording several tv shows. So here is what I have done.

The error windows do not have a title so I am using the window text and WinGetHandle to close.

Like this...

while 1
sleep(100)
if WinExists("","ネットワークに接続できません。") then
$handle = WinGetHandle("","ネットワークに接続できません。")
WinClose($handle)
;MsgBox(0, "WinGetHandle Result",$handle)
EndIf
Wend

I have tested this out by manually creating the error window using this and the above script will close the window fine.

MsgBox(0, "","ネットワークに接続できません。")

When I force the program to throw the error by disconnecting my network cable, the error window comes up but never closes. I added the WinGetHandle Result msgbox to see if it was even detecting the window. It does display the proper handle, I confirmed it by using the AutoIt Window Info tool.

I even tried this but it doesn't work either.....

while 1
sleep(100)
if WinExists("","ネットワークに接続できません。") then
$handle = WinGetHandle("","ネットワークに接続できません。")
WinActivate($handle)
Send("{ESC}")
;MsgBox(0, "WinGetHandle Result",$handle)
EndIf
Wend

Any suggestions?

Share this post


Link to post
Share on other sites
mihaibr

Are you sure that the handle is ok?

look at WinTitleMatchMode

Can you take a picture of that "Error"?

if is MsgBox(0, "","ネットワークに接続できません。"

why dont you send "Enter" ? (or press the OK button)

If that windows have the same handle everytime why don't you use WinClose(the handle value) ?

Edited by mihaibr

Share this post


Link to post
Share on other sites
thepaulguy

Any of the following should work after WinActivate but they don't. The window is made active but the Send is not causing it to close.

Send("{ENTER}")
Send("{ESC}")
Send("{SPACE}")

Also, the handle will never be the same. That's why I am using WinGetHandle. I've tried

WinClose($handle)

or

WinKill($handle)

I can't get anything to close it. Any more suggestions?

Edited by thepaulguy

Share this post


Link to post
Share on other sites
thepaulguy

I was one step ahead of you. lol I was trying that just now. This is crazy!

When testing using a Msgbox...

The script Activates the window, moves the mouse to the correct spot above the OK button and it left click's it. Works like expected.

When I force the error to popup using the program in question, the script activates the popup, moves the mouse to the correct position above the OK button, then nothing happens!

This makes no sense.

I'll try the ControlClick() next I guess.

Share this post


Link to post
Share on other sites
thepaulguy

WOW! This doesn't work either. Same results as all the others.

ControlClick("","ネットワークに接続できません。", "[CLASS:Button; ID:2; TEXT:OK; INSTANCE:1]")

Share this post


Link to post
Share on other sites
mihaibr

Are you sure that the button status is Active?

Maybe that application got some kind of protection.

Share this post


Link to post
Share on other sites
thepaulguy

Could the programmer of that program have done something to prevent this from working?

Share this post


Link to post
Share on other sites
thepaulguy

Are you sure that the button status is Active?

Maybe that application got some kind of protection.

Do you mean the window status is active?

Share this post


Link to post
Share on other sites
mihaibr

First, stop double posting, use the "Edit" button.

I was talking about the button status.

Can you post an screenshot of that application and the Error ?

Edited by mihaibr

Share this post


Link to post
Share on other sites
thepaulguy

First, there is no need to be pompous.

Second, I don't know what you are talking about. I did not double post anything.

Third, I do not need someone getting self righteous with me about what they perceive to be proper forum etiquette.

Thank you for your assistance mihaibr, but you may move along.

If anyone else has any suggestions I would love to hear from them.

Share this post


Link to post
Share on other sites
Mat

Get a simple mouse recorder, like this one or tasker if you have that. Record yourself clicking the button, then see if it works when playing back the macro. If so then a simple hack would be to find some way to execute that macro from AutoIt. Not pretty, but if its just something to run overnight then it will be sufficient.

Generally those tasker-like programs use a different approach to AutoIt in order to more directly mimic what the user was doing. AutoIt skips a step and allows you to do what you wanted to do, which is better in most cases, but not the same.

  • Like 1

Share this post


Link to post
Share on other sites
thepaulguy

TinyTask is a cool little program but the same thing happened. Mouse moves to the OK button but the mouse click doesn't close the error. <Sigh>

Well, I am throwing the towel in on this. I wish the program I am having an issue with was something I could let you guys run and see if you could get it to work but it requires a paid subscription to log into it. I appreciate all the suggestions.

Share this post


Link to post
Share on other sites
kaotkbliss

Just a thought and it's just a guess...

maybe the winactivate isn't really activating the window fully.

Have you tried 2 clicks with your script? Move mouse into position and click, wait a second and click again


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • MFrancisca
      By MFrancisca
      OK, after days looking at my code, the help file and forums I come (again) for help on message windows.
      I'm having trouble trying to close window messages that appear. This is the code I'm using
      #include <MsgBoxConstants.au3> Local $obs_handler = 0 Opt("WinTitleMatchMode",2) While 1 $obs_handler = WinWait("C:\Users\", "", 1) If IsHWnd($obs_handler) then MsgBox($MB_OK, "Message", "handler: "&$obs_handler, 1) ;Sleep(100) $obs_handler = HWND($obs_handler) WinKill($obs_handler, "") ;<<<<< PROBLEM!!!!! Else MsgBox($MB_OK, "Message", "No handler", 1) EndIf Send("{ESC}") Sleep(2000) $obs_handler = 0 WEnd The problem is on the Winkill command, it won't just close the window! 
      Winwait is capturing the handler, it checks as handler. Ii'm using the HWND() command just to be sure it is the correct variable type.  I've also checked the message box info with the autoit window info tool and the handle value matches the one captured by the code. 
      I've tried winkill, winclose, using wingethandle, moving the winkill command to Before the message box so it is not converted to a string, and now using the hwnd function to force the variable type of the handler. The use of the sleep command does not make any diference.
      As a side quest, I'd like to use classes to capture the windows instead of titles, just to keep things cleaner, but using the [CLASS:...] value for winwait is not working. I have the class name and number, am I missing something? 
       
      Thanks! 
    • ternal
      By ternal
      Hi,
      The FAQ proposed as a solution to keys getting stuck  to do this command
      ControlSend("", "", "", "text", 0) However this sends "text" to the last active control if I am not mistaken.I have tried this with
      controlsend("", "", "", "{altup}{shiftup}{ctrlup}", 0) This is already a lot better but still fails 1/10
      I cannot allow the script to send "text" to the last active control, and its a bit silly to let it send to somewhere where its harmless no?
      Are there any other methods of unstucking keys?
    • Fortitude
      By Fortitude
      Hello!
      I have made a program, that opens a folder, and then store the path ("C:\programFiles\etc") in a variable.
      Then i need to open the command panel as administrator, and write  in the stored path, and some other text.

      Can i somehow instantly copypaste the text i needed, instead of writing in the command panel with the Send commands?
       
      #RequireAdmin #include <MsgBoxConstants.au3> Global Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Global $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "Nem választottál ki mappát!") Exit EndIf Global $Tiff_path = $sFileSelectFolder & "\TiffChecker_2_32" FileCopy( "C:\TiffChecker_2_32.exe" , $sFileSelectFolder) $CMD = $Tiff_path & " " & $sFileSelectFolder & " /s/d" Run("C:\WINDOWS\system32\cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send($CMD) Sleep(1000) Send("{ENTER}") sleep(1000) MsgBox(0,"Press OK", "Press OK to continue") FileCopy("C:\Tiffchecker.txt", $sFileSelectFolder) Also, how do i close the command panel, when the program is finished? (usually its under 1 second, so after the send i just put a Sleep function there)
    • Docfxit
      By Docfxit
      I would like to know if there is a way to make the send cmd send characters when using
      Graphical AutoIt Debugger By Stumpii,
      If Not WinActive("Setup - UltraVNC","Setup is preparing to install") Then WinActivate("Setup - UltraVNC","Setup is preparing to install") WinWaitActive("Setup - UltraVNC","Setup is preparing to install") Send("{ALTDOWN}f{ALTUP}") ;Finish The debugger when using step mode will execute the Send cmd line but the window doesn't receive the input.
      Thanks,
      Docfxit
    • PoojaKrishna
      By PoojaKrishna
      Hi friends,
      I'm trying to send SHIFTDOWN, to keep the Shift key pressed until I close the program or releases the key.
      Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is down. Type something: ") $ret = Msgbox(0,"", "Press and release shift key manually and select [Ok] to continue") $text = InputBox("Shift key up", "Shift key is released manually, now type something: ") Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down Agin", "Shift key is pressed again, now type something: ") In the above program sequence,
      1. Send SHIFTDOWN from program, Works as we type in the text are in Capital letters
      2. Manually presses and releases the SHIFT button. SHIFT key is released as when we type, text is in small letters only.
      3. Again send SHIFTDOWN from program, but not working. When we type the letters are in small letters.
       
      If we send a SHIFTUP  before  sending the SHIFTDOWN again, then it is working correctly and the text appears in capital letters only. Can any one explain why this happens?
      Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is down. Type something: ") $ret = Msgbox(0,"", "Press and release shift key and select [Ok] to continue") $text = InputBox("Shift key up", "Shift key is released manually, now type something: ") Send ( "{SHIFTUP}") sleep(100) Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is pressed, now type something: ")  
      Thank you.
×