Sign in to follow this  
Followers 0
Diana (Cda)

Refresh date and time output in systray script?

2 posts in this topic

Hi, everyone! Coding along as much as always but now doing fairly well. Well, except when I get stumped, as today <g>. Here's the main part of my troubled script:

DirCreate($Folder2create)
Beep(1500,35)
Sleep(50)
DirCopy(@ScriptDir, $Folder2create, 1)
Sleep(500)
Beep(1500,35)
Sleep(50)
Beep(1500,35)
Sleep(150)
MsgBox(64,"To open ...","To open the newly created folder, " & @CRLF & _
"click on the icon in the systray." & @CRLF & @CRLF & _
"(this does _NOT_ close the systray script).         "& @CRLF & @CRLF)

;------------------------------------------------------------------------------------------------------------
#NoTrayIcon  ; AutoIt's icon doesn't show in systray
TraySetIcon($IconsMine, 2)   ; changes the icon displayed in the systray
;------------------------------------------------------------------------------------------------------------
#include <GuiConstants.au3>
;*****===== Tray "context menu": =====*****=====*****=====*****=====*****=====*****=====*****=====*
Opt("GuiOnEventMode", 1)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)
;--------------------------------------------------------------------------------------------------
TrayCreateItem("")   ; creates a "separator" line between items in tray menu
TrayCreateItem("Open target BACKUPS folder ...")
TrayItemSetOnEvent(-1, "_TrayItem1")
;--------------------------------------------------------------------------------------------------
TrayCreateItem("")   ; creates a "separator" line between items in tray menu
TrayCreateItem("Open source folder ...")
TrayItemSetOnEvent(-1, "_TrayItem2")
;--------------------------------------------------------------------------------------------------
TrayCreateItem("")   ; creates a "separator" line between items in tray menu
TrayCreateItem("....... MAKE A NEW BACKUP .......")
TrayItemSetOnEvent(-1, "_TrayItem3")
;--------------------------------------------------------------------------------------------------
TrayCreateItem("")   ; creates a "separator" line between items in tray menu
TrayCreateItem("")   ; creates a "separator" line between items in tray menu
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "_Quit")
TrayCreateItem("")   ; creates a "separator" line between items in tray menu
TrayCreateItem("")   ; creates a "separator" line between items in tray menu
;*****=====*****=====*****=====*****=====*****=====*****=====*****=====*****=====*****=====********
While 1
Sleep(250)
WEnd

Beep(3500,25)
Sleep(50)
Beep(4500,25)
Sleep(50)
Beep(5500,25)
Sleep(50)
Beep(6500,25)
Sleep(50)
Beep(7500,25)

;=========================================================================
Func _TrayItem1()
If NOT WinExists($FolderROOT) THEN ShellExecute($WEReplacement, $FolderROOT, "", "Open", @SW_MAXIMIZE)
EndFunc

Func _TrayItem2()
If NOT WinExists($FolderROOT) THEN ShellExecute($WEReplacement, @ScriptDir, "", "Open", @SW_MAXIMIZE)
EndFunc

Func _TrayItem3()
DirCreate($Folder2create)
Beep(1500,35)
Sleep(50)
DirCopy(@ScriptDir, $Folder2create, 1)
Sleep(150)
EndFunc

Func _Quit()
Exit
EndFunc

I've had this problem before but today the solution is less than ideal. Here's what does work, removing the variable line re $Folder2Create close to the top and putting it down in the _TrayItem3() below and not using my variables from my time UDF:

Func _TrayItem3()
;----------------------------------------------------------------------------------------------------------------------------------
$Folder2Create = $FolderROOT & "\BKP- Ready2PUB- " & @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & "m" & @SEC & "s"
;----------------------------------------------------------------------------------------------------------------------------------
DirCreate($Folder2create)
Beep(1500,35)
Sleep(50)
DirCopy(@ScriptDir, $Folder2create, 1)
Sleep(150)
EndFunc

But this is incredibly clunky and doesn't give me the necessary custom date and time output formats. Is there any way to make the original script work with the special date and time variables, anyone know? Perhaps refreshing the date and time somehow??

Thx.

Share this post


Link to post
Share on other sites



What "special" date and time variables are you talking about, and what is the problem with your script. You're not explaining very well what help you need.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0