AutoHotkey Community

It is currently May 25th, 2012, 5:56 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 66 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
 Post subject: BalloonTip
PostPosted: May 23rd, 2007, 6:52 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
This script creates a balloon tip, borrowed from the script Color Zoomer/Picker.

DOWNLOAD BalloonTip.ahk.


Last edited by Sean on August 22nd, 2007, 7:28 am, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 7:56 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 8:18 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 9:07 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Its not that hard to make icon change its.

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


Thx Sean.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 9:43 am 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 10:05 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 10:19 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 10:29 am 
Sean wrote:
OK, I added comments.
Thanks! :-D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 11:35 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 12:05 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
None of the scripts work here.

Hwnd returned by CreateWindowEx is valid.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 12:48 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 12:57 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
It works on other computer like it is. It doesn't work on my own.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 1:14 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 1:51 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
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

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 23rd, 2007, 2:16 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 66 posts ]  Go to page 1, 2, 3, 4, 5  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group