Last active
September 3, 2023 06:46
-
-
Save emvaized/fd63582d26a583033f983e0c05f5fcd5 to your computer and use it in GitHub Desktop.
Autohotkey script to fade out window of drag/resize
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; This AHK script makes dragged or resized windows semi-transparent, with nice fade in and fade out animation | |
; It is intended to recreate similar Compiz effect on KDE Plasma | |
; Source of window hook: http://forum.script-coding.com/viewtopic.php?pid=95736#p95736 | |
#NoEnv | |
#SingleInstance Force | |
#Persistent | |
SetBatchLines,-1 | |
HookProcAdr := RegisterCallback( "HookProc", "F" ), hWinEventHook := SetWinEventHook( 0x1, 0x17, 0, HookProcAdr, 0, 0, 0 ) | |
SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags) | |
{ | |
DllCall("CoInitialize", Uint, 0) | |
return DllCall("SetWinEventHook", Uint,eventMin , Uint,eventMax , Uint,hmodWinEventProc | |
, Uint,lpfnWinEventProc, Uint,idProcess, Uint,idThread, Uint,dwFlags) | |
} | |
HookProc( hWinEventHook, Event, hWnd, idObject, idChild, dwEventThread, dwmsEventTime ) | |
{ | |
; EVENT_SYSTEM_MOVESIZESTART | |
if (Event = 10) { | |
FadeOutWindow(Hwnd, 200, 10) | |
} | |
; EVENT_SYSTEM_MOVESIZEEND | |
else if (Event = 11) { | |
FadeInWindow(Hwnd, 255, 10) | |
} | |
} | |
FadeOutWindow(windowId = "A", end = 0, speed = 10) | |
{ | |
WinGet, currentTrans, Transparent, ahk_id %windowId% | |
If (currentTrans == "") | |
{ | |
WinSet, Trans, 255, ahk_id %windowId% | |
WinGet, currentTrans, Transparent, ahk_id %windowId% | |
} | |
While, (currentTrans > end) | |
{ | |
Sleep, % speed / 2 | |
Trans := currentTrans - speed | |
WinSet, Trans, %Trans%, ahk_id %windowId% | |
WinGet, currentTrans, Transparent, ahk_id %windowId% | |
} | |
} | |
FadeInWindow(windowId = "A", end = 0, speed = 10) | |
{ | |
WinGet, currentTrans, Transparent, ahk_id %windowId% | |
If (currentTrans == "") | |
{ | |
WinSet, Trans, 255, ahk_id %windowId% | |
WinGet, currentTrans, Transparent, ahk_id %windowId% | |
} | |
While, (currentTrans < end) | |
{ | |
Sleep, % speed / 2 | |
Trans := currentTrans + speed | |
WinSet, Trans, %Trans%, ahk_id %windowId% | |
WinGet, currentTrans, Transparent, ahk_id %windowId% | |
} | |
} | |
return |
Author
emvaized
commented
Sep 2, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment