t2d2c2 Posted May 14, 2014 Share Posted May 14, 2014 expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <WinAPI.au3> Opt('GUIOnEventMode', 1) Opt('TrayOnEventMode', 1) Opt("TrayMenuMode",1) TraySetClick(8) $exititem = TrayCreateItem("Exit") Global Const $IDANI_OPEN = 1 Global Const $IDANI_CAPTION = 3 Global $hGUI = GUICreate('Test', 200, 200) Global $fMinimized = False Global $hTray = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', 'TrayNotifyWnd1') TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, '_Restore') ; TraySetClick(16) GUISetOnEvent($GUI_EVENT_CLOSE, '_Minimize') GUISetState() While 1 Switch TrayGetMsg() Case $exititem Exit EndSwitch WEnd Func _Minimize() Local $tRcFrom , $tRcTo If Not $fMinimized Then $tRcFrom = _WinAPI_GetWindowRect($hGUI) $tRcTo = _WinAPI_GetWindowRect($hTray) _WinAPI_DrawAnimatedRects($hGUI, $IDANI_CAPTION, DllStructGetPtr($tRcFrom), DllStructGetPtr($tRcTo)) GUISetState(@SW_HIDE) $fMinimized = True EndIf EndFunc Func _Restore() If $fMinimized Then $tRcFrom = _WinAPI_GetWindowRect($hTray) $tRcTo = _WinAPI_GetWindowRect($hGUI) _WinAPI_DrawAnimatedRects($hGUI, $IDANI_CAPTION, DllStructGetPtr($tRcFrom), DllStructGetPtr($tRcTo)) GUISetState(@SW_SHOW) $fMinimized = False EndIf EndFunc Func _WinAPI_DrawAnimatedRects($hWnd, $iAnim, $pRectFrom, $pRectTo) Local $aResult $aResult = DllCall('user32.dll', 'int', 'DrawAnimatedRects', 'hwnd', $hWnd, 'int', $iAnim, 'ptr', $pRectFrom, 'ptr', $pRectTo) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc This is my code, when click (x) button on GUI --> HIDE GUI When left click on trayicon --> SHOW GUI When right click on trayicon --> show tray menu --> BUT click on tray menu item --> don't working Help me fixed it Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 14, 2014 Moderators Share Posted May 14, 2014 t2d2c2, please do not PM forum members asking for help. This is not a 24 hour support forum; please wait 24 hours after posting an issue to give others time to respond. Then you can bump the issue if you are still having trouble. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
t2d2c2 Posted May 15, 2014 Author Share Posted May 15, 2014 still nobody view and help, sorry to bother, good luck Link to comment Share on other sites More sharing options...
dmob Posted May 16, 2014 Share Posted May 16, 2014 You forgot: TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN, 'Func') ? Link to comment Share on other sites More sharing options...
t2d2c2 Posted May 17, 2014 Author Share Posted May 17, 2014 You forgot: TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN, 'Func') ? No, right click on trayicon, show menu tray OK, but when click on item on meutray --> NOT DETECT click on item Link to comment Share on other sites More sharing options...
dmob Posted May 17, 2014 Share Posted May 17, 2014 expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <WinAPI.au3> Opt('GUIOnEventMode', 1) Opt('TrayOnEventMode', 1) Opt("TrayMenuMode",3) TraySetClick(8) $exititem = TrayCreateItem("Exit") Global Const $IDANI_OPEN = 1 Global Const $IDANI_CAPTION = 3 Global $hGUI = GUICreate('Test', 200, 200) Global $fMinimized = False Global $hTray = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', 'TrayNotifyWnd1') TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, '_Restore') TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN, '_Exit') ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< add this ; TraySetClick(16) GUISetOnEvent($GUI_EVENT_CLOSE, '_Minimize') GUISetState() While 1 Switch TrayGetMsg() Case $exititem _Exit() EndSwitch WEnd Func _Exit() Exit EndFunc Func _Minimize() Local $tRcFrom , $tRcTo If Not $fMinimized Then $tRcFrom = _WinAPI_GetWindowRect($hGUI) $tRcTo = _WinAPI_GetWindowRect($hTray) _WinAPI_DrawAnimatedRects($hGUI, $IDANI_CAPTION, DllStructGetPtr($tRcFrom), DllStructGetPtr($tRcTo)) GUISetState(@SW_HIDE) $fMinimized = True EndIf EndFunc Func _Restore() If $fMinimized Then $tRcFrom = _WinAPI_GetWindowRect($hTray) $tRcTo = _WinAPI_GetWindowRect($hGUI) _WinAPI_DrawAnimatedRects($hGUI, $IDANI_CAPTION, DllStructGetPtr($tRcFrom), DllStructGetPtr($tRcTo)) GUISetState(@SW_SHOW) $fMinimized = False EndIf EndFunc Func _WinAPI_DrawAnimatedRects($hWnd, $iAnim, $pRectFrom, $pRectTo) Local $aResult $aResult = DllCall('user32.dll', 'int', 'DrawAnimatedRects', 'hwnd', $hWnd, 'int', $iAnim, 'ptr', $pRectFrom, 'ptr', $pRectTo) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc Link to comment Share on other sites More sharing options...
t2d2c2 Posted May 17, 2014 Author Share Posted May 17, 2014 expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <WinAPI.au3> Opt('GUIOnEventMode', 1) Opt('TrayOnEventMode', 1) Opt("TrayMenuMode",3) TraySetClick(8) $exititem = TrayCreateItem("Exit") Global Const $IDANI_OPEN = 1 Global Const $IDANI_CAPTION = 3 Global $hGUI = GUICreate('Test', 200, 200) Global $fMinimized = False Global $hTray = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', 'TrayNotifyWnd1') TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, '_Restore') TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN, '_Exit') ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< add this ; TraySetClick(16) GUISetOnEvent($GUI_EVENT_CLOSE, '_Minimize') GUISetState() While 1 Switch TrayGetMsg() Case $exititem _Exit() EndSwitch WEnd Func _Exit() Exit EndFunc Func _Minimize() Local $tRcFrom , $tRcTo If Not $fMinimized Then $tRcFrom = _WinAPI_GetWindowRect($hGUI) $tRcTo = _WinAPI_GetWindowRect($hTray) _WinAPI_DrawAnimatedRects($hGUI, $IDANI_CAPTION, DllStructGetPtr($tRcFrom), DllStructGetPtr($tRcTo)) GUISetState(@SW_HIDE) $fMinimized = True EndIf EndFunc Func _Restore() If $fMinimized Then $tRcFrom = _WinAPI_GetWindowRect($hTray) $tRcTo = _WinAPI_GetWindowRect($hGUI) _WinAPI_DrawAnimatedRects($hGUI, $IDANI_CAPTION, DllStructGetPtr($tRcFrom), DllStructGetPtr($tRcTo)) GUISetState(@SW_SHOW) $fMinimized = False EndIf EndFunc Func _WinAPI_DrawAnimatedRects($hWnd, $iAnim, $pRectFrom, $pRectTo) Local $aResult $aResult = DllCall('user32.dll', 'int', 'DrawAnimatedRects', 'hwnd', $hWnd, 'int', $iAnim, 'ptr', $pRectFrom, 'ptr', $pRectTo) If @error Then Return SetError(1, 0, 0) Return $aResult[0] EndFunc No, now when right click on menutray, and not click "Exit" item, but GUI is closed Link to comment Share on other sites More sharing options...
Developers Solution Jos Posted May 17, 2014 Developers Solution Share Posted May 17, 2014 Try: TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, '_Restore') ;~ TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN, '_Exit') ;< remove TrayItemSetOnEvent($exititem, '_Exit') ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< add this Jos t2d2c2 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
t2d2c2 Posted May 18, 2014 Author Share Posted May 18, 2014 Try: TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, '_Restore') ;~ TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN, '_Exit') ;< remove TrayItemSetOnEvent($exititem, '_Exit') ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< add this Jos Oh oh, it's wokring, thank you very much 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