AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

BalloonTip
Goto page 1, 2, 3, 4, 5  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Wed May 23, 2007 5:52 am    Post subject: BalloonTip Reply with quote

This script creates a balloon tip, borrowed from the script Color Zoomer/Picker.

DOWNLOAD BalloonTip.ahk.


Last edited by Sean on Wed Aug 22, 2007 6:28 am; edited 3 times in total
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3910
Location: Bremen, Germany

PostPosted: Wed May 23, 2007 6:56 am    Post subject: Reply with quote

Thanks for this great function.
Could the CoordMode and DetectHiddenWindow command be included into the function? So that it could just be included (from a library) and called with the function? At least A_DetectHiddenWindows could be used to set the status back to its initial state for DetectHiddenWindows.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
toralf



Joined: 31 Jan 2005
Posts: 3910
Location: Bremen, Germany

PostPosted: Wed May 23, 2007 7:18 am    Post subject: Reply with quote

I tested your script.
It shows a ballontip at mouse pointer with the color under the mouse pointer as its background color. This looks very nice when the mouse it on white background. But when I move the mouse on blue it doesn't look that nice. It seems that all the lines with "ncolor" influence the color. Could you please add comments to the function, so it is easier for other to modify it to their needs?
The script has one quirk, i can't close the ballontip. I have to kill the process by its tray icon.

On a side note: AHK already has a ballontip for the tray menu
Code:
TrayTip, AHK, This is a BalloonTip Test.,,1


Open questions:
How could I specify a different icon?
How could I define a timeout period?

Here is what I've got so far:
Code:
TrayTip, AHK, This is a BalloonTip Test.,  ,1

BalloonTip("This is a BalloonTip Test.", 10 ,10)

Sleep, 20000
ExitApp

BalloonTip(sText, xpos, ypos, sTitle = "AHK", hBGRcolor="") {
    Old_DetectHiddenWindows := A_DetectHiddenWindows
    DetectHiddenWindows, On
    hWnd := DllCall("CreateWindowEx", "Uint", 0x8, "str", "tooltips_class32", "Uint", 0, "Uint", 0xC3, "int", 0, "int", 0, "int", 0, "int", 0, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0)
    VarSetCapacity(ti, 40, 0)
    ti := Chr(40)
    DllCall("ntdll\RtlFillMemoryUlong", "Uint", &ti + 4, "Uint", 4, "Uint", 0x20)
    DllCall("ntdll\RtlFillMemoryUlong", "Uint", &ti +36, "Uint", 4, "Uint", &sText)
    SendMessage, 1028, 0, &ti,, ahk_id %hWnd%
    SendMessage, 1041, 1, &ti,, ahk_id %hWnd%
    SendMessage, 1042, 0, xpos | ypos << 16,, ahk_id %hWnd%
    If hBGRcolor {
        SendMessage, 1043, hBGRcolor, 0,, ahk_id %hWnd%
        SendMessage, 1044,~hBGRcolor & 0xFFFFFF, 0,, ahk_id %hWnd%
      }
    SendMessage, 1056, 1, &sTitle,, ahk_id %hWnd%
    SendMessage, 1036, 0, &ti,, ahk_id %hWnd%
    DetectHiddenWindows, %Old_DetectHiddenWindows%
  }

_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 4511
Location: Belgrade

PostPosted: Wed May 23, 2007 8:07 am    Post subject: Reply with quote

Its not that hard to make icon change its.

Yesterday in A4H forum somebody posted full Delphi code for this.


Thx Sean.
_________________
Back to top
View user's profile Send private message
Grumpy
Guest





PostPosted: Wed May 23, 2007 8:43 am    Post subject: Reply with quote

It is indeed nice, but on the lazy side, with lot of numerical, uncommented Windows messages. It is easy to find a message number with its name, the reverse is much harder...
And why the ballon doesn't close when we click on the cross? Does it need some kind of callback or notification not handled by AHK?
Back to top
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Wed May 23, 2007 9:05 am    Post subject: Reply with quote

Grumpy wrote:
It is indeed nice, but on the lazy side, with lot of numerical, uncommented Windows messages. It is easy to find a message number with its name, the reverse is much harder...

OK, I added comments.

Quote:
And why the ballon doesn't close when we click on the cross? Does it need some kind of callback or notification not handled by AHK?

I don't really know why. I guess AHK doesn't have message handling with tooltips.

As a matter of fact, clicking the (fake) close button is supposed to hide (:not close) the balloon, and used to work as expected in other application.

PS. Experiment this.
After clicking the close button, right-click the tray icon of the script.
You'll see the balloon is closed, more precisely hiden.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Wed May 23, 2007 9:19 am    Post subject: Reply with quote

toralf wrote:
Open questions:
How could I specify a different icon?
How could I define a timeout period?

I added a comment about it in the script.
One interesting point is that we can even use a custom icon with the balloon.

AFAIK, there is no way to specify the timeout with a balloon/tooltip.
This is one of the difference with AHK's TrayTip.
TrayTip is created via Shell_NotifyIcon API and this function has a timeout field of the balloon in NOTIFYICONDATA structure.

I may add a hotkey to close the balloon later if I can't find more elegant method.
Back to top
View user's profile Send private message
Grumpy
Guest





PostPosted: Wed May 23, 2007 9:29 am    Post subject: Reply with quote

Sean wrote:
OK, I added comments.
Thanks! Very Happy
Back to top
toralf



Joined: 31 Jan 2005
Posts: 3910
Location: Bremen, Germany

PostPosted: Wed May 23, 2007 10:35 am    Post subject: Reply with quote

Created a mod again, with several optional parameter. Timeout is added too.

