GetClassName instead of WinGetClassList vs for ToolTips controls
"valery_vi" <[email protected]>
| Newsgroups | gmane.comp.windows.autoit.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
There is some discussion about tooltips content on
http://www.autoitscript.com/forum/index.php?
showtopic=33677&st=420&start=420
I've written following script to get tooltips content:
#include <GUIConstants.au3>
Global $A_Btn, $B_Btn, $A, $B
GUICreate("Default Buttons", 300, 300)
Global $ttXprev=0,$ttYprev=0
Opt("WinTitleMatchMode", 4)
Dim $hTT=''
$Tab = GUICtrlCreateTab (10, 10, 280, 280)
$A = GUICtrlCreateTabitem ("A")
$A_Btn = GUICtrlCreateButton ("OK", 20, 200, 100, 20)
GUICtrlSetTip($A_Btn,"Button on Tab A")
$B = GUICtrlCreateTabitem ("B")
$B_Btn = GUICtrlCreateButton ("OK", 20, 200, 100, 20)
GUICtrlSetTip($B_Btn,"Button on Tab B")
;Init buttons state
GUICtrlSetState($A_Btn, BitOr($GUI_ENABLE, $GUI_DEFBUTTON))
;GUICtrlSetState($B_Btn, $GUI_DISABLE)
GUICtrlCreateTabitem ("")
GUISetState ()
While 1
$msg = GUIGetMsg()
If WinExists('classname=tooltips_class32') Then
$hTT = WinGetHandle('classname=tooltips_class32')
if $hTT <> '' then HandlerToolTips($hTT)
endif
Select
case $msg = $GUI_EVENT_CLOSE
ExitLoop
case $msg = $Tab
If GUICtrlread ($Tab) = 0 then
GUICtrlSetState($A_Btn, $GUI_ENABLE+$GUI_DEFBUTTON)
GUICtrlSetState($B_Btn, $GUI_DISABLE)
else
GUICtrlSetState($A_Btn, $GUI_DISABLE)
GUICtrlSetState($B_Btn, $GUI_ENABLE+$GUI_DEFBUTTON)
endif
case $msg = $A_Btn
MsgBox(0,"","This is A_Btn")
case $msg = $B_Btn
MsgBox(0,"","This is B_Btn")
endselect
Wend
;=============================
; Handler of tooltip appearance
func HandlerToolTips($hTT)
local $ttX,$ttY, $state
$ttSize = WinGetPos($hTT)
$ttX = $ttSize[0]
$ttY = $ttSize[1]
$state = WinGetState($hTT)
if $ttX = $ttXprev and $ttY = $ttYprev then return
if Not BitAnd($state, 2) then return
$Title = WinGetTitle($hTT)
$ClassNameByAPI = GetClassName($hTT)
$ClassNameByAutoIt = StringSplit(WinGetClassList($hTT),@LF)
$Line = ''
$Line &= 'Title = ' & $Title & @CrLf
$Line &= 'ClassNameByAPI = ' & $ClassNameByAPI & @CrLf
$Line &= 'ClassNameByAutoIt = ' & $ClassNameByAutoIt[1] & @CrLf
MsgBox(0, 'Tooltip Info', $Line)
$ttXprev = $ttX
$ttYprev = $ttY
endfunc
;=============================
Func GetClassName($hWnd)
Local $aResult, $Length, $stText, $Text
$Length = 4096
$stText = DllStructCreate ("char[" & $Length & "]")
$aResult = DllCall("User32.dll", "int", "GetClassName", "hwnd",
$hWnd, "ptr", DllStructGetPtr($stText), "int", $Length)
$Text = DllStructGetData($stText,1)
$stText = 0
return $Text
EndFunc
Move mouse pointer over button to view message box.
You can get content of Button's tooltips. But I found that
WinGetClassList can't return known class name of tooltips.
As you can see script uses other function GetClassName to get class
name of tooltip - 'tooltips_class32'.
Is it bug in AutoIt?
Valery