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