Jump to content

same classname, different titles...


Recommended Posts

Hello folks,

I think we can precize the title of the window not in the $ie but in the "winwait" function ?

The problem was that I have two windows with a classname=ThunderRT6FormDC" and then I only want a click on the pop up but not on the one were I stream my webcam :-)

Is it correct to precize in the Winwait function only the title of the Windows (which is "new viewer connected!" like this :

$i1 = 'classname=ThunderRT6FormDC';Title of the first window
$i2 = 'classname=Microsoft Internet Explorer';Title of the second window

Opt("WinTitleMatchMode", 4)
HotKeySet('^!x','_Terminate');Use CTRL+ALT+X to terminate this script.
Do
; when the 1st IE window appears, then click the mouse at (1254,286)
   WinWait($i1, "new viewer connected!")
   WinActivate($i1)
   MouseClick("left", 1254, 286, 1, 1)
   WinWaitClose($i1)
   
; when the 2nd window appears, then click the mouse at (682, 509)
   WinWait($i2, "Microsoft Internet Explorer")
   WinActivate($i2)
   MouseClick ("left", 682, 509, 1, 1)
   WinWaitClose($i2)
Until 0

Exit
Func _Terminate()
   Exit
EndFunc

Many Thanks!

Sandra

Link to comment
Share on other sites

Actually you are messing my code... :|

The WinWait sintax is WinWait(title, text), I used a couple variants, $i1 and $i2 so you don't have to write down the same titles over and over but just once.

In your line 8 you wait for a window that have as classname ThunderRT6FormDC and as text "new viewer connected!". That I am not sure is intended.

While in line 14 you wait for a windows that have 'Microsoft Internet Explorer' as classname and as text "Microsoft Internet Explorer", that is virtually impossible.

If the two titles are different each other and never change, just set them in the begin in the variants and use them when needed.

Link to comment
Share on other sites

Yes, there is something I messed, because I did not get very well the difference between window title and window classname, even in reading the help file. I used both as when I used AutoitSpy, it gave me two different things:

one pop up (but it does not mean that it will appear first) is a little IE pop up, and as for title "Microsoft Internet Explorer"

the other pop up is not a IE pop up, and I suppose it is a part of the software I use to run my webcam. The classname of this one is the same as the main window of the software (and I don't want to click on this one!) and as for title "new viewer connected!". I don't want the script to click on every windows that have the same classname... this is why I add the title ...

And finally, to explain maybe the lines 8 and 14...

it is maybe more easy if I explain exactly what happens... If the pop up 1 come first, then click on it... if it comes a second time, then click on it... if now it is the pop up 2 that comes, then click on it... etc.

There is no order between these two pop ups... they can come at ay time, independently from each other...

Maybe it should have a "if" function somewhere ?

I am really a dumbass with this, but it is really the first time I see such codes :-)

Sandra

Link to comment
Share on other sites

Hi SandraParis,

Yes, maybe an if WinExists may help.

$i1 = 'classname=ThunderRT6FormDC';Title of the first window
$i2 = 'classname=Microsoft Internet Explorer';Title of the second window

Opt("WinTitleMatchMode", 4)
HotKeySet('^!x','_Terminate');Use CTRL+ALT+X to terminate this script.
While 1
   Sleep(100)
  ; when the 1st IE window appears, then click the mouse at (1254,286)
   If WinExists($i1, "new viewer connected!") Then
   WinActivate($i1)
   MouseClick("left", 1254, 286, 1, 1)
   EndIf
   
; when the 2nd window appears, then click the mouse at (682, 509)
   If WinExists($i2, "Microsoft Internet Explorer") Then
   WinActivate($i2)
   MouseClick ("left", 682, 509, 1, 1)
   EndIf
WEnd

Exit
Func _Terminate()
   Exit
EndFunc

May give you some idea, for a solution

:idiot:

Edited by MHz
Link to comment
Share on other sites

So here we hare, forget the classname thing for now.

As it is when 'Microsoft Internet Explorer' appear this script will click 1254,268 when 'new viewer connected!' appear the script will click 682,508, any order will work.

$i1 = 'Microsoft Internet Explorer';Title of the first window
$i2 = 'new viewer connected!';     Title of the second window

;Opt ("WinTitleMatchMode", 4)
HotKeySet('^!x', '_Terminate');Use CTRL+ALT+X to terminate this script.

While 1
  ; if $i1 window appears, then click the mouse at (1254,286)
   If WinExists($i1) Then
      WinActivate($i1)
      MouseClick("left", 1254, 286, 1, 1)
   EndIf
   
  ; if $i2 window appears, then click the mouse at (682, 509)
   If WinExists($i2) Then
      WinActivate($i2)
      MouseClick("left", 682, 509, 1, 1)
  EndIf
  
  Sleep(100)
WEnd

Exit
Func _Terminate()
   Exit
EndFunc  ;==>_Terminate

Can I ask why do you need to click? It is to keep a window active?

Link to comment
Share on other sites

thanks a lot for the code, I thought it would be better with the "if" but I cannot code it like you did ;-)

