Sign in to follow this  
Followers 0
jerseyzuks

Cannot get AutoIT to close a window

11 posts in this topic

Here is the code. Everything works 100% fine, except that it won't close the window

Func MarimbaTuner ()
Dim $Test
BlockInput(0) ; this enables the keyboard and mouse
MsgBox(0, "user access control", "A User Access Control Window is about to pop up.  Click 'yes' on the next window to allow Marimba to launch")
Sleep(500)  ;pause for .5 second
ShellExecute("http://marimbadev:5282/Marimba/Current/ChannelManager?start") ;Opens Marimba Tuner
Sleep(4000)  ;pause for 4 second
MsgBox(262144, "Marimba Tuner", "right click on one of the channels and select 'verify'") ;asks user to right click on a channel, and select verify
Sleep(2000)  ;pause for 2 second
$test = MsgBox(262144 + 4, "Marimba Tuner", "Did the channel you verified change from 'installed' to 'running'?") ;prompts user to click ok after verifying that the video works
If $test = ("6") then
  FileWriteLine($file, "PASS - Marimba Tuner is working correctly")
Else
  FileWriteLine($file, "FAIL - Marimba Tuner is NOT working correctly")
EndIf
Sleep(1000)  ;pause for 1 second
;WinClose("BBCA")
WinClose("BBCA Tuner 8.2", "")
Sleep(1000)  ;pause for 1 second
EndFunc

Tried Winclose, Tried send ("!{F4}")... doesn't want to close. However, if I manually type Alt and f4, the window will close.

Here is the window info

>>>> Window <<<<

Title: BBCA Tuner 8.2

Class: SunAwtFrame

Position: 308, 295

Size: 663, 433

Style: 0x16CF0000

ExStyle: 0x00000100

Handle: 0x00000000001607FA

>>>> Control <<<<

Class:

Instance:

ClassnameNN:

Name:

Advanced (Class):

ID:

Text:

Position:

Size:

ControlClick Coords:

Style:

ExStyle:

Handle:

>>>> Mouse <<<<

Position: 617, 311

Cursor ID: 0

Color: 0xCBD8E6

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

>>>> Hidden Text <<<<

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It's possible the title of the window changes when going from channel to channel/option to option.

Add

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocas

at the top of the script then to close the window

If WinExists("BBCA") Then
  WinClose("BBCA")
Else
  msgbox(16 + 262144, "BBCA Tuner", "Window not found")
EndIf
Edited by mechaflash213

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

Did you try ProcessClose?


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

It's possible the title of the window changes when going from channel to channel/option to option.

Add

Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocas

at the top of the script then to close the window

If WinExists("BBCA") Then
  WinClose("BBCA")
Else
  msgbox(16 + 262144, "BBCA Tuner", "Window not found")
EndIf

Thanks for the responses. I had the title match mode option already set for substring, as it gets used in other functions as well.

Oddly enough, I copied and pasted your code... and it didn't close the window, nor did it do the failure messagebox

Changed it to this...

If WinExists("BBCA") Then
  msgbox(16 + 262144, "BBCA Tuner", "Found the Window")
  WinClose("BBCA")
Else
  msgbox(16 + 262144, "BBCA Tuner", "Window not found")
EndIf

and now I get the message that says "found the window" but it still doesn't close it

Did you try ProcessClose?

Going to try that now

Share this post


Link to post
Share on other sites

$pid = WinGetProcess("BBCA Tuner 8.2")
ProcessClose($pid)

Share this post


Link to post
Share on other sites

$pid = WinGetProcess("BBCA Tuner 8.2") ProcessClose($pid)
This thing still won't go away! I am getting the "found the window" message box, but still won't kill it! Marimba won't die!!!!

Func MarimbaTuner ()
Dim $Test
BlockInput(0) ; this enables the keyboard and mouse
MsgBox(0, "user access control", "A User Access Control Window is about to pop up.  Click 'yes' on the next window to allow Marimba to launch")
Sleep(500)  ;pause for .5 second
ShellExecute("http://marimbadev:5282/Marimba/Current/ChannelManager?start") ;Opens Marimba Tuner
Sleep(4000)  ;pause for 4 second
MsgBox(262144, "Marimba Tuner", "right click on one of the channels and select 'verify'") ;asks user to right click on a channel, and select verify
Sleep(2000)  ;pause for 2 second
$test = MsgBox(262144 + 4, "Marimba Tuner", "Did the channel you verified change from 'installed' to 'running'?") ;prompts user to click ok after verifying that the video works
If $test = ("6") then
  FileWriteLine($file, "PASS - Marimba Tuner is working correctly")
Else
  FileWriteLine($file, "FAIL - Marimba Tuner is NOT working correctly")
