-
Notifications
You must be signed in to change notification settings - Fork 29
/
mintty-quake-console.ahk
executable file
·74 lines (63 loc) · 1.94 KB
/
mintty-quake-console.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
64
65
66
67
68
69
70
71
72
73
74
#NoEnv
#SingleInstance force
SendMode Input
DetectHiddenWindows, on
; get path to cygwin from registry
RegRead, cygwinRootDir, HKEY_LOCAL_MACHINE, SOFTWARE\Cygwin\setup, rootdir
cygwinBinDir := cygwinRootDir . "\bin"
; path to mintty (same folder as script), start with default shell
minttyPath := A_WorkingDir . "\mintty.exe -"
; width of dragable window border (we hide borders offscreen)
SysGet, dragableBorderWith, 69
; width of normal window border (we hide borders offscreen)
SysGet, borderWith, 5
; height of menubar (we hide this offscreen)
SysGet, menubarHeight, 30
; real height, this doesn't work for windows classic skins
; for luna skins it works, didn't test aero yet.
menubarHeight := menubarHeight + dragableBorderWith + borderWith * 2
; initial height of console window
heightConsoleWindow := 384
init()
{
global
; get last active window
WinGet, hw_current, ID, A
Run %minttyPath%, %cygwinBinDir%, Hide, hw_mintty
WinWait ahk_pid %hw_mintty%
; MsgBox You selected %hw_mintty%
; i have no idea why, but ( %dragableBorderWith% * 2 ) doesn't work here
WinMove, ahk_pid %hw_mintty%, , -%dragableBorderWith%, -%menubarHeight%, A_ScreenWidth + 8, %heightConsoleWindow%
WinShow ahk_pid %hw_mintty%
WinActivate ahk_pid %hw_mintty%
}
toggle()
{
global
IfWinActive ahk_pid %hw_mintty%
{
; get latest size^, remembers size when toggeling
WinGetPos, minttyX, minttyY, minttyWidth, minttyLastHeight, ahk_pid %hw_mintty%
WinHide ahk_pid %hw_mintty%
; reset focus to last active window
WinActivate, ahk_id %hw_current%
}
else
{
; get last active window
WinGet, hw_current, ID, A
WinMove, ahk_pid %hw_mintty%, , -%dragableBorderWith%, -%menubarHeight%, A_ScreenWidth + ( %dragableBorderWith% * 2 ), %minttyLastHeight%
WinShow ahk_pid %hw_mintty%
WinActivate ahk_pid %hw_mintty%
}
}
#Escape::
IfWinExist ahk_pid %hw_mintty%
{
toggle()
}
else
{
init()
}
return