Display current time in a large format on screen Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Raghava Doregowda
Posts: 139
Joined: 06 Nov 2022, 01:48

Display current time in a large format on screen

Post by Raghava Doregowda » 22 Jan 2024, 20:32

Sometimes I have to go a bit away from the computer for some time before returning back to the computer to continue my work. A large current time display on the screen would help as I need not check my phone(because the clock in the taskbar display is too small). Can someone assist me with this?

User avatar
mikeyww
Posts: 27280
Joined: 09 Sep 2014, 18:38

Re: Display current time in a large format on screen  Topic is solved

Post by mikeyww » 22 Jan 2024, 20:50

Display a clock

Code: Select all

; This script displays a clock
#Requires AutoHotkey v1.1.33
Process Priority,, B
Gui Font, s150 w700
Gui Color, Black
Gui Add, Text, w900 cRed Center vtime
Gui Show,, Time
SetTimer Update, 1000
Update:
FormatTime, time,, HH:mm:ss
GuiControl,, time, % time
Return

GuiEscape:
GuiClose:
ExitApp

jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Re: Display current time in a large format on screen

Post by jrachr » 22 Jan 2024, 22:17

This is exactly what I have been looking for. One question. Where would I go about putting a little set timer in to escape after say 5 seconds or whatever I choose. Tk's. Once again very nice.

sofista
Posts: 654
Joined: 24 Feb 2020, 13:59
Location: Buenos Aires

Re: Display current time in a large format on screen

Post by sofista » 22 Jan 2024, 22:52

My take

Code: Select all

; Adapted from Gdip Tutorial 8 - Write.text.onto.a.gui

#SingleInstance, Force
#NoEnv

#Include <Gdip_all>                        ; Update it -> Path to your Gdip Library

If !pToken := Gdip_Startup() {
	MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
	ExitApp
}

	Width := 1400, Height := 1050
	Font := "Arial"
	Options := "x10p y30p w80p Centre cbbff0000 r4 s72 Bold"    ; "s72" is Font size, change it for whatever size you want
return

q::
	Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
	Gui, 1: Show, NA
	global hwnd1 := WinExist()
	global hbm := CreateDIBSection(Width, Height)
	global hdc := CreateCompatibleDC()
	global obm := SelectObject(hdc, hbm)
	global G := Gdip_GraphicsFromHDC(hdc)
	Gdip_SetSmoothingMode(G, 4)

	SetTimer, ShowTimeGdip, 1000
return

ShowTimeGdip:
	FormatTime, T, % A_Now, HH:mm:ss
	Gdip_GraphicsClear(G, 0x00000000)
	Gdip_TextToGraphics(G, T, Options, Font, Width, Height)

	UpdateLayeredWindow(hwnd1, hdc, (A_ScreenWidth-Width)//2, (A_ScreenHeight-Height)//2, Width, Height)

Return

Esc::
	SelectObject(hdc, obm)
	DeleteObject(hbm)
	DeleteDC(hdc)
	Gdip_DeleteGraphics(G)
	Gdip_Shutdown(pToken)
	ExitApp
return
Note: You can download Gdip_All, version 1.96 (2023-08-22) - by @robodesign (Marcus Șucan) from:
https://github.com/marius-sucan/AHK-GDIp-Library-Compilation/blob/master/ahk-v1-1/Gdip_All.ahk

User avatar
mikeyww
Posts: 27280
Joined: 09 Sep 2014, 18:38

Re: Display current time in a large format on screen

Post by mikeyww » 22 Jan 2024, 23:12

A new timer could be added wherever you want it to start running. Give it a go.

jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Re: Display current time in a large format on screen

Post by jrachr » 22 Jan 2024, 23:29

@mikey. I think you misunderstood. I don't want to start a new clock. Just put in a set timer or sleep and close after 5 seconds. Just need help on where to put that command in your script Mikey. Thank you.

User avatar
mikeyww
Posts: 27280
Joined: 09 Sep 2014, 18:38

Re: Display current time in a large format on screen

Post by mikeyww » 23 Jan 2024, 07:25

Hello,

This addition will be straightforward. You would insert the SetTimer command at the place in the script where you would like the command to execute and the timer to start. For example, if you would like the timer to start after the GUI is shown, you would insert the command after the Gui Show line.

Below are additional examples of using a timer.

https://www.autohotkey.com/docs/v1/lib/SetTimer.htm#ExampleClose

viewtopic.php?f=76&t=122772&p=545433&hilit=settimer#p545433

viewtopic.php?f=76&t=123850&p=555435&hilit=settimer#p555435

jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Re: Display current time in a large format on screen

Post by jrachr » 23 Jan 2024, 07:40

@mikey. Understood.Thank you.

Raghava Doregowda
Posts: 139
Joined: 06 Nov 2022, 01:48

Re: Display current time in a large format on screen

Post by Raghava Doregowda » 31 May 2024, 20:32

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
; This script displays a clock
#Requires AutoHotkey v1.1.33
toggle:=1
!t::
{
 if (toggle=1)
 {
  toggle=0
  Gui, destroy
  Process Priority,, B
  Gui +AlwaysonTop
  Gui Font, s150 w700
  Gui Color, Black
  Gui Add, Text, w900 cWhite Center vtime 
  ;Gui Show,x10 yCenter, Time
  Gui, Show, % "x" A_ScreenWidth - 1600 " h" 500, Time
  SetTimer Update, 1000
  Update:
  FormatTime, time,, HH:mm:ss
  GuiControl,, time, % time
  Return
 }
 else
 {
  Winminimize, Time ahk_class AutoHotkeyGUI ahk_exe AutoHotkey.exe
  toggle:=1
 }
}

GuiEscape:
GuiClose:
Gui, destroy
return

Post Reply

Return to “Ask for Help (v1)”