vladedoty Posted July 14, 2009 Share Posted July 14, 2009 (edited) I'm trying to minimize my autoit program to the system tray after clicking the Hide button. I then want a menu of "About", "Restore", and "Close Program" in the system tray icon. I then need restore to bring the window back up, and close program to close the program.How would i do this?P.S. I've tried all the examples in here and none of them work.the hide button variable name is: $HideBtn Edited July 14, 2009 by vladedoty Link to comment Share on other sites More sharing options...
Yashied Posted July 14, 2009 Share Posted July 14, 2009 I'm trying to minimize my autoit program to the system tray after clicking the Hide button. I then want a menu of "About", "Restore", and "Close Program" in the system tray icon. I then need restore to bring the window back up, and close program to close the program. How would i do this? P.S. I've tried all the examples in here and none of them work. the hide button variable name is: $HideBtnThe name of function to minimize window is: _MinimizeFnc() My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
vladedoty Posted July 15, 2009 Author Share Posted July 15, 2009 The name of function to minimize window is: _MinimizeFnc() And where do I find this function at? Link to comment Share on other sites More sharing options...
Authenticity Posted July 15, 2009 Share Posted July 15, 2009 Heh, I guess it was a sarcasm Have a look please: expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <WinAPI.au3> Opt('GUIOnEventMode', 1) Opt('TrayOnEventMode', 1) Global Const $IDANI_OPEN = 1 Global Const $IDANI_CAPTION = 3 Global $hGUI = GUICreate('Test', 100, 200) Global $fMinimized = False Global $hTray = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', 'TrayNotifyWnd1') TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, '_Restore') TraySetClick(16) GUISetOnEvent($GUI_EVENT_CLOSE, '_Minimize') GUISetState() While 1 Sleep(100) 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 Link to comment Share on other sites More sharing options...
vladedoty Posted July 15, 2009 Author Share Posted July 15, 2009 Heh, I guess it was a sarcasm Have a look please: expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <WinAPI.au3> Opt('GUIOnEventMode', 1) Opt('TrayOnEventMode', 1) Global Const $IDANI_OPEN = 1 Global Const $IDANI_CAPTION = 3 Global $hGUI = GUICreate('Test', 100, 200) Global $fMinimized = False Global $hTray = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', 'TrayNotifyWnd1') TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, '_Restore') TraySetClick(16) GUISetOnEvent($GUI_EVENT_CLOSE, '_Minimize') GUISetState() While 1 Sleep(100) 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 so where would i have the hide button in this code? Link to comment Share on other sites More sharing options...
Authenticity Posted July 15, 2009 Share Posted July 15, 2009 Basically what you need to achieve to minimize to tray is the animation. You decide whether upon clicking the close (x button) or the minimize button or to show or hide the window. All that this script does it to retrieve the two rectangles required for the _WinAPI_DrawAnimatedRects() function. You can do something like, but it won't run just like that: Global $fMinimized = False Global $hGUI, $HideBtn $hGUI = GUICreate('Application', 400, 360) $HideBtn = GUICtrlCreateButton('Minimize', 10, 20, 70, 23) ; ... While 1 Switch GUIGetMsg() Case $HideBtn _TrayAnimator() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _TrayAnimator() Local $tRcFrom , $tRcTo 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 Else $tRcFrom = _WinAPI_GetWindowRect($hGUI) $tRcTo = _WinAPI_GetWindowRect($hTray) _WinAPI_DrawAnimatedRects($hGUI, $IDANI_CAPTION, DllStructGetPtr($tRcFrom), DllStructGetPtr($tRcTo)) GUISetState(@SW_HIDE) $fMinimized = True EndIf EndFunc Link to comment Share on other sites More sharing options...
Rawox Posted July 15, 2009 Share Posted July 15, 2009 If you just want to hide it. Just use GUISetState ( @SW_HIDE ) Be sure the icon is visible! And create a trayitem with something like "open" And if that trayitem is clicked use: GUISetState ( @SW_SHOW ) Link to comment Share on other sites More sharing options...
Yashied Posted July 15, 2009 Share Posted July 15, 2009 Authenticity, I think your example was a shock for OP. But the example is good! My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... 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