Jump to content

Simple Window Closing Madness


Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
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
 Share

×
×
  • Create New...