Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

onscreen time


  • Please log in to reply
19 replies to this topic
closed
  • Members
  • 509 posts
  • Last active: Jan 14 2012 06:14 PM
  • Joined: 07 Feb 2008
I needed a simple one that can be set clickthrough and transparency changed.

Posted Image

After seeing this post i gave it a try:
<!-- m -->http://www.autohotke... ... 614#407614<!-- m -->

update:Thanks to x79animal following warning :you need gdip.ahk in your standard lib or use #include gdip.ahk codeline. :)

you find Tic's gdip.ahk here:
<!-- m -->http://www.autohotke... ... 38&start=0<!-- m -->

#NoEnv
DetectHiddenWindows On
SetTitleMatchMode 2
OnExit gone_away

delta:=A_Now
delta -=A_NowUTC,seconds

Menu, Tray,add,Hide/Show , toggle_hide
Menu, Tray,default,Hide/Show
Menu,Tray ,Click, 1
Menu, Tray,add
Menu, Tray,add,Set Clock Color ,set_clockcolor
Menu, Tray,add,Set background opacity ,set_opacity
Menu, Tray,add
Menu, Tray,add,Save Position ,save_position
Menu, Tray,add,Set Click Through ,click_through
Menu, Tray,add,Set AlwaysOnTop ,AlwaysOnTop 
Menu, Tray,add,Set hotkeys off ,hotkey_off
Menu, Tray,add
Menu, Tray,add,Exit ,gone_away
Menu, Tray,NoStandard

;---------------- hotkey alt+o menu -----------------
Menu, MyMenu,add,Hide/Show , toggle_hide
Menu, MyMenu,default,Hide/Show
Menu, MyMenu,add
Menu, MyMenu,add,Set Clock Color ,set_clockcolor
Menu, MyMenu,add,Set background opacity ,set_opacity
Menu, MyMenu,add
Menu, MyMenu,add,Save Position ,save_position
Menu, MyMenu,add,Set Click Through ,click_through
Menu, MyMenu,add,Set AlwaysOnTop ,AlwaysOnTop 
Menu, MyMenu,add,Set hotkeys off ,hotkey_off
Menu, MyMenu,add
Menu, MyMenu,add,Exit ,gone_away
Menu, MyMenu,NoStandard
;---------------- alt+o menu -----------------


;-------------- create ini file -------------- 
IfNotExist, i_time.ini
{
IniWrite,cffE2E2E2, i_time.ini, parameters, clock_color
IniWrite,100, i_time.ini, parameters, positionx
IniWrite,100, i_time.ini, parameters, positiony
IniWrite,A3, i_time.ini, parameters, opacity     ;these are hex values!!!
IniWrite,0, i_time.ini, parameters, alwaysontop
IniWrite,0, i_time.ini, parameters, click_through
}
;-------------- create ini file -------------- 





;-------------- get default values -------------- 
IfExist, i_time.ini
{
IniRead,clock_color, i_time.ini, parameters, clock_color,cff3999E8
IniRead,posx, i_time.ini, parameters, positionx,100
IniRead,posy, i_time.ini, parameters, positiony,100
IniRead,opacity_value_hex, i_time.ini, parameters, opacity,A8
IniRead,alwaysontop, i_time.ini, parameters, alwaysontop,0
IniRead,click_through, i_time.ini, parameters, click_through,0
}

size=s24
background_color=0x%opacity_value_hex%000000
display_size:=size
 


;-------------- get default values -------------- 


If !pToken := Gdip_Startup()
{
	MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
	ExitApp
}
Font = Arial
If !hFamily := Gdip_FontFamilyCreate(Font)
{
   MsgBox, 48, Font error!, The font you have specified does not exist on the system
   ExitApp
}
Gdip_DeleteFontFamily(hFamily)




Gui, 3:  +E0x80000 +LastFound +OwnDialogs +Owner  -caption 
Gui, 3: Show,w140 h35 x0 y0 NA,i_time
winget,hwnd1,ID,i_time

WinWidth =140
WinHeight :=35
hbm := CreateDIBSection(WinWidth, WinHeight), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
pBrush := Gdip_BrushCreateSolid(background_color)
Gdip_SetSmoothingMode(G, 4)
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, WinWidth, WinHeight,10)



OnMessage(0x201, "WM_LBUTTONDOWN")
WinMove, i_time, , %posX%, %posY% 
settimer,get_realtime,900

;-------------- set initial conditions

if alwaysontop
Gosub, alwaysontop

if click_through
Gosub, click_through

;-------------- set initial conditions
return




click_through:
Menu, tray,togglecheck,Set Click Through
Menu, MyMenu,togglecheck,Set Click Through
status:=!status
if status
{
WinGetPos, temp_x,temp_y,,,ahk_id %hwnd1%
Gui, 3:destroy
Gui, 3:  +E0x80000 +LastFound +OwnDialogs +Owner  -caption +E0x20
Gui, 3: Show,w140 h35 x%temp_x% y%temp_y% NA,i_time
winget,hwnd1,ID,i_time
if toggle_ontop
WinSet, alwaysontop,on,ahk_id %hwnd1%
}
else
{
WinGetPos, temp_x,temp_y,,,ahk_id %hwnd1%
Gui, 3:destroy
Gui, 3:  +E0x80000 +LastFound +OwnDialogs +Owner  -caption 
Gui, 3: Show,w140 h35 x%temp_x% y%temp_y% NA,i_time
winget,hwnd1,ID,i_time
if toggle_ontop
WinSet, alwaysontop,on,ahk_id %hwnd1%
}
return 
;-------------- alwaysontop -------------- 
alwaysontop:
toggle_ontop:=!toggle_ontop
menu,tray,togglecheck,set alwaysontop
menu,MyMenu,togglecheck,set alwaysontop
if toggle_ontop
WinSet, alwaysontop,on,ahk_id %hwnd1%
else
WinSet, alwaysontop,off,ahk_id %hwnd1%
return
;-------------- alwaysontop -------------- 

set_opacity:
opacity_h:="0x"  opacity_value_hex
setformat,integer,d
opacity_display:=floor(opacity_h*100/255)
setformat,integer,hex


