Sign in to follow this  
Followers 0
MatheFreak

ToolTip buggy? (Blocks WinTitleMatchMode)

17 posts in this topic

I think I found a bug, or am I doing something wrong??

If I use 'ToolTip', my scripts don't work any longer.

ToolTip seems to block setting of WinTitleMatchMode even thogh it is refreshed afterwards.

Further windows simply dont get activated if their name is not fully given!

First I thouht it was a problem with VBS and AutoItX3, now I realised, that it doesent work in AutoIt either.

Try this code:

;ToolTip("Waiting for Excel")
Opt("WinTitleMatchMode", 2)
WinActivate("Excel")
WinWaitActive("Excel","",3)      ; Watchout: substring given
send("This one works{!}{DOWN}")  ; ToolTip NOT YET used => substring works


ToolTip("Waiting for Excel")
Opt("WinTitleMatchMode", 2)
WinActivate("Microsoft Excel")
WinWaitActive("Microsoft Excel","",3) ; Watchout: full titel given
send("It works too{!}{DOWN}")    ; ToolTip was used => MatchMode 2 is unimportant


ToolTip("Waiting for Excel")
Opt("WinTitleMatchMode", 2)      ; Watchout: try to refresh MatchMode doesn't seem to work
WinActivate("Excel")
WinWaitActive("Excel","",3)      ; Watchout: substring given
send("No way{!}{DOWN}")          ; ToolTip alredy used => substring FAILS

Share this post


Link to post
Share on other sites



Try using an AutoIt script to create the tooltip and then run a VB script using AppActivate to activate the window and if it fails then it maybe a windows bug.

:)

Share this post


Link to post
Share on other sites

Thats's what I was doing.

Just try the attached code. (After having started Excel manually).

This IS an AutoIt Script.

I Think you should get the same error.

=> the third block wouldn't do anything. (It should type "No way" in Ecxel Cell A:3)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thats's what I was doing.

I have seen you use AutoIt's WinActivate. I have not seen you use AppActivate which is the VB script method of activating a window. There is a difference.

Edit:

Note that I do not have Excel to test myself.

Edited by MHz

Share this post


Link to post
Share on other sites

Your usage for WinTitleMatchMode by substring is finding the ToolTip as it is the last active window with the substring to match.

This shows you the match.

Opt("WinTitleMatchMode", 2)
ToolTip('Some Excel Title')
If WinExists('Excel') Then
    MsgBox(0, Default, 'Title exists')
EndIf

Share this post


Link to post
Share on other sites

I have seen you use AutoIt's WinActivate.

I have not seen you use AppActivate which is the VB script method.

I was trying it from VBS first, and it didnt work.

So I reduced debuging to pure AutoIt. Shouldn't it run better on AutoIt without influence of VBS?

Is there a possibillity to use AppActivate from AutoIt? How?

But by the way: The application IS running, and WinExists() DOES report YES.

Note that I do not have Excel to test myself.

The same effect should come on each other Program.

e.g.: WinActivate("Microsoft Word") vs. WinActivate("Word")

... or any editor you use:

e.g.: WinActivate("Ultra Edit") vs. WinActivate("Edit")

or: WinActivate("SciTE4AutoIt3") vs. WinActivate("TE4")

=> As soon as you have used ToolTip you can't call a window ambigous. (MatchMode=2)

(I've tested it on 3 non MS-programs.)

I still belive: It's a bug.

You can try:

;Demo:  ToolTip is buggy
;Start you prefered editor manually first!
$FullTitle="Microsoft Excel"    ; or $FullTitle="SciTE4"        ; or $FullTitle="Ultra Edit"
$ShortTitle="Excel"             ; or $ShortTitle="TE4"          ; or $ShortTitle="Edit"


; Test 1: ================================================================
;ToolTip("Waiting for "& $ShortTitle)
Opt("WinTitleMatchMode", 2)
WinActivate($ShortTitle)
WinWaitActive($ShortTitle,"",3) ; Watchout: ShortTitle given
send("This one works{!}{DOWN}") ; ToolTip NOT YET used => ShortTitle works


; Test 2: ================================================================
ToolTip("Waiting for "& $ShortTitle)
Opt("WinTitleMatchMode", 2)
WinActivate($FullTitle)
WinWaitActive($FullTitle,"",3)  ; Watchout: FullTitle given
send("It works too{!}{DOWN}")   ; ToolTip is used => MatchMode 2 is ignored


; Test 3: ================================================================
ToolTip("Waiting for "& $ShortTitle)
Opt("WinTitleMatchMode", 2)     ; Watchout: try to refresh MatchMode doesn't seem to work
WinActivate($ShortTitle)
WinWaitActive($ShortTitle,"",3) ; Watchout: ShortTitle given
send("No way{!}{DOWN}")         ; ToolTip alredy used => ShortTitle FAILS
;!!!!! This last text never appeares!!!!

Share this post


Link to post
Share on other sites

Your usage for WinTitleMatchMode by substring is finding the ToolTip as it is the last active window with the substring to match.

This shows you the match.

Opt("WinTitleMatchMode", 2)
ToolTip('Some Excel Title')
If WinExists('Excel') Then
    MsgBox(0, Default, 'Title exists')
EndIf
OMG

Now I see!!!

ToolTip is findig himself!!

Thanks a lot for this hint!!

So it's not a bug!

How can I indicate with ToolTip "Im wating for SaveAs Dialog" without getting confused with the real "SaveAs Dialog"?

Do I have to something use like WinTitleMatchMode=4 ???

Share this post


Link to post
Share on other sites

How can I indicate with ToolTip "Im wating for SaveAs Dialog" without getting confused with the real "SaveAs Dialog"?

Do I have to something use like WinTitleMatchMode=4 ???

What's your problem with mode 4? You know advanced WinTitle strings work in all modes now, right? WinTitleMatchMode = 4 is deprecated, so you can be in mode 2 and also use advanced descriptions. The ToolTip has a different CLASS to begin with.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

What's your problem with mode 4? You know advanced WinTitle strings work in all modes now, right?

WinTitleMatchMode = 4 is deprecated, so you can be in mode 2 and also use advanced descriptions. The ToolTip has a different CLASS to begin with.

:)

