-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
BgInfo-Helper.ahk
63 lines (53 loc) · 1.76 KB
/
BgInfo-Helper.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
;@Ahk2Exe-SetCopyright Bennett Blodinger
;@Ahk2Exe-SetDescription Quality of life improvements for Sysinternal's BgInfo
;@Ahk2Exe-SetLanguage 0x0409
;@Ahk2Exe-SetName BgInfo-Helper
;@Ahk2Exe-SetVersion 1.0.0
;@Ahk2Exe-IgnoreBegin
#Warn
;@Ahk2Exe-IgnoreEnd
/*@Ahk2Exe-Keep
#NoTrayIcon
ListLines Off
*/
#NoEnv
#Persistent
#SingleInstance, Force
Process, Priority, , Low
#Include, %A_ScriptDir%\Lib\Gdip_All.ahk
global executable, global parameters
; Get bitness
if (A_Is64bitOS) {
executable := "BgInfo64.exe"
} else {
executable := "BgInfo.exe"
}
; Parse arguments
For Each, argument In A_Args {
parameters .= (parameters <> "" ? A_Space : "") . argument
}
; Convert unsupported image formats
ConvertWallpaper(format:="bmp") {
RegRead, currentWallpaper, HKEY_CURRENT_USER\Control Panel\Desktop, WallPaper
SplitPath, currentWallpaper, currentWallpaper_outFileName, currentWallpaper_outDir, currentWallpaper_outExtension, currentWallpaper_outNameNoExt, currentWallpaper_outDrive
StringUpper, currentWallpaper_outExtension, currentWallpaper_outExtension
If (!RegExMatch(currentWallpaper_outExtension, "^(?i:BMP|JPG|GIF)$")) {
If (pToken0 := Gdip_Startup()) {
convertedWallpaper := A_Temp . "\" . currentWallpaper_outNameNoExt . "." . format
pBitmap0 := Gdip_CreateBitmapFromFile(currentWallpaper)
Gdip_SaveBitmapToFile(pBitmap0, convertedWallpaper)
Gdip_DisposeImage(pBitmap0)
Gdip_Shutdown(pToken0)
}
DllCall("SystemParametersInfo", Int, 0x14, Int, 0, Str, convertedWallpaper, Int, 3)
}
}
; Refresh BgInfo at startup
WM_DISPLAYCHANGE(0, 0)
; Listen for resolution changes
OnMessage(0x7E, "WM_DISPLAYCHANGE")
WM_DISPLAYCHANGE(wParam, lParam) {
ConvertWallpaper("bmp")
Run, %executable% %parameters%
DllCall("SetProcessWorkingSetSize", Int, -1, Int, -1, Int, -1)
}