InputBox, opacity_value_dec,Set Transparency 0-100,transparency level can be set `nvalue =100 is dark ,,200,150,,,,20,%opacity_display%

if opacity_value_dec not between 0 and 100
{
msgbox error value  %opacity_value_dec% not between 0-100
return
}
setformat,integer,hex
op:=floor(opacity_value_dec*2.5)+1
StringTrimLeft, opacity_value_hex,op,2
IniWrite,%opacity_value_hex%, i_time.ini, parameters, opacity
setformat,integer,d
Gdip_DeleteBrush(pBrush)
background_color=0x%opacity_value_hex%000000
pBrush := Gdip_BrushCreateSolid(background_color)
return 
;-------------- enable dragwindow -------------- 
WM_LBUTTONDOWN()
{
	PostMessage, 0xA1, 2
}
return
;-------------- enable dragwindow -------------- 

;-------------- hotkeys ------------------ 
!i::  ;hide/show hotkey
Gosub, toggle_hide
return
~rbutton::
MouseGetPos, ,,hwnd2
if (hwnd2=hwnd1)
{
toggle=1
WinHide, ahk_id %hwnd1%
}
return
!o::
Menu, MyMenu,show
return
;-------------- hotkeys off -------------- 

hotkey_off:
Menu, tray,togglecheck,Set hotkeys off
Hotkey, !o,toggle

return
;-------------- hotkeys off-------------- 
toggle_hide:
toggle:=!toggle
if toggle
WinHide, ahk_id %hwnd1%
Else, 
WinShow, ahk_id %hwnd1%
return 

get_realtime:
FormatTime, displaytext,,H : mm : ss
display_color=%clock_color%
display_size=s18
gosub write_display_text_clock
return
;-------------- write display text -------------- 

write_display_text_clock:
Gdip_SetCompositingMode(G, 1)
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, WinWidth, WinHeight,5)
Gdip_SetCompositingMode(G, 0)
Options = x0 y6 w140 %display_color%  Center  %display_size%
Gdip_TextToGraphics(G, displaytext, Options, Font, winWidth, winHeight)
UpdateLayeredWindow(hwnd1, hdc)
return

;-------------- write display text -------------- 
set_clockcolor:
newcolor:=ChooseColorA( 0x2255ff)
if (newcolor<>"")
clock_color=cff%newcolor%
IniWrite, %clock_color%,i_time.ini,parameters,clock_color
return

save_position:
WinGetPos, posx,posy,,,ahk_id %hwnd1%
IniWrite, %posx%,i_time.ini,parameters,positionx
IniWrite, %posy%,i_time.ini,parameters,positiony
return 


FormatSeconds(NumberOfSeconds) 
{
    time = 19990101 
    time += %NumberOfSeconds%, seconds
    FormatTime, mmss, %time%, mm : ss
    hours:=NumberOfSeconds//3600
    hours:=(hours ? hours : "00")
    return  hours " : " mmss  
}

gone_away:
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gdip_DeleteBrush(pBrush)
Gdip_Shutdown(pToken)
ExitApp


;  By SKAN code for choosing color http://www.autohotkey.com/forum/topic59534.html

ChooseColorA( CR=0x0, hWnd=0x0, X=25, Y=25, Title=0, CustomColors=0, RGB=1 ) {

 Static CC, Color = "000000", S22 = "                      ", ATOU = "MultiByteToWideChar"
 If ! ( VarSetCapacity( CC ) ) {
 CCD =
 ( LTrim Join
   24ZV47ZV8N8J808N8H8H8J808HC0C0CH80808HFFMFFIFFFFMFFGFFGFFIFFFFGFFFFFFGC020C88G8K1BH2K2A
   01B8O43G43G68G6FG6FG73G65G43G6FG6CG6FG72G41G2H2H2H2H2H2H2H2H2H2H2H2H2H2H2H2H2H2H2M8G4DG
   53G2H53G68G65G6CG6CG2H44G6CG67P25O4H4G8CH9GFFFFFFFF82G26G42G61G73G69G63G2H63G6FG6CG6FG7
   2G73G3ATBH35O4HEG8CG56GDG2FFFF82X25O4G6AG8CH9GFFFFFFFF82G26G43G75G73G74G6FG6DG2H63G6FG6
   CG6FG72G73G3APBH35O4G74G8CG1CGD102FFFF82X35O4G96G8CHEGCF02FFFF8H26G44G65G66G69G6EG65G2H
   43G75G73G74G6FG6DG2H43G6FG6CG6FG72G73G2H3EG3ET1H35O4GA6G2CHEH1GFFFF8H4FG4BX35N34GA6G2CH
   EH2GFFFF8H43G61G6EG63G65G6CX35N64GA6G2CHEHE04FFFF8H26G48G65G6CG7QB1H5N98H4G76G74GC602FF
   FF82TB1H5N180104H8G74GBE02FFFF82TB1H5N98G7CG28G1AGC502FFFF82X35N2C01C8H4HEGC902FFFF8H26
   G6FT2H25N98G97G14H9GDA02FFFF82G43G6FG6CG6FG72T25NACG97G14H9GDB02FFFF82G7CG53G26G6FG6CG6
   9G64P2H25NC2G7EG14H9GD302FFFF82G48G75G26G65G3AS835ND8G7CG12HCGBF02FFFF81T2H25NC2G8CG14H
   9GD402FFFF82G26G53G61G74G3AS835ND8G8AG12HCGCG2FFFF81T2H25NC2G9AG14H9GD502FFFF82G26G4CG7
   5G6DG3AS835ND8G98G12HCGC102FFFF81T2H25NF3G7EG18H9GD602FFFF82G26G52G65G64G3AS835OD017CG1
   2HCGC202FFFF81T2H25NF3G8CG18H9GD702FFFF82G26G47G72G65G65G6EG3AS835OD018AG12HCGC302FFFF8
   1T2H25NF3G9AG18H9GD802FFFF82G42G6CG26G75G65G3AW835OD0198G12HCGC402FFFF81X35N98GA6G8EHEG
   C802FFFF8H26G41G64G64G2H74G6FG2H43G75G73G74G6FG6DG2H43G6FG6CG6FG72G73O
 )
 Loop 20
  StringReplace,CCD,CCD,% Chr(70+21-A_Index),% SubStr("000000000000000000000",A_Index),All
 Loop % VarSetCapacity(CC,StrLen(CCD)//2,0)
  NumPut( "0x" . SubStr(CCD, 2*A_Index-1,2),CC,A_Index-1,"Char" )
 }
 Numput( &CC+100,CC,8 ), NumPut( &CC+36,CC,16 )
 IfNotEqual,CustomColors,0, Loop, Parse, CustomColors, |
 _ := (A_LoopField<>"" && A_Index<17) ? NumPut("0x" A_LoopField,CC,36+(4*(A_Index-1))) : 0
 Title ? DllCall( ATOU, Int,0,Int,0, Str,Title S22, UInt,22, UInt,&CC+122, UInt,44 ) : 0
 NumPut(Y,CC,112,"UShort"), NumPut(X,CC,110,"UShort"), NumPut(hWnd,CC,4)
 WinExist( "ahk_id" hWnd ) ? NumPut(0,CC,104) : 0
 RGB ? NumPut((((CR&0xFF)<<16)|(CR&0xFF00)|((CR&0xFF0000)>>16)),CC,12) : NumPut(CR,CC,12)
 If ! DllCall( "comdlg32\ChooseColorA", UInt,&CC ) || ErrorLevel
      Return
 DllCall( "msvcrt\sprintf", Str,Color, Str,"%06X", UInt, RGB ? ( (((CR:=Numget(CC,12) )
  &0xFF)<<16)|(CR&0xFF00)|((CR&0xFF0000)>>16)) : Numget(CC,12) )
Return Color
}




x79animal
  • Members
  • 1021 posts
  • Last active: May 14 2013 04:21 PM
  • Joined: 01 May 2010
Nice use of GDI,i like it. you should probably mention its a requirement before people whine at you

tomoe_uehara
  • Members
  • 2166 posts
  • Last active: Jun 11 2015 05:33 PM
  • Joined: 05 Sep 2009
I can't change the clock nor the background color :?

Sinel1980
  • Members
  • 21 posts
  • Last active: Mar 13 2012 07:32 AM
  • Joined: 30 Aug 2010
Doesn't show anything on my Vista x64

closed
  • Members
  • 509 posts
  • Last active: Jan 14 2012 06:14 PM
  • Joined: 07 Feb 2008
Sinel1980 Sorry but i only have WinXP to test it on but do you have the latest gdip.ahk?I am not sure that texttographics was supported in earlier versions.

tomoe_uehara I wrote this for my own use and then decided to share it as it is,so if there are parameters you like to be able to change i am sure you are qualified to add the necessary code and feel free to share it. :)

tomoe_uehara
  • Members
  • 2166 posts
  • Last active: Jun 11 2015 05:33 PM
  • Joined: 05 Sep 2009
Fixed it, it's pretty nice!

Sinel1980
  • Members
  • 21 posts
  • Last active: Mar 13 2012 07:32 AM
  • Joined: 30 Aug 2010
Gdip yet doesn't work on 64 bit version of AHK (AHK_L), so this is the reason. Hope it will soon.

  • Guests
  • Last active:
  • Joined: --
It says call to nonexistent function

What do I do with Gdip.ahk. I just kept that file in same folder as your script is in and ran ur script..

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010

It says call to nonexistent function

What do I do with Gdip.ahk. I just kept that file in same folder as your script is in and ran ur script..


Either put Gdip.ahk in your Library folder (inside the Autohotkey folder), OR place it in the same folder as the script, and add the following row to the start of the script:

#include gdip.ahk

EDIT: The script is awesome! Gonna have it on my 2nd monitor. Really stylish and useful, so simple and elegant.
EDIT2: I think this I managed to crash my computer using this script. I just right-clicked it. Windows 7 x64, dual screen setup. Won't be doing that again :)

closed
  • Members
  • 509 posts
  • Last active: Jan 14 2012 06:14 PM
  • Joined: 07 Feb 2008
~rbutton::
MouseGetPos, ,,hwnd2
if (hwnd2=hwnd1)
{
toggle=1
WinHide, ahk_id %hwnd1%
}
return

Hi Sumon

Rightclicking on the clock will hide it ( or that is the intention...) the code is just a winhide command so it is strange that it crashes your system,ALT+i or clicking on the trayicon does the same thing.

You can best remove the rightclick hotkey if it gives a problem .I use it on a WinXP SP3 system single monitor (no problem here)

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010

~rbutton::
MouseGetPos, ,,hwnd2
if (hwnd2=hwnd1)
{
toggle=1
WinHide, ahk_id %hwnd1%
}
return

Hi Sumon

Rightclicking on the clock will hide it ( or that is the intention...) the code is just a winhide command so it is strange that it crashes your system,ALT+i or clicking on the trayicon does the same thing.

You can best remove the rightclick hotkey if it gives a problem .I use it on a WinXP SP3 system single monitor (no problem here)


Bravely tried again, no crash. So don't errorsearch it quite yet.

Cristi®
  • Members
  • 45 posts
  • Last active: Feb 13 2018 11:57 PM
  • Joined: 29 Nov 2007
hi Than, i liked this script and I decided to create my own. hope u don't mind
;created by Cristi based on Thanh00 script http://www.autohotkey.com/forum/viewtopic.php?t=66207
#SingleInstance Force
#Persistent
#NoEnv
DetectHiddenWindows On
SetTitleMatchMode 2


; add alarm function
; add mode small or large, huge

;----------------------Check If Exist Settings-----------------
IniRead, LockPos, i_time2.ini, Parameters, Lock_Position, 0
IniRead, OnTop, i_time2.ini, Parameters, Always_On_Top, 0
IniRead, PosX, i_time2.ini, Parameters, PositionX, 100
IniRead, PosY, i_time2.ini, Parameters, PositionY, 100
If (posX ="100" or posY="100")
{
PosX := (A_ScreenWidth)-125 
PosY := (A_ScreenHeight)-80
}
IniRead, Through_Status, i_time2.ini, Parameters, Click_Through_Clock, 0
IniRead, Back_Color, i_time2.ini, Parameters, Back_Color, 000000
IniRead, Clock_Color, i_time2.ini, Parameters, Clock_Color, FFFFFF
IniRead, Trans_Value, i_time2.ini, Parameters, Transparency, 255
;------------------------------------------------------------

Gui, 1:+ToolWindow -Caption
Gui, 1:Color, %Back_Color%, %Back_Color%
Gui, 1:Font, s14 c%Clock_Color%, bold, Arial
Gui, 1:Add, text, x16 y5 w119 h30 GMove vClock, %A_Hour%:%A_Min%:%A_Sec%
Gui, 1:Show, x%PosX% y%PosY% w105 h35, My_Clock_1.0
WinSet, Region, 0-0 W105 H35 R6-6, My_Clock_1.0
WinSet, Transparent, %Trans_Value%, My_Clock_1.0

SetTimer, TicTac, 1000


IfExist, clock.ico
Menu, Tray, Icon, clock.ico
Menu, Tray, Tip, My Clock 1.0
Menu, Tray, NoStandard
Menu, Tray, add, AlwaysOnTop, SetOnTop
Menu, Tray, add, Click Through, Click_Through
Menu, Tray, add, Lock Position, Lock_Position
Menu, Tray, add, Clock Colors, set_clock_colors
Menu, Tray, add, Close Clock ,ExitApp
Menu, Tray, add, Hide/&Show , Toggle_Hide
Menu, Tray, default, Hide/&Show
If Through_Status
{
Gui, 1:+E0x20
Menu, Tray, Check, Click Through
}

If OnTop = 1
{
WinSet, AlwaysOnTop, On, My_Clock_1.0
Menu, Tray, Check, AlwaysOnTop
}

If LockPos = 1
Menu, Tray, Check, Lock Position

;----------------------SeT Transparency --------------------
#IfWinActive, My_Clock_1.0
{
!WheelUp::
If Trans_Value <= 200
{
Trans_Value += 5
WinSet, Transparent, %Trans_Value%, My_Clock_1.0
}
return

!WheelDown::
If Trans_Value >= 15
{
Trans_Value -= 5
WinSet, Transparent, %Trans_Value%, My_Clock_1.0
}
return
}
;------------------------------------------------------------
return


;----------------------Enable Window Drag -------------------
Move:
PostMessage, 0xA1, 2,,, A
if A_GuiEvent = DoubleClick
GoSub, Show_Hide
Return
;------------------------------------------------------------


;----------------------Clock Engine :P-----------------------
TicTac:
GuiControl,, Clock, %A_Hour%:%A_Min%:%A_Sec%
return
;------------------------------------------------------------





;---------------------Show Or Hide Clock---------------------
Show_Hide:
Toggle_Hide:
toggle:=!toggle
if toggle
WinHide, My_Clock_1.0
Else,
WinShow, My_Clock_1.0
return
;------------------------------------------------------------


;---------------------Don't Save Position--------------------
Lock_Position:
If LockPos = 1
{
LockPos = 0
Menu, Tray, UnCheck, Lock Position
IniWrite, 0, i_time2.ini, Parameters, Lock_Position
}
else
{
LockPos = 1
GoSub, SavePos
Menu, Tray, Check, Lock Position
IniWrite, 1, i_time2.ini, Parameters, Lock_Position
}
return
;------------------------------------------------------------


;----------------------Set Clock Colors----------------------
Set_Clock_Colors:
SPosX := (899)-50 
SPosY := (688)-160
Gui, 2:Color, %Back_Color%
Gui, 2:+ToolWindow +AlwaysOnTop -Caption
Gui, 2:Font, S7 c%Clock_Color%, Verdana
Gui, 2:Add, Text, x6 y6 w130 h20 gMove, MyClock 1.0 - Settings
Gui, 2:Add, Text, x148 y6 w20 h20 g2GuiClose, X
Gui, 2:Add, GroupBox, x6 y25 w150 h75 , Colors
Gui, 2:Add, Text, x16 y45 w80 h20 , Background:
Gui, 2:Add, Button, x96 y45 w55 h17 vBack_Color_Btn gBackColorSet, %Back_Color%
Gui, 2:Add, Text, x16 y75 w100 h20 , Clock Color:
Gui, 2:Add, Button, x96 y75 w55 h17 vClock_Color_Btn gClockColorSet, %Clock_Color%
Gui, 2:Add, GroupBox, x6 y103 w150 h38 Right, Transparency
Gui, 2:Add, Slider, x16 y118 w130 h18 Range15-230 gSetTransparency vTrans_Value, %Trans_Value%
Gui, 2:Show, x%SPosX% y%SPosY% w163 h152, MyClock 1.0 - Settings
WinSet, Region, 0-0 w163 h152 R10-10, MyClock 1.0 - Settings
WinSet, Transparent, 180, MyClock 1.0 - Settings
Return

2GuiClose:
2GuiEscape:
Gui, 2:Destroy
return

;-----------------Set Clock Background Color-----------------
BackColorSet:
Gui, Submit, NoHide
Back_Color:=ChooseColorA( 0x000000)
if Back_Color <>
{
IniWrite, %Back_Color%, i_time2.ini,parameters, Back_Color
Gui, 1:Color, %Back_Color%
GuiControl, 2:, Back_Color_Btn, %Back_Color%
}
return
;-----------------------Set Clock Color----------------------
ClockColorSet:
Gui, Submit, NoHide
clock_color:=ChooseColorA( 0xffffff)
if clock_color <>
{
IniWrite, %Clock_Color%, i_time2.ini,parameters, Clock_Color
Gui, 1:Font, c%clock_color%
GuiControl, 1:Font, Clock
GuiControl, 2:, Clock_Color_Btn, %clock_color%
}
return
;------------------------------------------------------------

;-----------------------Set Transparency----------------------
SetTransparency:
Gui, Submit, NoHide
WinSet, Transparent, %Trans_Value%, My_Clock_1.0
IniWrite, %Trans_Value%, i_time2.ini, Parameters, Transparency
return
;------------------------------------------------------------

;-----------------------Set AlwaysOnTop----------------------
SetOnTop:
If OnTop = 1
{
WinSet, AlwaysOnTop, Off, My_Clock_1.0
OnTop=0
IniWrite, 0, i_time2.ini, Parameters, Always_On_Top
Menu, Tray, UnCheck, AlwaysOnTop
}
else
{
OnTop = 1
WinSet, AlwaysOnTop, On, My_Clock_1.0
Menu, Tray, Check, AlwaysOnTop
IniWrite, 1, i_time2.ini, Parameters, Always_On_Top
}
return
;------------------------------------------------------------

ExitApp:
If LockPos <> 1
GoSub, SavePos
sleep, 500
ExitApp
return

;---------------------Save Clock Position--------------------
SavePos:
WinGetPos, PosX,PosY,,, My_Clock_1.0
IniWrite, %PosX%,i_time2.ini, Parameters, PositionX
IniWrite, %PosY%,i_time2.ini, Parameters, PositionY
return
;------------------------------------------------------------




;------------------Click Through Clock Window-----------------
;Gui, 1:  +E0x80000 +LastFound +OwnDialogs +Owner -caption +E0x20 remove this
Click_Through:
Through_Status:=!Through_Status
if Through_Status
{
Gui, 1: +E0x20
Menu, tray, togglecheck, Click Through
IniWrite, %Through_Status%, i_time2.ini, Parameters, Click_Through_Clock
}
Else,
{
Gui, 1: -E0x20
Menu, tray, togglecheck, Click Through
IniWrite, %Through_Status%, i_time2.ini, Parameters, Click_Through_Clock
}
return
;------------------------------------------------------------


;  By SKAN code for choosing color http://www.autohotkey.com/forum/topic59534.html

ChooseColorA( CR=0x0, hWnd=0x0, X=25, Y=25, Title=0, CustomColors=0, RGB=1 ) {

 Static CC, Color = "000000", S22 = "                      ", ATOU = "MultiByteToWideChar"
 If ! ( VarSetCapacity( CC ) ) {
 CCD =
 ( LTrim Join
   24ZV47ZV8N8J808N8H8H8J808HC0C0CH80808HFFMFFIFFFFMFFGFFGFFIFFFFGFFFFFFGC020C88G8K1BH2K2A
   01B8O43G43G68G6FG6FG73G65G43G6FG6CG6FG72G41G2H2H2H2H2H2H2H2H2H2H2H2H2H2H2H2H2H2H2M8G4DG
   53G2H53G68G65G6CG6CG2H44G6CG67P25O4H4G8CH9GFFFFFFFF82G26G42G61G73G69G63G2H63G6FG6CG6FG7
   2G73G3ATBH35O4HEG8CG56GDG2FFFF82X25O4G6AG8CH9GFFFFFFFF82G26G43G75G73G74G6FG6DG2H63G6FG6
   CG6FG72G73G3APBH35O4G74G8CG1CGD102FFFF82X35O4G96G8CHEGCF02FFFF8H26G44G65G66G69G6EG65G2H
   43G75G73G74G6FG6DG2H43G6FG6CG6FG72G73G2H3EG3ET1H35O4GA6G2CHEH1GFFFF8H4FG4BX35N34GA6G2CH
   EH2GFFFF8H43G61G6EG63G65G6CX35N64GA6G2CHEHE04FFFF8H26G48G65G6CG7QB1H5N98H4G76G74GC602FF
   FF82TB1H5N180104H8G74GBE02FFFF82TB1H5N98G7CG28G1AGC502FFFF82X35N2C01C8H4HEGC902FFFF8H26
   G6FT2H25N98G97G14H9GDA02FFFF82G43G6FG6CG6FG72T25NACG97G14H9GDB02FFFF82G7CG53G26G6FG6CG6
   9G64P2H25NC2G7EG14H9GD302FFFF82G48G75G26G65G3AS835ND8G7CG12HCGBF02FFFF81T2H25NC2G8CG14H
   9GD402FFFF82G26G53G61G74G3AS835ND8G8AG12HCGCG2FFFF81T2H25NC2G9AG14H9GD502FFFF82G26G4CG7
   5G6DG3AS835ND8G98G12HCGC102FFFF81T2H25NF3G7EG18H9GD602FFFF82G26G52G65G64G3AS835OD017CG1
   2HCGC202FFFF81T2H25NF3G8CG18H9GD702FFFF82G26G47G72G65G65G6EG3AS835OD018AG12HCGC302FFFF8
   1T2H25NF3G9AG18H9GD802FFFF82G42G6CG26G75G65G3AW835OD0198G12HCGC402FFFF81X35N98GA6G8EHEG
   C802FFFF8H26G41G64G64G2H74G6FG2H43G75G73G74G6FG6DG2H43G6FG6CG6FG72G73O
 )
 Loop 20
  StringReplace,CCD,CCD,% Chr(70+21-A_Index),% SubStr("000000000000000000000",A_Index),All
 Loop % VarSetCapacity(CC,StrLen(CCD)//2,0)
  NumPut( "0x" . SubStr(CCD, 2*A_Index-1,2),CC,A_Index-1,"Char" )
 }
 Numput( &CC+100,CC,8 ), NumPut( &CC+36,CC,16 )
 IfNotEqual,CustomColors,0, Loop, Parse, CustomColors, |
 _ := (A_LoopField<>"" && A_Index<17) ? NumPut("0x" A_LoopField,CC,36+(4*(A_Index-1))) : 0
 Title ? DllCall( ATOU, Int,0,Int,0, Str,Title S22, UInt,22, UInt,&CC+122, UInt,44 ) : 0
 NumPut(Y,CC,112,"UShort"), NumPut(X,CC,110,"UShort"), NumPut(hWnd,CC,4)
 WinExist( "ahk_id" hWnd ) ? NumPut(0,CC,104) : 0
 RGB ? NumPut((((CR&0xFF)<<16)|(CR&0xFF00)|((CR&0xFF0000)>>16)),CC,12) : NumPut(CR,CC,12)
 If ! DllCall( "comdlg32\ChooseColorA", UInt,&CC ) || ErrorLevel
      Return
 DllCall( "msvcrt\sprintf", Str,Color, Str,"%06X", UInt, RGB ? ( (((CR:=Numget(CC,12) )
  &0xFF)<<16)|(CR&0xFF00)|((CR&0xFF0000)>>16)) : Numget(CC,12) )
Return Color
}

Posted Image

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010

hi Than, i liked this script and I decided to create my own. hope u don't mind


What's the difference? Different looks?

Cristi ®
  • Guests
  • Last active:
  • Joined: --
background color can be changed,

closed
  • Members
  • 509 posts
  • Last active: Jan 14 2012 06:14 PM
  • Joined: 07 Feb 2008
Hi Cristi

You added a nice and easy interface to change the colors and some creative code.The slider for transparency is handy!But why remove the gdip code?

I think the quality of graphics using gdip is much better.I use the clock with high transparency and gdip has the advantage that you can separate background from text when applying transparency which gives a more readable text if transparency is high and also rounded windows are much more smooth.

You can see in the picture the difference when transparency is applied ,the gdip created text is still clear.

Posted Image


Have you plans to add an alarm? (from the comments in your code).I think that will be useful.If i need to do something in 45minutes time being able to set a countdown timer/clock will surely prevent some disappointments....