EndIf
Sleep(1000)  ;pause for 1 second
ProcessClose ("tuner.exe")
If WinExists("BBCA") Then
  msgbox(16 + 262144, "BBCA Tuner", "Found the Window")
  ;WinClose("BBCA")
  $pid = WinGetProcess("BBCA Tuner 8.2")
  ProcessClose($pid)
Else
  msgbox(16 + 262144, "BBCA Tuner", "Window not found")
EndIf
Sleep(1000)  ;pause for 1 second
EndFunc

Share this post


Link to post
Share on other sites

notice the title you used in WinExists() and WinGetProcess() are different. Humor me and change the WinGetProcess() title to just "BBCA". You could also check what process close returns:

$close = ProcessClose(WinGetProcess("BBCA"))
msgbox(0,"",$close)

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

notice the title you used in WinExists() and WinGetProcess() are different. Humor me and change the WinGetProcess() title to just "BBCA". You could also check what process close returns:

$close = ProcessClose(WinGetProcess("BBCA"))
msgbox(0,"",$close)

hmmmm...

Tried this...

Func MarimbaTuner ()
Dim $Test
BlockInput(0) ; this enables the keyboard and mouse
MsgBox(0, "user access control", "A User Access Control Window is about to pop up.  Click 'yes' on the next window to allow Marimba to launch")
Sleep(500)  ;pause for .5 second
ShellExecute("[url="http://marimbadev:5282/Marimba/Current/ChannelManager?start"]http://marimbadev:5282/Marimba/Current/ChannelManager?start[/url]") ;Opens Marimba Tuner
Sleep(4000)  ;pause for 4 second
MsgBox(262144, "Marimba Tuner", "right click on one of the channels and select 'verify'") ;asks user to right click on a channel, and select verify
Sleep(2000)  ;pause for 2 second
$test = MsgBox(262144 + 4, "Marimba Tuner", "Did the channel you verified change from 'installed' to 'running'?") ;prompts user to click ok after verifying that the video works
If $test = ("6") then
  FileWriteLine($file, "PASS - Marimba Tuner is working correctly")
Else
  FileWriteLine($file, "FAIL - Marimba Tuner is NOT working correctly")
EndIf
Sleep(1000)  ;pause for 1 second
ProcessClose ("tuner.exe")
If WinExists("BBCA") Then
  msgbox(16 + 262144, "BBCA Tuner", "Found the Window")
  ;WinClose("BBCA")
  ;$pid = WinGetProcess("BBCA Tuner 8.2")
  ;ProcessClose($pid)
  $close = ProcessClose(WinGetProcess("BBCA"))
  msgbox(0,"",$close)
Else
  msgbox(16 + 262144, "BBCA Tuner", "Window not found")
EndIf
Sleep(1000)  ;pause for 1 second
EndFunc
Func SunJava ()
EndFunc

Get the "found the window" message, but does not close, and returns a message box with a zero in it

Edited by jerseyzuks

Share this post


Link to post
Share on other sites

Ok, something is really screwy here

Trying another test, everything is working just fine, but again it won't close the window...

Func AdobeFlash ()
Opt("WinTitleMatchMode", 2)
BlockInput(1) ; this disables the keyboard and mouse, so the tester cannot interfere with the testing
ShellExecute ("http://helpx.adobe.com/flash-player/kb/find-version-flash-player.html") ;opens the adobe page to check the version of flash
BlockInput(0)
$test = MsgBox(4, "Adobe Flash Test", "Do you see the red ball moving back and forth?") ;prompts user to click ok after verifying that the video works
If $test = ("6") then
  FileWriteLine($file, "PASS - Adobe Flash Player was working")
Else
  FileWriteLine($file, "FAIL - Adobe Flash Player was NOT working")
EndIf
$test = MsgBox(4, "Adobe Flash Test", "Is the version # 10.0.45.2 or higher?") ;prompts user to click ok after verifying that the video works
If $test = ("6") then
  FileWriteLine($file, "PASS - Adobe Flash Player has the current version installed")
Else
  FileWriteLine($file, "FAIL - Adobe Flash Player does not have the current version installed")
EndIf
    BlockInput(1) ; this disables the keyboard and mouse, so the tester cannot interfere with the testing
    If WinExists("Flash Player Help") Then
  msgbox(16 + 262144, "Flash Player", "Window found")
  WinClose ("Flash Player Help")
Else
  msgbox(16 + 262144, "Flash Player", "Window not found")
EndIf
EndFunc

I know for this one I could just kill the ieprocess... but it would be nice to know why WinClose isn't working ;)

Share this post


Link to post
Share on other sites

One more piece of evidence that might help...

I accidentally left one of the internet explorer windows open when I ran the script, so it opened http://helpx.adobe.com/flash-player/kb/find-version-flash-player.html page in a second tab. When the script got to the WinClose ("Flash Player Help") line, I got a pop up asking if I wanted to close just that tab, or all the tabs.

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