Jump to content

OnEvent for traytip() [SOLVED]


Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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()
Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...