binarydigit0101 Posted November 11, 2010 Posted November 11, 2010 how are you? i like to do a easy traytip without a control GUi as this: expandcollapse popup;Author: rover 07/04/09 ;MSDN reference: ;Shell_NotifyIcon Function ;http://msdn.microsoft.com/en-us/library/bb762159(VS.85).aspx #include <GUIConstantsEX.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <StaticConstants.au3> Global Const $NIN_BALLOONTIMEOUT = $WM_USER + 4 Global Const $NIN_BALLOONUSERCLICK = $WM_USER + 5 ;Global Const $GWLP_WNDPROC = -4; for SetWindowLongPtr Global $wProcNew = 0, $wProcOld = 0, $iMsg, $iError = 0 ;get handle to AutoIt v3 hidden gui Global $hGUI1 = _AutoItWinGetHandle() ;$hGUI1 = WinGetHandle(AutoItWinGetTitle()) ;will work without GUICreate but global vars must be set in WndProc instead of GUICtrlCreateDummy/GUICtrlSendToDummy ;NOTE: _WinAPI_SetWindowLong() in WinAPI.au3 consistently returns 'The specified procedure could not be found' error 127 ;error is due to the call being SetWindowLong instead of SetWindowLongW, ;using SetWindowLongW the error message is 'The operation completed successfully. Global $hGUI2 = GUICreate("Traytip click detect", 260, 150, @DesktopWidth - 400, @DesktopHeight - 300) Global $cTooltipClose = GUICtrlCreateDummy() Global $cTooltipClick = GUICtrlCreateDummy() Global $cLabel1 = GUICtrlCreateLabel("Traytip area clicked", 70, 80, 120, 16, $SS_CENTER) Global $cLabel2 = GUICtrlCreateLabel("", 10, 110, 240, 16, $SS_CENTER) GUICtrlSetBkColor(-1, 0xFFFFFF) Global $cButton = GUICtrlCreateButton("Create Traytip", 70, 30, 120, 25) GUISetState() ;subclass AutoIt v3 gui to get tray icon/traytip notifications _SubclassWin($hGUI1, $wProcNew, $wProcOld) Global $sLastError = _WinAPI_GetLastErrorMessage() ConsoleWrite('- GetLastErrorMessage ' & $sLastError & "- Error: " & _WinAPI_GetLastError() & @CRLF) ConsoleWrite('+$wProcOld = ' & $wProcOld & @CRLF) GUICtrlSetData($cLabel2, $sLastError) If StringInStr($sLastError, "Access is denied.") <> 0 Then GUICtrlSetBkColor($cLabel2, 0xFF0000) EndIf While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $cButton TrayTip("Clear", "", 1) TrayTip("I'm a title", "I'm the message", 5, 1) Case $cTooltipClick GUICtrlSetData($cLabel2, "") GUICtrlSetColor($cLabel2, 0x0000FF) Sleep(100) GUICtrlSetData($cLabel2, "Tooltip clicked") ConsoleWrite("!NIN_BALLOONUSERCLICK" & @CRLF) Case $cTooltipClose GUICtrlSetData($cLabel2, "") GUICtrlSetColor($cLabel2, 0xFF0000) Sleep(100) GUICtrlSetData($cLabel2, "Tooltip closed") ConsoleWrite("-NIN_BALLOONTIMEOUT" & @CRLF) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _SubclassWin($hWnd, ByRef $hProcNew, ByRef $hProcOld) If $hProcNew <> 0 Or $hProcOld <> 0 Then Return SetError(1, 0, 0) $hProcNew = DllCallbackRegister("_AutoItWndProc", "int", "hwnd;uint;wparam;lparam") If @error Or $hProcNew = 0 Then Return SetError(2, 0, 0) $hProcOld = DllCall("User32.dll", "int", "SetWindowLongW", "hwnd", _ $hWnd, "int", $GWL_WNDPROC, "ptr", DllCallbackGetPtr($hProcNew)) If @error Or $hProcOld[0] = 0 Then $hProcOld = 0 Return SetError(3, 0, 0) EndIf $hProcOld = $hProcOld[0] Return SetError(0, 0, 1) EndFunc;==>_SubclassWin Func _RestoreWndProc($hWnd, ByRef $hProcNew, ByRef $hProcOld) If $hProcOld <> 0 Then _WinAPI_SetWindowLong($hWnd, $GWL_WNDPROC, $hProcOld) If $hProcNew <> 0 Then DllCallbackFree($hProcNew) $hProcNew = 0 $hProcOld = 0 EndFunc;==>_RestoreWndProc Func OnAutoItExit() _RestoreWndProc($hGUI1, $wProcNew, $wProcOld) EndFunc;==>OnAutoItExit Func _AutoItWndProc($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam Switch $iMsg Case $WM_USER + 1;AutoIt callback message value for tray icon (1025), can be retrieved with ReadProcessMemory and TRAYDATA struct Switch $ilParam Case $NIN_BALLOONTIMEOUT; timeout and by tooltip close icon GUICtrlSendToDummy($cTooltipClose) Case $NIN_BALLOONUSERCLICK GUICtrlSendToDummy($cTooltipClick) EndSwitch EndSwitch ; pass the unhandled messages to default WindowProc Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $iMsg, $iwParam, $ilParam) EndFunc;==>_AutoItWndProc ;=============================================================================== ; ; Function Name: _AutoItWinGetHandle ; Description:: Returns the Windowhandle of AutoIT-Window ; Parameter(s): -- ; Requirement(s): -- ; Return Value(s): Autoitwindow Handle ; Author(s): Prog@ndy ; ;=============================================================================== ; Func _AutoItWinGetHandle() Local $oldTitle = AutoItWinGetTitle() Local $x = Random(1248578, 1249780) AutoItWinSetTitle("qwrzu" & $x) Local $x = WinGetHandle("qwrzu" & $x) AutoItWinSetTitle($oldTitle) Return $x EndFunc;==>_AutoItWinGetHandle i'd like remove gui and use only click event and timeout event for the traytip, but i don't know how can i do. i modify Case $NIN_BALLOONTIMEOUT; timeout and by tooltip close icon ;timeout event Case $NIN_BALLOONUSERCLICK ;click event but is really complicated for the gui. can anyone help me? thank you in advance! :-) ehi ehi ehi, what is your name?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now