Sign in to follow this  
Followers 0
thepaulguy

Simple Window Closing Madness

14 posts in this topic

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



#2 ·  Posted (edited)

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

#3 ·  Posted (edited)

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

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

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

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

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

Share this post


Link to post
Share on other sites

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

#10 ·  Posted (edited)

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

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

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.

1 person likes this

Share this post


Link to post
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.

Share this post


Link to post
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!

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  
Followers 0

  • Similar Content

    • badcoder123
      By badcoder123
      Anyone know how to access the information circled in the photo?
       

    • AndreyS
      By AndreyS
      Dear developers and creators of the language, please explain to me why when pressing the combination Crtl + Shift + C from the 5th or the 10th time "sticks / sinks" Ctrl or Shift? And then you need to press Ctrl or Shift again to reset their triggering. I only need to use hot keys like in the example!
      The code is a small example. Its essence is that when a user in the editor selects any number and presses a combination, then it increases by 1. 
      Dim $x HotKeySet("+^c","Calc") While 1 Sleep(10000) WEnd Func Calc() Send("^c") Sleep(50) $x=ClipGet()+1 ClipPut($x) Send("^v") EndFunc I thought that in my program some kind of glitch was searching for a reason for a long time. And it turned out that apparently somehow the work of some functions used in the example is not compatible. 
      Tell me, please, what is the problem?
    • ur
      By ur
      If you observe in below code.
      Func _WinWaitActivate($title,$text,$timeout=$time_out) Logging("Waiting for "&$title&":"&$text) $dHandle = WinWait($title,$text,$timeout) if not ($dHandle = 0) then If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) Else Logging("Timeout occured while waiting for the window...") Exit EndIf EndFunc WinActivate("Untitled - Notepad") $p = "Notallowed1!!" Send("{ENTER}{ENTER}{ENTER}{ENTER}"& $p &"{ENTER}create{SPACE}database{SPACE}"& $p &";{ENTER}") In the notepad if you observe, ! is missing in the text got.
       
      Is there way to get that also printed.
    • rawkhopper
      By rawkhopper
      Hello everyone,
      I have a script that is automating a piece of sluggish software.  I want to automate it with a bit of caution and I am not sure the best way to do it.  ControlSend works great most of the time.  If I have it enter 10 into a text box every once in a while it will enter 1 or 11 and then hit enter.
      To overcome this I use MouseClick to select the text I just entered and then see if it matches the string it was supposed to put in before it hits enter.  This seems to work but what I love about ControlSend is there is less room for human interaction messing it up.  
      Yes I could block input but I prefer not to do that (permissions).
      Is there a better way of doing this?  Any Help would be much appreciated.
      Anyway here is the snippet of the script in question:
      Func KVSend () WinActivate ( "Window", "" ) Local $WindowPos = WinGetPos("Window", "") If $kV < 30 Then WinActivate ( "Window", "" ) ControlClick ("Window", "", 1001) ;Click in Accel Voltage box Sleep (100) ControlSend ("Window", "", 1001, $kV) ; \ kV Sleep (100) MouseMove($WindowPos[0]+130,$WindowPos[1]+75,1) MouseClick($MOUSE_CLICK_LEFT) MouseClick($MOUSE_CLICK_LEFT) Send ("^c") Local $clip = ClipGet () If $clip = $kV Then ControlSend ("Window", "", 1001, "{ENTER}") ;Hit ENTER if value is correct Sleep (100) ControlClick ("Window", "", 1518) ;Lens Clear Else Send ("{BACKSPACE}") KVSend() ; If value is incorrect try again EndIf EndIf  
    • spuuunit
      By spuuunit
      This is what I'm trying to do: In Firefox, if you hold down CTRL + C for about 200ms, then press CTRL + T. This is my code:
      While WinActive(" - Mozilla Firefox") If _IsPressed("A2", $hDLL) And _IsPressed("43", $hDLL) Then $timer = TimerInit() While _IsPressed("A2", $hDLL) And _IsPressed("43", $hDLL) Sleep(10) $diff = TimerDiff($timer) If $diff > 200 Then Send("^{T}") While _IsPressed("A2", $hDLL) And _IsPressed("43", $hDLL) Sleep(10) WEnd EndIf WEnd EndIf WEnd The problem is that the CTRL key gets stuck down after Send("^{T}"). I found this, but what I understand that happens when I release, and that is not what I want. The "General unstuck method" did nothing.