Roshith Posted April 14, 2011 Share Posted April 14, 2011 Hi, I was researching on how to identify click on baloon popup caused by TrayTip(), but no solution. TrayGetMsg returns value only if a click event occurs on the tray icon. Is there any way to get the mouse click on the message baloon poped by the function TrayTip() Thanks in advance Roshith Link to comment Share on other sites More sharing options...
wakillon Posted April 14, 2011 Share Posted April 14, 2011 (edited) See This rover named "Detect click on TrayTip" ! Edited April 14, 2011 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Roshith Posted April 15, 2011 Author Share Posted April 15, 2011 Thanks Wakillon, That almost serves the purpose. But is there anyway to differentiate the click on the message and on the X (close) mark? Sorry if I'm a headache.. Link to comment Share on other sites More sharing options...
wakillon Posted April 15, 2011 Share Posted April 15, 2011 Thanks Wakillon, That almost serves the purpose. But is there anyway to differentiate the click on the message and on the X (close) mark? Sorry if I'm a headache.. In the rover example, if you click on traytip, console give a !NIN_BALLOONUSERCLICKand if you click on the X, console give -NIN_BALLOONTIMEOUT. AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Roshith Posted April 15, 2011 Author Share Posted April 15, 2011 Thanks so much.. Actually i did not see the complete rover script. Just saw the function _AutoItWinGetHandle(). My mistake.. Thanks a lot for the help!! Link to comment Share on other sites More sharing options...
Roshith Posted April 25, 2011 Author Share Posted April 25, 2011 Hi Wakillon, I modified Rover's script removing the GUI. Its working well. But even after the script exits, the AutoIt process still runs without exiting. I think there there is some dll issue. Can you please help me. I'm attaching the code Thanks in advance Roshithexpandcollapse popup#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 $wProcNew = 0, $wProcOld = 0, $iMsg, $iError = 0 Global $hGUI1 = _AutoItWinGetHandle() $hProcNew = DllCallbackRegister("_AutoItWndProc", "int", "hwnd;uint;wparam;lparam") $hProcOld = DllCall("User32.dll", "int", "SetWindowLongW", "hwnd", $hGUI1, "int", $GWL_WNDPROC, "ptr", DllCallbackGetPtr($hProcNew)) $hProcOld = $hProcOld[0] TrayTip("I'm a title", "I'm the message", 5, 1) $iTimer = TimerInit() While TimerDiff($iTimer) < 5000 Sleep(10) 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) 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 MsgBox(0,"","close") Case $NIN_BALLOONUSERCLICK MsgBox(0,"","click") 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 25, 2011 Share Posted April 25, 2011 (edited) Add this: OnAutoItExitRegister("OnAutoItExit") You have the function, but I don't see you registering it with OnAutoItExitRegister(). P.S. I don't see where the script ever exits either. Edited April 25, 2011 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Roshith Posted April 25, 2011 Author Share Posted April 25, 2011 I just tried that. But no progress Link to comment Share on other sites More sharing options...
Roshith Posted April 25, 2011 Author Share Posted April 25, 2011 The script exists from once it comes out of the 'while' loop. i.e. when the timer expires Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 26, 2011 Share Posted April 26, 2011 Oops, missed the timer exiting your only main loop. This works fine: OnAutoItExitRegister("OnAutoItExit") TrayTip("I'm a title", "I'm the message", 5, 1) $iTimer = TimerInit() While TimerDiff($iTimer) < 5000 Sleep(10) WEnd Func OnAutoItExit() ConsoleWrite("OnAutoItExit() @ExitCode = " & @exitCode & " @ExitMethod = " & @exitMethod & @LF ) EndFunc So the call to OnAutoItExit() should be made. Since you are messing with the AutoIt script's own window processing I guess you might be in a loop of callbacks. Add a ConsoleWrite() to each of your handler functions so you can see when they are called. For example: Func _AutoItWndProc($hWnd, $iMsg, $iwParam, $ilParam) ConsoleWrite("Debug: _AutoItWndProc(" & $hWnd & ", " & $iMsg & ", " & $iwParam & ", " & $ilParam & ")" & @LF) ; ... EndFunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
wakillon Posted April 26, 2011 Share Posted April 26, 2011 You need to use DllCallbackFree, else script do not exit ! expandcollapse popup#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 $wProcNew = 0, $wProcOld = 0, $iMsg, $iError = 0 Global $hGUI1 = _AutoItWinGetHandle() $hProcNew = DllCallbackRegister("_AutoItWndProc", "int", "hwnd;uint;wparam;lparam") $hProcOld = DllCall("User32.dll", "int", "SetWindowLongW", "hwnd", $hGUI1, "int", $GWL_WNDPROC, "ptr", DllCallbackGetPtr($hProcNew)) $hProcOld = $hProcOld[0] TrayTip("I'm a title", "I'm the message", 5, 1) $iTimer = TimerInit() While 1 If TimerDiff($iTimer) > 5000 Then DllCallbackFree ( $hProcNew ) Exit EndIf Sleep ( 10 ) 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) 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 MsgBox(0,"","close") Case $NIN_BALLOONUSERCLICK MsgBox(0,"","click") 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 AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Roshith Posted April 26, 2011 Author Share Posted April 26, 2011 I've already tried adding dllcallbackfree(). But that time, once the it comes out of the loop, I get the attached error. Then I tried removing Dllcallbackfree(), then the script does not exit once it comes out of the loop (icon goes of from the tray, but 'AutoIt' process runs in the background) Roshith Link to comment Share on other sites More sharing options...
Roshith Posted April 26, 2011 Author Share Posted April 26, 2011 D:\Users\501850295\Desktop\DllcallbackfreeError.jpjError Link to comment Share on other sites More sharing options...
Roshith Posted April 26, 2011 Author Share Posted April 26, 2011 D:\Users\501850295\Desktop\DllcallbackfreeError.jpgSorry, this is the error I get Link to comment Share on other sites More sharing options...
Roshith Posted April 27, 2011 Author Share Posted April 27, 2011 Found the solution. Below code works well 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 $cTooltipClose = GUICtrlCreateDummy() Global $cTooltipClick = GUICtrlCreateDummy() TrayTip("Clear", "", 1) TrayTip("I'm a title", "I'm the message", 5, 1) GUISwitch($hGUI1) _SubclassWin($hGUI1, $wProcNew, $wProcOld) $iTimer = TimerInit() While TimerDiff($iTimer) < 5000 Sleep(10) 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 MsgBox(0,$NIN_BALLOONTIMEOUT,"close") ;GUICtrlSendToDummy($cTooltipClose) Case $NIN_BALLOONUSERCLICK MsgBox(0,$NIN_BALLOONUSERCLICK,"clicked") ;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 Link to comment Share on other sites More sharing options...
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