Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[AHL_L/v2] TT() - Full-blown ToolTip Library


  • Please log in to reply
197 replies to this topic
HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

I've finally finished the new ToolTip Library :)

Note!  You will need latest AutoHotkey or AutoHotkey_H to use these functions.

For AutoHokey TT() requires also _Struct and sizeof and following function:

Struct(Structure,pointer:=0,init:=0){
    return new _Struct(Structure,pointer,init)
} 

In AutoHotkey_H build-in Struct function is used so it has no dependencies and #inlclude <_Struct> can be deleted or commented out.

Thanks to Chris and Lexikos for AHK[_L] and everybody else for helpful posts in forum-

Enjoy ;)
 

Gosub, Example1 ;Simple ToolTip

Gosub, Example2 ;Links in ToolTip

Gosub, Example3 ;ToolTips for Controls

Gosub, Example4 ;ToolTip follows mouse

Gosub, Example5 ;View Icons included in dll

~Esc::ExitApp

;-------------------------------------------------

Example1:
TT:=TT("Icon=1","text","Title") ;create a ToolTip
Loop 50 {
   TT.Show() ;show ToolTip at mouse coordinates
   Sleep, 50
}
TT.Remove() ;delete ToolTip
MsgBox ToolTip Deleted, click ok for next ToolTip example
Return
;-------------------------------------------------

Example2:
TT:=TT("CloseButton OnClick=TT_Msg OnClose=TT_MsgClose"
      ,"<a click>Click Me</a>`n<a Second action>Click Me Too</a>"
      ,"Title (Click close Button to proceed)")
TT.Show()
Exit
TT_Msg(TT,option){
   MsgBox % option
}
TT_MsgClose(TT){
   SetTimer, Example3,-100
}

;-------------------------------------------------

Example3:
TT:=TT("GUI=1")
Gui,Add,Edit,,I'm an Edit Box
TT.Add("Edit1","Edit Control","Center RTL HWND")
Gui,Add,Button,,I'm a Button
TT.Add("Button1","<a>You can't click me :)</a>","PARSELINKS")
Gui,Show
Return
GuiClose:
Gui,Destroy
TT_Remove() ;remove all tooltips
;-------------------------------------------------

Example4:
TT:=TT("ClickTrough Balloon"
      ,""
      ,"ClickTrough activated (Hold Ctrl and clict trough ToolTip)") ;create new tooltip
TT.Color("White","Black")
Loop 100 {
   If !GetKeyState("Ctrl","P")
      TT.Show(A_Hour ":" A_Min ":" A_Sec)
   Sleep 50
}
TT.Remove()
;-------------------------------------------------

Example5:
i:=0
File:="c:\Windows\system32\shell32.dll"
TT:=TT("OnClick=TTmsg OnClose=TTMsgClose CloseButton")
TT.Show("<a>Click Me</a>`nhello there I'm a ToolTip`n`nPress Ctrl & + or Ctrl & - to see icons of:`n" File ;Text
         ,"","" ;x and y coordinates
         ,"ToolTip Title") ;Title
Return
^+::
^-::
If A_ThisHotkey=^+
   i++
else
   i--
TT.Show("You are currently watching icons in`n<a>" File "</a>`n<a newFile>>>> Select another file</a>"
      ,"",""
      ,"Icon Number: " i
      ,File,i) ;iconFile and icon index
Return
TTMsg(TT,key){
   global File
   If key=
      ExitApp
   else if key=newFile
      FileSelectFile,File,,%A_WinDir%\system32\,Select a file,*.dll;*.exe;*.*
   else if key=Click Me
      MsgBox % key
   else
      Run % "explorer.exe /e,/n,/select," key
}
TTMsgClose(TT){
   ExitApp
}
Return

- Update -

03.09.2015 - Update Delay parameters
02.09.2012 - Updated to use Struct() instead of new _Struct(), changed OnClick,OnShow,OnClose to use object as first parameter. Updated example
01.04.2012 - Fix setting text in structure when no text given
02.03.2012 - Fix for v2 31++
18.02.2012 - V2 version.
03.01.2012 - Fixed positioning of ToolTip when using .Show() without x/y parameters.
09.02.2011 - added Font support, thanks majkinetor
05.02.2011 - x64 support
02.12.2010 - Updated TT_GetIcon to recevie hIcon from png, jpg, gif and even hex string (IconIndex must be empty string to use those "")
- Many thanks to Sean and SKAN -> How to convert image data
24.11.2010 - Changed .Hide() to use TTM_TrackPosition()



Big Digger
  • Members
  • 46 posts
  • Last active: Jul 23 2017 04:06 PM
  • Joined: 07 Feb 2009
Thanks. You forgot to notify about required Struct() function.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Thank you, I have added above.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Updated TT_GetIcon(), now icon can be a png, jpg, gif... or even a hex string.
TT:=TT(),TT.Show("Hello World!","","","I'm a ToolTip","MyPng.png",[color=red]""[/color]) ;IconIndex must be "" here.

Esc::ExitApp


Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
Hello HotKeyIt,

I haven't tried it yet, but it looks very nice. :)
Could you specify the license for TT() please.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
HotKeyIt's default license ;)

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Is this compatible with the 64bit version of AHK_L? I've noticed that ToolTip() crashes, so I'm wondering if 64bit is supported here.

Edit: I just took a quick look at the source and found multiple occassions where handles are used in DllCalls with UInt type. To my knowledge all handles need to have a PTR type in 64bit builds. Are you going to add 64bit support anytime soon?

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Thanks for reporting, can you try again now.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Thanks, I will do so tomorrow.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
I just tried the example, and AHK_L Unicode x64 crashes immediately on script startup, even when I put a msgbox as first line.
I put Struct.ahk and TT.ahk in lib directory, but including them in the demo has the same effect.

Edit: One more test, if I include Struct.ahk or TT.ahk (same directory as demo script) it already crashes, even if the demo script only contains one of those lines.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Right, thanks for testing.

Crash problem relates to Struct lowlevel (__getvar) which is not compatible with x64.
Can you try with this modified version: Struct64.ahk

Second problem might be due to Session 0 Isolation

Remarks

As part of the Vista re-architecture, all services were moved off the interactive desktop into Session 0. hwnd and window manager operations are only effective inside a session and cross-session attempts to manipulate the hwnd will fail. For more information, see The Windows Vista Developer Story: Application Compatibility Cookbook.


Anyway, can you try now and report back ;)

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Now it does not crash, but it's not showing a tooltip either.
Using the demo file above, I first see a message box saying "Tooltip deleted, click ok for the next example.", and then nothing happens, and the last executed line is line 31, "Exit". I think it's still waiting for the close action to happen, but I can't press the button since I don't see the tooltip.

How are the sessions related to this topic? Is anything running as a service or system process? It works fine in Win7 32bit btw.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Any progress on this?

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
I am not sure what is wrong, all I can see is that SetWindowPos returns "invalid handle" error, CreateWindowEx seems to work fine :?
Can you have a look whether BallonTip() or ToolTip() work?

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
I will do so when I find some time (e.g. start of the week probably).

I assume you're passing the hwnd as "PTR"?