Renderer Posted November 14, 2015 Share Posted November 14, 2015 (edited) Here's my litte desktop clock:#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <misc.au3> ; global $popup = GUICreate('DesktopClock',300,50,@DesktopWidth+(-330),@DesktopHeight+(-100),$WS_POPUP) GUISetBkColor(0x000000) global $clockLabel = GUICtrlCreateLabel('',30,5,450,30) GUICtrlSetFont($clockLabel,20,0,0,'Segoe UI') GUICtrlSetColor($clockLabel,0x32cd32) WinSetTrans($popup,"",190) GUISetState() While 1 Switch GUIGetMsg() case -3 ExitLoop EndSwitch _GetTime_() WEnd Func _GetTime_() GUICtrlSetData($clockLabel, 'Local time: ' & @Hour & ":" & @Min & ":" & @sec) Sleep(1000) _GetTime_() EndFuncThere is a little problem. I cannot exit the program , because the _GetTime_() function is written once again into the _GetTime_() function definition. So the program only updates the date and time. Edited November 14, 2015 by Renderer Link to comment Share on other sites More sharing options...
llewxam Posted November 14, 2015 Share Posted November 14, 2015 Here are a few quick suggestions:2 of your includes are not neededAdlibRegister calls a specified function at specified intervals, so instead of having the _GetTime_ function call itself once the script starts (and then get stuck in it), AdlibRegister will just go there once a secondCall _GetTime_ after the AdlibRegister so the clock has a chance to display before the first 1-second interval passesRun Tidy (CTRL-T) Please see the modified code below, anything not needed I just commented out rather than deleted. #include <WindowsConstants.au3> ;~ #include <GUIConstantsEx.au3> ;~ #include <misc.au3> Global $popup = GUICreate('DesktopClock', 300, 50, @DesktopWidth + (-330), @DesktopHeight + (-100), $WS_POPUP) GUISetBkColor(0x000000) Global $clockLabel = GUICtrlCreateLabel('', 30, 5, 450, 30) GUICtrlSetFont($clockLabel, 20, 0, 0, 'Segoe UI') GUICtrlSetColor($clockLabel, 0x32cd32) WinSetTrans($popup, "", 190) GUISetState() AdlibRegister("_GetTime_",1000) _GetTime_() While 1 Switch GUIGetMsg() Case -3 ExitLoop EndSwitch ;~ _GetTime_() WEnd Func _GetTime_() GUICtrlSetData($clockLabel, 'Local time: ' & @HOUR & ":" & @MIN & ":" & @SEC) ;~ Sleep(1000) ;~ _GetTime_() EndFunc ;==>_GetTime_ Ian My projects: IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged. INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them. PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses. Sync Tool - Folder sync tool with lots of real time information and several checking methods. USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions. Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent. CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction. MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app. 2048 Game - My version of 2048, fun tile game. Juice Lab - Ecigarette liquid making calculator. Data Protector - Secure notes to save sensitive information. VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive. Find in File - Searches files containing a specified phrase. Link to comment Share on other sites More sharing options...
Renderer Posted November 14, 2015 Author Share Posted November 14, 2015 Here are a few quick suggestions:2 of your includes are not neededAdlibRegister calls a specified function at specified intervals, so instead of having the _GetTime_ function call itself once the script starts (and then get stuck in it), AdlibRegister will just go there once a secondCall _GetTime_ after the AdlibRegister so the clock has a chance to display before the first 1-second interval passesRun Tidy (CTRL-T) Please see the modified code below, anything not needed I just commented out rather than deleted. #include <WindowsConstants.au3> ;~ #include <GUIConstantsEx.au3> ;~ #include <misc.au3> Global $popup = GUICreate('DesktopClock', 300, 50, @DesktopWidth + (-330), @DesktopHeight + (-100), $WS_POPUP) GUISetBkColor(0x000000) Global $clockLabel = GUICtrlCreateLabel('', 30, 5, 450, 30) GUICtrlSetFont($clockLabel, 20, 0, 0, 'Segoe UI') GUICtrlSetColor($clockLabel, 0x32cd32) WinSetTrans($popup, "", 190) GUISetState() AdlibRegister("_GetTime_",1000) _GetTime_() While 1 Switch GUIGetMsg() Case -3 ExitLoop EndSwitch ;~ _GetTime_() WEnd Func _GetTime_() GUICtrlSetData($clockLabel, 'Local time: ' & @HOUR & ":" & @MIN & ":" & @SEC) ;~ Sleep(1000) ;~ _GetTime_() EndFunc ;==>_GetTime_ IanThanks! This was helpfull. Exploring the functions may help me on the future. Link to comment Share on other sites More sharing options...
argumentum Posted November 15, 2015 Share Posted November 15, 2015 #include <WindowsConstants.au3> Global $popup = GUICreate('DesktopClock', 300, 50, @DesktopWidth + (-330), @DesktopHeight + (-100), $WS_POPUP) GUISetBkColor(0x000000) Global $clockLabel = GUICtrlCreateLabel('', 30, 5, 450, 30) GUICtrlSetFont($clockLabel, 20, 0, 0, 'Segoe UI') GUICtrlSetColor($clockLabel, 0x32cd32) WinSetTrans($popup, "", 190) GUISetState() Local $SEC = 99 While 1 Switch GUIGetMsg() Case -3 GUIDelete() ExitLoop EndSwitch If $SEC = @SEC Then ContinueLoop $SEC = @SEC GUICtrlSetData($clockLabel, 'Local time: ' & @HOUR & ":" & @MIN & ":" & @SEC) WEnd Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. 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