Skip to content

Instantly share code, notes, and snippets.

@maykar
Last active June 16, 2020 21:57
Show Gist options
  • Save maykar/b67e81e745d52db989fa582d5d472e43 to your computer and use it in GitHub Desktop.
Save maykar/b67e81e745d52db989fa582d5d472e43 to your computer and use it in GitHub Desktop.
[AutoHotkey] Animated Guake-like dropdown visor for any window. By default this script is setup for fman (http://fman.io) with the hotkey F12, but it is configurable by modifying config. Inspired by and modified from this gist by Jon Dolan: https://gist.github.com/jondolan/9eb0a9eefffac3ae67445763973e9f58
; Animated Guake-like dropdown visor for any window.
; By default this script is setup for fman (fman.io) with the hotkey F12,
; but it is configurable by modifying config below.
; Inspired by and modified from this gist by Jon Dolan
; https://gist.github.com/jondolan/9eb0a9eefffac3ae67445763973e9f58
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode 3
SetWinDelay, 0
;;;; CONFIG OPTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
hotkey = F12 ; Hotkey to trigger. https://autohotkey.com/docs/KeyList.htm
animation := true ; Toggle animations on/off.
animation_speed := 1.5 ; Greater than zero. 0.1 is very slow, 10 is very fast.
win_title = fman ; Title of window to be used.
win_width_percent := 100 ; Window size as percent of screen. 0 for no resizing.
win_height_percent := 50
win_opacity_percent := 95 ; Window transparency. 100 is opaque, 0 transparent.
; Some windows may need resized or shifted in order to fill space.
horizontal_shift := -4
vertical_shift := 0
add_pixels_to_width := 8
add_pixels_to_height := 0
; Return focus back to previously active window when closed.
return_focus := false
; Hide the top title bar of window.
hide_title_bar := true
; Path to the application to open if not already running.
path_to_app = C:\Users\xxxx\AppData\Local\fman\Versions\1.6.6\fman.exe
;;;; CONFIG END ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hotkey, %hotkey%, trigger
win_height := A_ScreenHeight * (win_height_percent/100) + add_pixels_to_height
win_width := A_ScreenWidth * (win_width_percent/100) + add_pixels_to_width
win_opacity := 255 * (win_opacity_percent/100)
currentWindow := 0
previousWindow := 0
if (hide_title_bar) {
SysGet, TitleBarHeight, 32
SysGet, TitleBarPadding, 4
TitleBarHeight := -(TitleBarHeight + TitleBarPadding)
}
else {
TitleBarHeight := 0
}
TitleBarHeight += vertical_shift
loop {
WinGet, currentWindow, ID, A
WinWaitNotActive, ahk_id %currentWindow%
IfWinNotActive, %win_title%
WinSet, Transparent, On, %win_title%
previousWindow := currentWindow
}
trigger:
IfWinExist, %win_title%
{
WinMove, %win_title%, , %horizontal_shift%, , %win_width%, %win_height%
IfWinNotActive, %win_title%
{
WinMove, %win_title%, , ,-%win_height%
WinSet, Transparent, %win_opacity%, %win_title%
WinActivate, %win_title%
Gosub SlideDown
}
else
{
Gosub SlideUp
WinSet, Transparent, On, %win_title%
if (return_focus)
WinActivate, ahk_id %previousWindow%
else
WinActivate, ahk_class Progman
}
}
else
{
run, %path_to_app%
WinWait, %win_title%, , 15
if ErrorLevel {
return
}
else {
WinSet, Transparent, %win_opacity%, %win_title%
WinMove, %win_title%, , %horizontal_shift%, , %win_width%, %win_height%
Gosub SlideDown
}
}
return
SlideUp:
if (animation) {
x := TitleBarHeight
while (x > -win_height) {
x -= animation_speed
WinMove, %win_title%, , , %x%
}
}
else {
WinMove, %win_title%, , , -%win_height%
}
return
SlideDown:
if (animation) {
x := -win_height
while (x < TitleBarHeight) {
x += animation_speed
if (x > TitleBarHeight) {
WinMove, %win_title%, , , %TitleBarHeight%
return
}
WinMove, %win_title%, , , %x%
}
}
else {
WinMove, %win_title%, , , %TitleBarHeight%
}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment