1
0
mirror of https://github.com/glennrice/PortableDesktop.git synced 2024-12-05 07:28:24 +10:00

Added basic system tray menu

This commit is contained in:
Glenn Rice 2016-04-02 20:31:58 +10:00
parent 8b8c997009
commit 78920d9a44

View File

@ -1,11 +1,20 @@
#include <Array.au3> #NoTrayIcon
#include <Constants.au3> #include <Constants.au3>
#include <WindowsConstants.au3> #include <WindowsConstants.au3>
#include <StaticConstants.au3> #include <StaticConstants.au3>
#include <ProgressConstants.au3> #include <ProgressConstants.au3>
#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.#include <Array.au3>
Opt("GUIOnEventMode", 1)
OnAutoItExitRegister ( 'OnAutoItExit' ) OnAutoItExitRegister ( 'OnAutoItExit' )
Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected.
$HostDrive = StringLeft(@AutoItExe, 2) $HostDrive = StringLeft(@AutoItExe, 2)
$hProgressSplash = _SplashTextProgress("Portable Desktop",$HostDrive&"work_portal.jpg","... Opening Portal ...","O") $hProgressSplash = _SplashTextProgress("Portable Desktop",$HostDrive&"work_portal.jpg","... Opening Portal ...","O")
@ -116,13 +125,13 @@ Sleep(500)
; setup some desktop icons ; setup some desktop icons
;$FileName = "P:\Start.exe" $FileName = "P:\Utility\cmder\cmder.exe"
;$LinkFileName = @DesktopDir & "\Start Personal Desktop.lnk" $LinkFileName = @DesktopDir & "\Start Cmder prompt.lnk"
;$WorkingDirectory = "P:\" $WorkingDirectory = "P:\"
;$Description = "This starts my mobile personal MojoPac desktop" $Description = "This starts customised command prompt"
;$State = @SW_SHOWNORMAL ;Can also be @SW_SHOWNORMAL or @SW_SHOWMINNOACTIVE $State = @SW_SHOWNORMAL ;Can also be @SW_SHOWNORMAL or @SW_SHOWMINNOACTIVE
;FileCreateShortcut($FileName,$LinkFileName,$WorkingDirectory,"",$Description) FileCreateShortcut($FileName,$LinkFileName,$WorkingDirectory,"",$Description)
;$FileName = $drive&"\mobile-backup.exe" ;$FileName = $drive&"\mobile-backup.exe"
;$LinkFileName = @DesktopDir & "\Mobile Backup.lnk" ;$LinkFileName = @DesktopDir & "\Mobile Backup.lnk"
@ -194,9 +203,39 @@ Sleep(500)
GUIDelete($hProgressSplash) GUIDelete($hProgressSplash)
; --- Setup Tray menu
Global $iSettings = TrayCreateMenu("Settings") ; Create a tray menu sub menu with two sub items.
Global $iDisplay = TrayCreateItem("Display", $iSettings)
Global $iPrinter = TrayCreateItem("Printer", $iSettings)
TrayCreateItem("") ; Create a separator line.
Local $idAbout = TrayCreateItem("About")
TrayCreateItem("") ; Create a separator line.
Local $idExit = TrayCreateItem("Exit")
TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.
; wait until it finishes ; wait until it finishes
Sleep(16000) Sleep(16000)
ProcessWaitClose("PortableAppsPlatform.exe") ; ---ProcessWaitClose("PortableAppsPlatform.exe")
While ProcessExists("PortableAppsPlatform.exe")
; Poll the system tray menu
Switch TrayGetMsg()
Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
Global $hAbout = AboutForm()
Case $iDisplay, $iPrinter
MsgBox($MB_SYSTEMMODAL, "", "A sub menu item was selected from the tray menu.")
Case $idExit ; Exit the loop.
ExitLoop
EndSwitch
Wend
$hProgressSplash = _SplashTextProgress("Portable Desktop",$HostDrive&"close_portal.jpg","... Locking Vault ...","C") $hProgressSplash = _SplashTextProgress("Portable Desktop",$HostDrive&"close_portal.jpg","... Locking Vault ...","C")
@ -227,6 +266,32 @@ Func _SplashTextProgress($sText,$sPic,$sDesc,$sWhich) ;Creates a Splash Text Scr
Return SetExtended($iProgressBar, $hSplash) Return SetExtended($iProgressBar, $hSplash)
EndFunc ; end _SplashTextProgress EndFunc ; end _SplashTextProgress
Func AboutForm()
#Region ### START Koda GUI section ### Form=G:\Tools\Koda\Forms\frmAbout.kxf
$frmAbout = GUICreate("About", 445, 348, 186, 149)
$lblTitle = GUICtrlCreateLabel("PortableDesktop", 168, 24, 258, 41)
GUICtrlSetFont(-1, 24, 800, 0, "Arial")
$btnOK = GUICtrlCreateButton("OK", 344, 312, 75, 25)
GUICtrlSetOnEvent(-1, "btnOKClick")
$lblVersion = GUICtrlCreateLabel("Version 0.1", 168, 80, 57, 17)
$grpConfig = GUICtrlCreateGroup("Configuration:", 32, 152, 385, 145)
$txtHost = GUICtrlCreateInput(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1), 224, 192, 121, 21)
GUICtrlSetState(-1, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel("Host Drive:", 112, 192, 57, 17)
$Label2 = GUICtrlCreateLabel("Portable Desktop:", 112, 232, 89, 17)
$txtPortable = GUICtrlCreateInput($HostDrive, 224, 232, 121, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Return $frmAbout
EndFunc ; end AboutForm
Func btnOKClick()
GUIDelete($hAbout)
EndFunc
Func OnAutoItExit() Func OnAutoItExit()
Sleep(5000) Sleep(5000)
@ -266,7 +331,7 @@ Func OnAutoItExit()
endif endif
; remove some desktop icons ; remove some desktop icons
; FileDelete(@DesktopDir & "\Start Personal Desktop.lnk") FileDelete(@DesktopDir & "\Start Cmder prompt.lnk")
; FileDelete(@DesktopDir & "\Mobile Backup.lnk") ; FileDelete(@DesktopDir & "\Mobile Backup.lnk")
; FileDelete($WorkDrive & $My_Nimi_Places & "Tools\mRemote.lnk") ; FileDelete($WorkDrive & $My_Nimi_Places & "Tools\mRemote.lnk")
; FileDelete($WorkDrive & $My_Nimi_Places & "Tools\jungledisk-usb.lnk") ; FileDelete($WorkDrive & $My_Nimi_Places & "Tools\jungledisk-usb.lnk")