My Problem is not mode 4. I just guess it was the solution and I don't know how to work with it. (Newbie on AutoIt)

Now I know that mode 4 is basicly wrong, as I'm just understanding the principal of "advanced WinTitle". Thanks so far.

The real problem behind it is: How can I invoke the right window, if name is duplikated (gets duplikated by my own produced ToolTip)?

e.g.: The Dialog "Any-Text - Open-Dialog" and the ToolTip "Waiting for Open-Dialog".

Problem is that it must work in a subroutine, and I do know ONLY (e.g) "Open-Dialog"

How should I WinActivate() with TITLE something like "Open-Dialog" and CLASS not a ToolTip.

Share this post


Link to post
Share on other sites

Is there text that is always in the window you want? such as a menu it would see &File (If I remember correctly, The & underlines the F)


Giggity

Share this post


Link to post
Share on other sites

How should I WinActivate() with TITLE something like "Open-Dialog" and CLASS not a ToolTip.

WinActivate("[TITLE:Open-Dialog; REGEXPCLASS:^(ToolTip)]")

Maybe something like this? that REGEXPCLASS should allow all classes that aren't "ToolTip"?

Share this post


Link to post
Share on other sites
WinActivate("[TITLE:Open-Dialog; REGEXPCLASS:^(ToolTip)]")oÝ÷ ØƲmë(ëax%G­+-«Qa

Share this post


Link to post
Share on other sites

The caret in the pattern "^(tooltip)" matches beginning of line, it is not negation. I don't see a way to get RegExp to do what you want in that circumstance.

To find windows that do match a title but do not match a class:

1. WinList() with only the title to get an array of all windows with the matching title.

2. Loop through the array using _WinAPI_GetClassName() to get the class name of each window

3. Use StringInStr() to test the class NOT containing tooltip

#Include <WinAPI.au3>

$avWinList = WinList("Excel")
For $n = 1 To $avWinList[0][0]
    $sClass = _WinAPI_GetClassName($avWinList[$n][1])
    If StringInStr($sClass, "tooltip") = 0 Then
        MsgBox(64, "Found Window", "This window has the title 'Excel'," & @CRLF & _
                "but is not a tooltip class:" & @CRLF & @CRLF & _
                "Title:  " & $avWinList[$n][0] & @CRLF & _
                "HWND:  " & $avWinList[$n][1] & @CRLF & _
                "Class:  " & $sClass)
        Exit
    EndIf
Next
MsgBox(16, "Not Found", "Did not find a matching window.")

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Found a way to do it with REGEXPCALSS :)

;Start EXCEL manually first!
Opt("WinTitleMatchMode", 2)
ToolTip("Waiting for Excel")

; None of them works
$Search="[TITLE:Excel; REGEXPCLASS:\A(?!tooltips_class)]" ; Matches beginning of Class is not "tooltips_class"
MsgBox(0, '', WinExists($Search))

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Found a way to do it with REGEXPCALSS :o

$Search="[TITLE:Excel; REGEXPCLASS:\A(?!tooltips_class)]"; Matches beginning of Class is not "tooltips_class"
MsgBox(0, '', WinExists($Search))
Oh, nice one. Negative Lookahead Assertions; that's what I didn't find in my reading.

Thanks.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Found a way to do it with REGEXPCALSS :)

;Start EXCEL manually first!
Opt("WinTitleMatchMode", 2)
ToolTip("Waiting for Excel")

$Search="[TITLE:Excel; REGEXPCLASS:\A(?!tooltips_class)]"; Matches beginning of Class is not "tooltips_class"
MsgBox(0, '', WinExists($Search))
Great!! Thank you!

Indeed I thought '^' was a negation, and dont yet understand this '\A(' thing.

Looks getting quite complicated :-) , but might work.

Just I'm on wrong machine till monday, I'll let you know!

Share this post


Link to post
Share on other sites

Just I'm on wrong machine today, I'll let you know!

It works Great!! Thank you!

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