I just changed the x,y for each window

I need a "click" on each one of these windows because I am sometimes far away from the screen do offer other views... and that I cannot come back always to click to let a viewer enter...

Ideally, it would be even better to have a voice recognition that can type for me things in the "chat" what I want to type on the keyboard, without to use my fingers :D))

Because my fingers are busy sometimes too. I will not go further :idiot:

I will tell you if the script if working :lol:

Sandra

Link to comment
Share on other sites

Rhaaaagh :-(

The script did not get one of the window... (I only tryed it with one so far)... The pop up stood without to be cliked

:idiot:

Here is the code again... I don't think I made a mistake in writting the windows names...

$i1 = 'Microsoft Internet Explorer';Title of the first window
$i2 = 'new viewer connected!';     Title of the second window

;Opt ("WinTitleMatchMode", 4)
HotKeySet('^!x', '_Terminate');Use CTRL+ALT+X to terminate this script.

While 1
 ; if $i1 window appears, then click the mouse at (682,509)
   If WinExists($i1) Then
      WinActivate($i1)
      MouseClick("left", 682, 509, 1, 1)
   EndIf
   
 ; if $i2 window appears, then click the mouse at (1254, 286)
   If WinExists($i2) Then
      WinActivate($i2)
      MouseClick("left", 1254, 286, 1, 1)
  EndIf
  
  Sleep(100)
WEnd

Exit
Func _Terminate()
   Exit
EndFunc ;==>_Terminate

It is like if the script did not recognize the pop up came... :-(

Sandra

Link to comment
Share on other sites

Just a little comment..

Haven't really set my mind into this project, but wouldn't the

use of a WinClose be more stable then a manual close with MouseClick ? :idiot:

Because, as far as I see this is a kind of popup-killer, and with the use of

MouseClick this could result in a miss-placed MouseClick if the window of

some reason isn't located where it's normally is..

Maybe I'm way off.. :D

Link to comment
Share on other sites

Rhaaaagh :-(

It is like if the script did not recognize the pop up came... :-(

Your script works for me. Below is the code I used to test it. It creates two Notepad windows and assigns the names you specified to them. The rest is your code, with message boxes instead of mouse clicks (as the mouse clicks are not needed just to see if both windows get identified by the loop).

1. Are the window names exactly as you specified, including the capitalization of characters (should "new" be "New")? See the "Opt" function in the help file for the "WnTitleMatchMode" parameter.

2. Are the mouse click positions correct? Are they relative to the screen or the particular window? See the "Opt" function in the help file for the "MouseCoordMode" parameter.

$i1 = 'Microsoft Internet Explorer';Title of the first window
$i2 = 'new viewer connected!';     Title of the second window

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Create windows with specific titles for testing purposes
Run("NotePad")
WinWaitActive("Untitled - Notepad")
sleep(100)
winmove("Untitled - Notepad", "", 100, 100)
WinSetTitle("Untitled - Notepad", "", $i1)
sleep(100)
Run("NotePad")
WinWaitActive("Untitled - Notepad")
sleep(100)
winmove("Untitled - Notepad", "", 300, 300)
WinSetTitle("Untitled - Notepad", "", $i2)
sleep(100)
opt("WinTitleMatchMode", 2)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Opt ("WinTitleMatchMode", 4)
HotKeySet('^!x', '_Terminate');Use CTRL+ALT+X to terminate this script.

While 1
  ; if $i1 window appears, then click the mouse at (682,509)
   If WinExists($i1) Then
      WinActivate($i1)
;     MouseClick("left", 682, 509, 1, 1)
MsgBox(4096, "Debug", "Window:  " & $i1)
   EndIf
   
  ; if $i2 window appears, then click the mouse at (1254, 286)
   If WinExists($i2) Then
      WinActivate($i2)
;     MouseClick("left", 1254, 286, 1, 1)
MsgBox(4096, "Debug", "Window:  " & $i2)
   EndIf
   Sleep(100)
WEnd

Exit
Func _Terminate()
   Exit
EndFunc  ;==>_Terminate

Phillip

Link to comment
Share on other sites

Thanks Phillipadams and Helge (and ezzetabi and everybody) :D

I will check again for the capital in the window title... otherwise, I really don't see anything that can avoid the window to be recognized... Maybe because it is not an Internet Explorer window as the other one that is recognize ?

It seems to me that a "winclose" close a window, but don't click on a specific area on it ? But maybe I am wrong ?

Now I am trying also to fiw a problem with my IE vdeochat that make a "visual c++" error with "abnormal termination" for iexplorer.exe :-( I tryed to reinstall IE, I scanned for adwares and spywares... I uninstall all google bar and other bars.....

Do one of you had this error previously ?

(it is not a recent error, I have it since few weeks, but I cannot figure out what was wrong...)... And I don't want to install XP again -moreover I lost the CD :lol:))

Life is too injust ! :idiot:

Sandra

Link to comment
Share on other sites

1. Are the window names exactly as you specified, including the capitalization of characters (should "new" be "New")? See the "Opt" function in the help file for the "WnTitleMatchMode" parameter.

You were right !! I saw that the N was capital... I changed it, so I will tell you if it works better this way :idiot:

Still is the problem with IE, but I think scripts cannot do anything for that :-(

Windows sucks :D

Sandra

Link to comment
Share on other sites

Using AutoIt Active Window Spy, note you use CTRL-ALT-F to freeze the display and you can cut and paste the windows text parameters.

Perhaps the window is one of those unpleasant java generated windows?

Then the mouse click may be nec. I dunno.

J

If I am too verbose, just say so. You don't need to run on and on.

Link to comment
Share on other sites

Now I am trying also to fiw a problem with my IE vdeochat that make a "visual c++" error with "abnormal termination" for iexplorer.exe :-( I tryed to reinstall IE, I scanned for adwares and spywares... I uninstall all google bar and other bars...

<{POST_SNAPBACK}>

The main problem is that you use IE... Some solutions:

http://www.opera.com

http://www.getfirefox.com

http://www.maxthon.com

http://www.mozilla.org

http://www.avantbrowser.com

http://www.flashpeak.com/sbrowser/sbrowser.htm

About the problem, Autoit detects every windows, it may not detect controls. So the problem have to be in the title, check again with the infotool and use copy and paste.

Link to comment
Share on other sites

Ezzetabi,

You are right, the problem is in the title, I changed it to the right "N" and it works perfectly :-)

The other IE window is not working properly as I have a IE error...

The main problem is that you use IE...

Yes, I know it, i tryed lot of other briswers, but the website where I am is not supporting other broswer for the IE applet I have to use :-(

Too bad :-(

Sandra

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...