Code:
#Persistent
BalloonTip("This is a BalloonTip Test.")
BalloonTip("Second BalloonTip Test.", "Toralf", 100, "", 2, 3000 , "Position")
MsgBox, 0,Ballon Test,wait,6
ExitApp
Return

BalloonTip(sText                   ; text of balloon tip
         , sTitle = "AutoHotkey"   ; title of balloon tip
         , xpos=""                 ; x position, "": mouse x position
         , ypos=""                 ; y position, "": mouse y position
         , hIcon="1"               ; icon of ballon tip, 0: None, 1:Info, 2: Warning, 3: Error. n > 3: assumed to be an hIcon
         , iTimeout = "0"          ; timeout in milliseconds for balloon tip, 0: no timeout
         , nColor="")              ; BGR color for background, text uses compliment color, "Position": color at xpos/ypos
          {
   static hWnd
   hWnd := DllCall("CreateWindowEx", "Uint", 0x8, "str", "tooltips_class32", "str", "", "Uint", 0xC3, "int", 0, "int", 0, "int", 0, "int", 0, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0)

   VarSetCapacity(ti, 40, 0)
   ti := Chr(40)
   DllCall("ntdll\RtlFillMemoryUlong", "Uint", &ti + 4, "Uint", 4, "Uint", 0x20)   ; TTF_TRACK
   DllCall("ntdll\RtlFillMemoryUlong", "Uint", &ti +36, "Uint", 4, "Uint", &sText)

   DllCall("GetCursorPos", "int64P", pt)
   If !xpos
       xpos := pt << 32 >> 32            ; can be negative
   If !ypos
       ypos := pt       >> 32            ; can be negative

   If (nColor = "Position"){
       hDC_Scr := DllCall("GetDC", "Uint", 0)
       nColor  := DllCall("GetPixel", "Uint", hDC_Scr, "int", xpos, "int", ypos)
       DllCall("ReleaseDC", "Uint",0, "Uint", hDC_Scr)
     }

   _DetectHiddenWindows_ := A_DetectHiddenWindows
   DetectHiddenWindows, On
   SendMessage, 1028, 0, &ti,, ahk_id %hWnd%      ; TTM_ADDTOOL
   SendMessage, 1041, 1, &ti,, ahk_id %hWnd%      ; TTM_TRACKACTIVATE
   SendMessage, 1042, 0, (xpos & 0xFFFF)|(ypos & 0xFFFF)<<16,, ahk_id %hWnd%   ; TTM_TRACKPOSITION
   If (nColor <> ""){
       SendMessage, 1043, nColor, 0,, ahk_id %hWnd%      ; TTM_SETTIPBKCOLOR
       SendMessage, 1044,~nColor & 0xFFFFFF, 0,, ahk_id %hWnd%   ; TTM_SETTIPTEXTCOLOR
     }
   SendMessage, 1056, hIcon, &sTitle,, ahk_id %hWnd%      ; TTM_SETTITLE   ; 0: None, 1:Info, 2: Warning, 3: Error. n > 3: assumed to be an hIcon.
   SendMessage, 1036, 0, &ti,, ahk_id %hWnd%      ; TTM_UPDATETIPTEXT
   DetectHiddenWindows, %_DetectHiddenWindows_%
   
   If iTimeOut
      SetTimer, BalloonTip_TimeOut, %iTimeOut%
   Return
   
   BalloonTip_TimeOut:
      SetTimer, BalloonTip_TimeOut, Off
      WinClose, ahk_id %hWnd%
   Return
}

_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 4511
Location: Belgrade

PostPosted: Wed May 23, 2007 11:05 am    Post subject: Reply with quote

None of the scripts work here.

Hwnd returned by CreateWindowEx is valid.
_________________
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Wed May 23, 2007 11:48 am    Post subject: Reply with quote

majkinetor wrote:
None of the scripts work here.

How did you test it? Just copy as it is and execute it?
Looks like the balloon window doesn't become active/visible.
Make sure that the text isn't blank.
Or, did you happen to hook messages?
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 4511
Location: Belgrade

PostPosted: Wed May 23, 2007 11:57 am    Post subject: Reply with quote

It works on other computer like it is. It doesn't work on my own.
_________________
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Wed May 23, 2007 12:14 pm    Post subject: Reply with quote

majkinetor wrote:
It works on other computer like it is. It doesn't work on my own.

Could you test Color Zoomer/Picker script linked at the top of the post?
It doesn't work either?
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 4511
Location: Belgrade

PostPosted: Wed May 23, 2007 12:51 pm    Post subject: Reply with quote

I did that already. Didn't see any ballon.


I also disabled ObjectDesktop I am using - DesktopX & ObjectBar, but nothing changed.

Using XP SP1 + updates
_________________
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Wed May 23, 2007 1:16 pm    Post subject: Reply with quote

majkinetor wrote:
Using XP SP1 + updates

Then, I can't really tell what's going on here as I can't access XPSP1.
There may be some quirk with comctl32.dll version 6 in XPSP1.
But, there is something I simplified than the documentation.

Try to replace CreateWindowEx with the following:

Code:
hWnd := DllCall("CreateWindowEx", "Uint", 0x8, "str", "tooltips_class32", "Uint", 0, "Uint", 0xC3, "int", 0x80000000, "int", 0x80000000, "int", 0x80000000, "int", 0x80000000, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0)


If still doesn't work, try to add the following after TTM_ADDTOOL:

Code:
   SendMessage, 1048, 0, A_ScreenWidth,, ahk_id %hWnd%   ; TTM_SETMAXTIPWIDTH
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2, 3, 4, 5  Next
Page 1 of 5

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group