GDIP时钟

/*
	AutoHotkey Version:				1.1.26.00
	Language:						English
	Platform:						Win XP, Win 7, Win 8.1, Win 10
	Author:							Delta
	Contact information:			octalblockmc@gmail.com

	|-------------------------------------------------------|
	|	Hotkeys:											|
	|			None										|
	|-------------------------------------------------------|
*/

#NoEnv
#SingleInstance Force
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#Include, %A_ScriptDir%\Gdip.ahk
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode, Input

OnExit("Exit")
Menu, Tray, NoStandard
Menu, Tray, Add, Restore Clock, Show
Menu, Tray, Add, Hide Clock, Hide
Menu, Tray, Add
Menu, Tray, Add, Exit
Menu, Tray, Tip, GDIPlus Clock
Menu, Tray, Icon, % A_WinDir "\system32\SHELL32.dll", 266
Clock(0, 0, 1)
Loop(Loop_Clock := 1)
Return

Esc::
Exit()
Return

Show() 
{
	Clock(0, 0, 1)
	Loop(1)
}

Clock(OutX, OutY, Loop_Clock) 
{
	If (Loop_Clock = 0)
		Return
	If (!pToken := Gdip_Startup()) 
	{
		MsgBox, 48, GDIPlus Error!, GDIPlus failed to start. Please ensure you have gdiplus on your system, 5
		ExitApp
	}
	Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
	Gui, 1: Show, NA, GDIPlus Clock
	Width := 500, Height := 500
	OptionsH := "x-32p y6p w80p Centered cAAFFFFFF r4 s29 Bold"
	OptionsM := "x-18p y7p w80p Centered cAAFFFFFF r4 s32 Bold"
	OptionsA_P := "x-28p y15p w80p Centered cAAFFFFFF r4 s20 Bold"
	FormatTime, TimeH,, h
	

	FormatTime, TimeM,, mm
	FormatTime, TimeA_P,, tt
	hwnd1 := WinExist()
	hbm := CreateDIBSection(Width, Height)
	hdc := CreateCompatibleDC()
	obm := SelectObject(hdc, hbm)
	G := Gdip_GraphicsFromHDC(hdc)
	Gdip_SetSmoothingMode(G, 5)
	pBrush := Gdip_BrushCreateSolid(0xFF2A2A2D)
	Gdip_FillEllipse(G, pBrush, 2, 4, 75, 75)
	pBrush := Gdip_BrushCreateSolid(0xFF000000)
	Gdip_FillEllipse(G, pBrush, 35, 60, 50, 50)
	pBrush := Gdip_BrushCreateSolid(0xFF111111)
	Gdip_FillEllipse(G, pBrush, 60, 0, 100, 100)
	; Font := "Marlett" ;System items. Must keep for custom program icons
	Font := "Arial"
	If (!Gdip_FontFamilyCreate(Font)) {
		MsgBox, 48, Font error!, The font specified:`n===================`n%Font%`n===================`nDoes not exist on the System.
		ExitApp
	}
	Gdip_TextToGraphics(G, TimeH, OptionsH, Font, Width, Height)
	Gdip_TextToGraphics(G, TimeM, OptionsM, Font, Width, Height)
	Gdip_TextToGraphics(G, TimeA_P, OptionsA_P, Font, Width, Height)
	Gdip_DeleteBrush(pBrush)
	UpdateLayeredWindow(hwnd1, hdc, (OutX) ? OutX : 0, (OutY) ? OutY : 0, Width, Height)
	SelectObject(hdc, obm)
	DeleteObject(hbm)
	DeleteDC(hdc)
	Gdip_DeleteGraphics(G)
	OnMessage(0x201, "Move")
	OnMessage(0x205, "Menu")
	Menu, Tray, Disable, Restore Clock
	Menu, Tray, Enable, Hide Clock
	Return
}

Hide() 
{
	Gdip_Shutdown(pToken)
	Gui, 1:Destroy
	Menu, Tray, Enable, Restore Clock
	Menu, Tray, Disable, Hide Clock
	Loop_Clock := 0
	Clock(0, 0, Loop_Clock)
}

Exit() 
{
	Hide()
	ExitApp
}

Move(wParam := 0, lParam := 0, msg := "", hwnd := "")
{
	x := lParam & 0xFFFF
	y := lParam >> 16

	PostMessage, 0xA1, 2
}

Menu(wParam, lParam, msg, hwnd) 
{
	x := lParam & 0xFFFF
	y := lParam >> 16

	Menu, Tray, Show
}

Loop(Loop_Clock) 
{
	If (Loop_Clock = 1) 
	{
		Loop 
		{
			WinGetPos, OutX, OutY,,, GDIPlus Clock
			Width := 500, Height := 500
			UpdateLayeredWindow(hwnd1, hdc, OutX, OutY, Width, Height)
			Sleep % 1 * 100
			If (Loop_Clock = 0)
				Break
		}
	} Else If (Loop_Clock = 0) {
		Return
	}
}

GDIP库文件请到这个页面自行下载!http://www.autoahk.com/archives/11396

给TA买糖
共{{data.count}}人
人已赞赏
AHKV1

免费脚本定制(1)快捷键复制当前编辑excel文档为模板文档

2018-8-27 21:18:29

AHKV1学习

AutoHotKey系列教程中级教程第三节第五课:函数对象

2018-8-29 13:52:35

4 条回复 A文章作者 M管理员
  1. Modifier

    哇,真好看!

    • 1河许人

      忘了贴个图上去了

  2. ahker

    只有图标是为什么

    • 1河许人

      我这里运行正常,看下源代码,是不是有什么问题!

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索