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

    • 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.
    • TheDcoder
      By TheDcoder
      Hello everyone, long time since I made a post in the H&S sub-forum
      I am working on a project where in a situation I would have to hold down an arrow key and release it in another statement/command, however when I wrote the code it isn't working exactly like I thought it would. Here is an example:
      Send("{UP down}") Sleep(10000) Send("{UP up}") This should hold the up arrow key for 10 seconds before releasing it again, but when I run this code the cursor in SciTE moves up only once
      If I hold the up arrow manually for 10 seconds it "repeats" and the cursor moves up several times until I release the key... Is this a known limitation of Send? Is there any other way I can accomplish this?
      Thanks for all the help and feedback in advance! TD
    • jantograaf
      By jantograaf
      Hi all,
      I'm having some trouble restoring a program which uses a normal AutoIT-GUI and is used as a ToolKit for our customers to open different (external) tools, check their network connections or ping different destinations. Almost all customers are running this script on Win7 x64. 
      What do I want to do?
      When the program is already running and the user tries to start it for a second time, it should exit the second instance after activating/restoring the first instance.
      What did I do to integrate this?
      I used a little piece of script found on the forums to prevent opening a second instance and modified it as follows:
      $g_szVersion = "VSOL ToolKit" If WinExists($g_szVersion) Then Local $gState = WinGetState($g_szVersion) MsgBox(0,"","gState = " & $gState) ;For debugging purposes WinSetState($g_szVersion,"",@SW_SHOW) MsgBox(0,"","gState = " & $gState) ;For debugging purposes WinSetState($g_szVersion,"",@SW_RESTORE) MsgBox(0,"","gState = " & $gState) ;For debugging purposes WinActivate($g_szVersion) Exit EndIf AutoItWinSetTitle($g_szVersion) I have tried it with only the @SW_SHOW, only the @SW_RESTORE, both of them in a different order, same difference, it doesn't work.
      What does happen then?
      It detects the current state (when it's minimized) as '5', which means enabled and hidden. After setting the state to show, the state changes to 7. Restoring doesn't change the state. But what is really odd, is that the window doesn't appear but AutoIt seems to create a néw window with the same title as the existing one. 

      It doesn't matter if the window was originally minimized by clicking the minimize button in the GUI or by a line of code in my script. For example, when users open a software package from within my script, a similar function to this one will be called:
      Func VSOL_FFTOOLS_SHOW_DOWNLOADS() GUISetState(@SW_MINIMIZE,$VSOL_BACKEND) ShellExecute(@UserProfileDir & "\Downloads") EndFunc The only thing that does work, is when the window is running in a non-minimized state (somewhere behind the current window), it gets activated and receives the focus when trying to start the second instance.
      If anyone could help me out with this one, I'd be forever thankful :-)
      Thanks in advance!
      Kind regards,
      Jan Geurts
×