Jump to content
Sign in to follow this  
okdewit

OnEvent for traytip() [SOLVED]

Recommended Posts

okdewit

Simple question:

Is there a way to run a function when the user clicks on the traytip I created?

I want the effect of a traytip that says: "Don't forget to configure this app", or "Some event happened with this app!", and when the user clicks on the balloon he is taken to that specific part of my program.

Is that possible!

Thanks!

Edited by okdewit

Share this post


Link to post
Share on other sites
rasim

This is a trick:

#include <Misc.au3>

HotKeySet("{Pause}", "_Exit")

$wClass = "[Class:tooltips_class32]"

$DllHandle = DllOpen("user32.dll")

AdlibEnable("_CheckTip")

TrayTip("Tip Title", "Some Text", 10, 1)

While 1
    Sleep(100)
WEnd

Func _CheckTip()
    If WinExists($wClass) And _IsPressed("01", $DllHandle) Then
        $aWinPos = WinGetPos($wClass)
        $aMousePos = MouseGetPos()
        
        If ($aMousePos[0] >= $aWinPos[0]) And ($aMousePos[0] <= $aWinPos[0] + $aWinPos[2]) And _
            ($aMousePos[1] >= $aWinPos[1]) And ($aMousePos[1] <= $aWinPos[1] + $aWinPos[3]) Then ConsoleWrite("Tip checked" & @LF)
    EndIf
EndFunc

Func _Exit()
    DllClose($DllHandle)
    Exit
EndFunc
Edited by rasim

Share this post


Link to post
Share on other sites
okdewit

Thanks for the quick response!

Great idea, didn't know I could do it that way. There seems to be one problem though:

It only works in about 50% of the cases. It seems that when I click "lightly" it does not work, only on a slightly "longer" click. Sometimes it even runs multiple times when I click only once.

So thanks for the code, it is enlightening, but not sufficient for my program. I'm going to try to get it to work without the adlib.

Thanks a lot for getting me started again :)

EDIT:

Why doesn't this work?

#include <Misc.au3>
#include <GUIConstants.au3>

HotKeySet("{Pause}", "_Exit")
Opt("GUIOnEventMode",1)

$wClass = "[Class:tooltips_class32]"

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"_Function",WinGetHandle($wClass))

TrayTip("Tip Title", "Some Text", 10, 1)

While 1
    Sleep(100)
WEnd

Func _Function()
    ConsoleWrite("Click" & @LF)
EndFunc

Func _Exit()
    Exit
EndFunc
Edited by okdewit

Share this post


Link to post
Share on other sites
rasim

okdewit

It only works in about 50% of the cases.

Try this:

#include <Misc.au3>

HotKeySet("{Pause}", "_Exit")

$wClass = "[Class:tooltips_class32]"

$DllHandle = DllOpen("user32.dll")

AdlibEnable("_CheckTip", 10)

TrayTip("Tip Title", "Some Text", 10, 1)

While 1
    Sleep(100)
WEnd

Func _CheckTip()
    If WinExists($wClass) And _IsPressed("01", $DllHandle) Then
        $aWinPos = WinGetPos($wClass)
        $aMousePos = MouseGetPos()
        
        If ($aMousePos[0] >= $aWinPos[0]) And ($aMousePos[0] <= $aWinPos[0] + $aWinPos[2]) And _
            ($aMousePos[1] >= $aWinPos[1]) And ($aMousePos[1] <= $aWinPos[1] + $aWinPos[3]) Then
            AdlibDisable()
            ConsoleWrite("Tip checked" & @LF)
        EndIf
    EndIf
EndFunc

Func _Exit()
    DllClose($DllHandle)
    Exit
EndFunc

Why doesn't this work?

You can not use a GUISetOnEvent() for windows which not created via AutoIt e.g. GuiCreate()

Share this post


Link to post
Share on other sites
okdewit

You can not use a GUISetOnEvent() for windows which not created via AutoIt e.g. GuiCreate()

That seems logical.

Thanks a lot for the updated code!

Share this post


Link to post
Share on other sites
ProgAndy

As extension for ModernMenu, you can use the WINAPI messages to get the click:

http://www.autoitscript.com/forum/index.ph...mp;#entry525720


*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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.