Skip to content

Instantly share code, notes, and snippets.

@akaleeroy
Last active November 10, 2019 12:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akaleeroy/c52ef0639fee5e22378aab1f102de3f9 to your computer and use it in GitHub Desktop.
Save akaleeroy/c52ef0639fee5e22378aab1f102de3f9 to your computer and use it in GitHub Desktop.
Movable Blank - Blank fullscren GUI window that's click-through
; Movable blank
; Blank fullscren GUI window that's click-through
; It's not power-saving but allows you to peek through when you need it.
; For power saving consider just switching (native Windows shortcut Win + P)
; Move it from screen to screen (native Windows shortcut Win + Shift + Left/Right)
; Make it translucent (Helpers enhancement Win + PgUp/PgDn or Win + WheelUp/WheelDn)
; Close it like a regular window (native Windows Alt + F4)
; Start multiple instances for multiple monitors
; I trigger it with a hotkey defined in another script:
; #s::
; Run, D:\Documents\AutoHotkey\MovableBlank.ahk
; return
#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.
#SingleInstance, off ; Allow multiple instances for multiple displays
#NoTrayIcon
; Menu, Tray, Icon, imageres.dll, 114 ; Empty icon
Menu, Tray, Icon, shell32.dll, 175 ; Screen diagonal half white half black
CoordMode, Mouse, Screen
; Current is where the mouse cursor rests
MouseGetPos, mx, my
Gui, Color, Black
; Disable borders and titlebars. Alternatively: Gui, -0xC00000 +0x8000000
; Add +ToolWindow and the window will have no taskbar button.
; You won't be able to select it though, thus no transparency control
Gui, -Caption +AlwaysOnTop
SysGet, monitorsCount, 80
Loop %monitorsCount% {
SysGet, monitor, Monitor, %A_Index%
; Stretch full-screen
if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom) {
; Do not allow several blanks stacked on the same screen
if (!WinExist("MovableBlank " . A_Index)) {
; Added NoActivate to avoid focus stealing
Gui, Show, % "W" . Abs(monitorLeft) + Abs(monitorRight) . " H" . A_ScreenHeight . " X" . monitorLeft . " Y" . monitorTop . " NoActivate", MovableBlank %A_Index%
}
}
}
; Get window ID for next step, matching just the beginning
WinGet, blankid, ID, MovableBlank
; Make click-through: 0x20 = WS_EX_CLICKTHROUGH
; Only works when translucent. No mis-clicking when window is fully opaque. Awesome!
WinSet, ExStyle, +0x20, ahk_id %blankid%
return
GuiContextMenu: ; RightClick to close
GuiClose:
ExitApp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment