Jump to content

If Winexists


Go to solution Solved by grimmlock,

Recommended Posts

Good Morning,

I have a wierd question, that I have not been able to solve. If anyone has used Team Viewer before you know that when you are done accessing a PC (using the Personal Free Version) that the TeamViewer window pop up. So I have created a small little script that runs and closes the window if it exists.

 
If winexists('TeamViewer', '') Then
winclose('Teamviewer', '')
Endif
 

 

However I just ran into a snag where if I open a browser and try to login to my Team Viewer account it closes the browser, because I have told the script to close any and all windows that have TeamViewer at the title to close. Is there a way to have the script know the difference between a browser tab and the app? That way I can access my TeamViewer account using a browser but still have the TeamViewer App windows close.

Thanks in advance.

Grimm

Thanks

Grimm

Link to comment
Share on other sites

The app's popup window has more than just TeamViewer in the title, try looking for that instead. Or use the class name of the window.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

That class is an 'enabled popup'.

If you have the handle of the parent window, you can use this;

$hpopup = _WinAPI_GetWindow($hParent,6)

That's a really helpful function to dynamically grab any message from the application.  Then use the title and text of the window to know what actions to perform.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

I've done this.  I do kinda forget how exactly though.  I suggest an array of block strings.

$a_block[0] = "Google Chrome"

$a_block[1] = "Internet Explorer"

$a_block[2] = "Some Other String to Block"

When you find one of the block strings in the window title, don't close the window.

Edited by Xandy
Link to comment
Share on other sites

Data from Summary Tab :)

>>>> Window <<<<
Title:    TeamViewer
Class:    #32770
Position:    687, 281
Size:    546, 478
Style:    0x96CA08CC
ExStyle:    0x00050101
Handle:    0x00010178

>>>> Control <<<<
Class:    
Instance:    
ClassnameNN:    
Name:    
Advanced (Class):    
ID:    
Text:    
Position:    
Size:    
ControlClick Coords:    
Style:    
ExStyle:    
Handle:    

>>>> Mouse <<<<
Position:    830, 288
Cursor ID:    0
Color:    0xBBD0F0

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Control Remote Computer
Please enter your partner's ID in order to control the remote computer.
Partner ID
772020948
772020948
Remote control
File transfer
Connect to partner
Allow Remote Control
534 671 829
Please tell your partner the following ID and password if you would like to allow remote control.
v442du
Use your personal password to access this computer from anywhere.


>>>> Hidden Text <<<<
Initializing security settings...
Statisch
VPN
Abort connection
Personal
Password
Host Meeting
Schedule meetings
Schedule a meeting
My meetings
Start instant meeting
Abort meeting
Join Meeting
Please enter the ID of the Meeting you would like to participate in.
Meeting ID
m
Your name

Join meeting
Abort connection
Start a spontaneous meeting and invite participants to it.
Presentation mode
Video mode

Thanks,

Thanks

Grimm

Link to comment
Share on other sites

When I end a TV session I get this pop up dialog.

>>>>> Window <<<<

Title: Sponsored session

Class: #32770

Position: 434, 280

Size: 491, 168

Style: 0x94C000CE

ExStyle: 0x00010109

Handle: 0x00080460

>>>> Control <<<<

Class: Static

Instance: 2

ClassnameNN: Static2

Name:

Advanced (Class): [CLASS:Static; INSTANCE:2]

ID: 20097

Text: This was a free session sponsored by www.teamviewer.com.

TeamViewer sessions are free of charge for personal use.

We thank you for playing fair!

Position: 81, 11

Size: 386, 75

ControlClick Coords: 126, 41

Style: 0x50020000

ExStyle: 0x00000024

Handle: 0x000404B8

>>>> Mouse <<<<

Position: 644, 357

Cursor ID: 0

Color: 0x000000

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

Like!

Buy License

OK

This was a free session sponsored by www.teamviewer.com.

TeamViewer sessions are free of charge for personal use.

We thank you for playing fair!

>>>> Hidden Text <<<<

4

Show my desktop

Don't show this dialog again

What you're showing is the main window for TV.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Solution

I got it, it took me forever but this seems to work,

 
$tview = ""
$thandle = WinGetTitle("[ACTIVE]")

If $thandle = "TeamViewer Management Console - Mozilla Firefox" Then
    $tview = "Console"
        If $tview = "Console" Then
        EndIf
ElseIf $thandle = "TeamViewer" Then
    $tview = "App"
        If $tview = "App" Then
            WinClose("TeamViewer")
        EndIf
EndIf
 

Thanks for everyone's help

Edited by grimmlock

Thanks

Grimm

Link to comment
Share on other sites

I disagree with that being the best answer.

Also, you should be using the handle of the window, or the first instance of 'TeamViewer' will close, and possibly not the one you expect to close.

Or, winclose("[ACTIVE]")

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

I didn't realize you were starting a session from the web browser and not the application. 

You should look for the text of the window to match, as well as the title, this way you know you're closing the right window.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • 3 years later...

I also use the WinGetText("text here") funct. to grab infos I need for my windows. But sometimes it unfortunately doesn't find the text I need. It really depends on the type of windows (Visual Studio, SQL Server, Chrome.. etc.)

Link to comment
Share on other sites

I also use the WinGetText("text here") funct. to grab infos I need for my windows. But sometimes it unfortunately doesn't find the text I need. It really depends on the type of windows (Visual Studio, SQL Server, Chrome.. etc.)

Link to comment
Share on other sites

I also use the WinGetText("text here") funct. to grab infos I need for my windows. But sometimes it unfortunately doesn't find the text I need. It really depends on the type of windows (Visual Studio, SQL Server, Chrome.. etc.)

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...