From bd39cc3a13fd2f1a97d323c2ed12e735143c0568 Mon Sep 17 00:00:00 2001 From: breadcat Date: Sat, 17 Aug 2013 16:20:05 +0100 Subject: Removed MouseWin, split tile to hotkeys+functions MouseWin may return one day, it was being glitchy as an include and doesn't warrant an additional process. --- functions.ahk | 32 ++++++++++++++++++++ index.ahk | 36 ++++++++++++++-------- mousewin.ahk | 97 ----------------------------------------------------------- tiling.ahk | 46 ---------------------------- 4 files changed, 56 insertions(+), 155 deletions(-) create mode 100644 functions.ahk delete mode 100644 mousewin.ahk delete mode 100644 tiling.ahk diff --git a/functions.ahk b/functions.ahk new file mode 100644 index 0000000..cf438c2 --- /dev/null +++ b/functions.ahk @@ -0,0 +1,32 @@ + +Shift(Pos) +{ + WinGetClass, class, A + IfInString , shell_TrayWnd,Progman,Button,DV2ControlHost, %class% + Return + IfWinExist,ahk_class Shell_TrayWnd + SysGet, m, MonitorWorkArea + Else SysGet, m, Monitor + WinGetPos, MWT_X, MWT_Y, MWT_W, MWT_H, A + SendMessage, 0x1F,,,, A + WinGet, MWT_active, MinMax, A + if (MWT_active = 1) + WinRestore, A + If (Pos = "T") + WinMove, A,, 0, 0, mRight, mBottom/2 + If (Pos = "B") + WinMove, A,, 0, mBottom/2, mRight, mBottom/2 + If (Pos = "L") + WinMove, A,, 0, 0, mRight/2, mBottom + If (Pos = "R") + WinMove, A,, mRight/2, 0, mRight/2, mBottom + If (Pos = "TL") + WinMove, A,, 0, 0, mRight/2, mBottom/2 + If (Pos = "TR") + WinMove, A,, mRight/2, 0, mRight/2, mBottom/2 + If (Pos = "BR") + WinMove, A,, mRight/2, mBottom/2, mRight/2, mBottom/2 + If (Pos = "BL") + WinMove, A,, 0, mBottom/2, mRight/2, mBottom/2 +} +Return diff --git a/index.ahk b/index.ahk index 38f30d8..2ee4568 100644 --- a/index.ahk +++ b/index.ahk @@ -1,10 +1,9 @@ + ; ^ctrl #win !alt +shift ;environment #NoEnv #SingleInstance,Force -SetWinDelay, -1 ;don't delay window opening -SetBatchLines, -1 ;run script as fast as possible SetWorkingDir, C:\Users\%A_UserName% ;keystates @@ -14,7 +13,7 @@ SetNumLockState, AlwaysOn ;hotkeys #q::Run notepad -^q::Send {ALTDOWN}{F4}{ALTUP} ;quit most programs +^q::Send !{F4} ;quit most programs ^!q::Run "AppData\Local\Chromium\User Data\Default\User StyleSheets\Custom.css" ;chrome global css #w::Run "C:\Program Files (x86)\Chromium\chrome.exe" #+w::Run "C:\Program Files (x86)\Chromium\chrome.exe" -incognito @@ -32,7 +31,7 @@ RAlt & k::AltTab Capslock::Backspace ;remap logitech m570 buttons -XButton1::Send {Click}{Click} ;double click +XButton1::Send {Click 2} ;double click XButton2::Send {MButton} ;wheel click ;bullshit ps/2 to usb adapter workarounds @@ -46,15 +45,15 @@ XButton2::Send {MButton} ;wheel click ::(tm)::™ ;change screen res (resswitch.exe - http://www.naughter.com/qres.html) -^!+UP::run %A_ScriptDir%\resswitch.exe /WIDTH:1920 /HEIGHT:1080 -^!+DOWN::run %A_ScriptDir%\resswitch.exe /WIDTH:1280 /HEIGHT:720 +^!+Up::run %A_ScriptDir%\resswitch.exe /WIDTH:1920 /HEIGHT:1080 +^!+Down::run %A_ScriptDir%\resswitch.exe /WIDTH:1280 /HEIGHT:720 ;date/time insertion -#space:: +#Space:: FormatTime, CurrentDateTime,, yyyy-MM-dd SendInput %CurrentDateTime% return -#+space:: +#+Space:: FormatTime, CurrentDateTime,, yyyy-MM-ddTHH:mm SendInput %CurrentDateTime% return @@ -66,8 +65,21 @@ Insert:: clipboard = %newclipboard%`r`n%clipboard% return +;tiling +#Up::WinMaximize, A +#Down::WinMinimize, A +#Left::Shift("L") +#Right::Shift("R") +#Numpad1::Shift("BL") +#Numpad2::Shift("B") +#Numpad3::Shift("BR") +#Numpad4::Shift("L") +#Numpad5::WinMaximize, A +#Numpad6::Shift("R") +#Numpad7::Shift("TL") +#Numpad8::Shift("T") +#Numpad9::Shift("TR") + ;includes -#Include, %A_ScriptDir%\appspecific.ahk ;application specific hotkeys -#Include, %A_ScriptDir%\tiling.ahk ;win+numpad tiling -#Include, %A_ScriptDir%\mousewin.ahk ;control windows like kde does -#Include, %A_ScriptDir%\secret.ahk ;personally identifiable data +#Include, %A_ScriptDir%\appspecific.ahk ;too many to include in index, deserves separating +#Include, %A_ScriptDir%\functions.ahk ;functions don't belong in index \ No newline at end of file diff --git a/mousewin.ahk b/mousewin.ahk deleted file mode 100644 index 16caf26..0000000 --- a/mousewin.ahk +++ /dev/null @@ -1,97 +0,0 @@ -; Easy Window Dragging -- KDE style (requires XP/2k/NT) -- by Jonny -; http://www.autohotkey.com -; This script makes it much easier to move or resize a window: 1) Hold down -; the ALT key and LEFT-click anywhere inside a window to drag it to a new -; location; 2) Hold down ALT and RIGHT-click-drag anywhere inside a window -; to easily resize it; 3) Press ALT twice, but before releasing it the second -; time, left-click to minimize the window under the mouse cursor, right-click -; to maximize it, or middle-click to close it. - -; This script was inspired by and built on many like it -; in the forum. Thanks go out to ck, thinkstorm, Chris, -; and aurelian for a job well done. - -; Change history: -; November 07, 2006: Optimized resizing code in !RButton, courtesy of bluedawn. -; February 05, 2006: Fixed double-alt (the ~Alt hotkey) to work with latest versions of AHK. - -; The Double-Alt modifier is activated by pressing -; Alt twice, much like a double-click. Hold the second -; press down until you click. -; -; The shortcuts: -; Alt + Left Button : Drag to move a window. -; Alt + Right Button : Drag to resize a window. -; -; You can optionally release Alt after the first -; click rather than holding it down the whole time. - -; This is the setting that runs smoothest on my -; system. Depending on your video card and cpu -; power, you may want to raise or lower this value. -SetWinDelay,2 - -CoordMode,Mouse -return - -!LButton:: -; Get the initial mouse position and window id, and -; abort if the window is maximized. -MouseGetPos,KDE_X1,KDE_Y1,KDE_id -WinGet,KDE_Win,MinMax,ahk_id %KDE_id% -If KDE_Win - return -; Get the initial window position. -WinGetPos,KDE_WinX1,KDE_WinY1,,,ahk_id %KDE_id% -Loop -{ - GetKeyState,KDE_Button,LButton,P ; Break if button has been released. - If KDE_Button = U - break - MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position. - KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position. - KDE_Y2 -= KDE_Y1 - KDE_WinX2 := (KDE_WinX1 + KDE_X2) ; Apply this offset to the window position. - KDE_WinY2 := (KDE_WinY1 + KDE_Y2) - WinMove,ahk_id %KDE_id%,,%KDE_WinX2%,%KDE_WinY2% ; Move the window to the new position. -} -return - -!RButton:: -; Get the initial mouse position and window id, and -; abort if the window is maximized. -MouseGetPos,KDE_X1,KDE_Y1,KDE_id -WinGet,KDE_Win,MinMax,ahk_id %KDE_id% -If KDE_Win - return -; Get the initial window position and size. -WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id% -; Define the window region the mouse is currently in. -; The four regions are Up and Left, Up and Right, Down and Left, Down and Right. -If (KDE_X1 < KDE_WinX1 + KDE_WinW / 2) - KDE_WinLeft := 1 -Else - KDE_WinLeft := -1 -If (KDE_Y1 < KDE_WinY1 + KDE_WinH / 2) - KDE_WinUp := 1 -Else - KDE_WinUp := -1 -Loop -{ - GetKeyState,KDE_Button,RButton,P ; Break if button has been released. - If KDE_Button = U - break - MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position. - ; Get the current window position and size. - WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id% - KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position. - KDE_Y2 -= KDE_Y1 - ; Then, act according to the defined region. - WinMove,ahk_id %KDE_id%,, KDE_WinX1 + (KDE_WinLeft+1)/2*KDE_X2 ; X of resized window - , KDE_WinY1 + (KDE_WinUp+1)/2*KDE_Y2 ; Y of resized window - , KDE_WinW - KDE_WinLeft *KDE_X2 ; W of resized window - , KDE_WinH - KDE_WinUp *KDE_Y2 ; H of resized window - KDE_X1 := (KDE_X2 + KDE_X1) ; Reset the initial position for the next iteration. - KDE_Y1 := (KDE_Y2 + KDE_Y1) -} -return diff --git a/tiling.ahk b/tiling.ahk deleted file mode 100644 index a1f1cea..0000000 --- a/tiling.ahk +++ /dev/null @@ -1,46 +0,0 @@ - -Shift(Pos) -{ - WinGetClass, class, A - IfInString , shell_TrayWnd,Progman,Button,DV2ControlHost, %class% - Return - IfWinExist,ahk_class Shell_TrayWnd - SysGet, m, MonitorWorkArea - Else SysGet, m, Monitor - WinGetPos, MWT_X, MWT_Y, MWT_W, MWT_H, A - SendMessage, 0x1F,,,, A - WinGet, MWT_active, MinMax, A - if (MWT_active = 1) - WinRestore, A - If (Pos = "T") - WinMove, A,, 0, 0, mRight, mBottom/2 - If (Pos = "B") - WinMove, A,, 0, mBottom/2, mRight, mBottom/2 - If (Pos = "L") - WinMove, A,, 0, 0, mRight/2, mBottom - If (Pos = "R") - WinMove, A,, mRight/2, 0, mRight/2, mBottom - If (Pos = "TL") - WinMove, A,, 0, 0, mRight/2, mBottom/2 - If (Pos = "TR") - WinMove, A,, mRight/2, 0, mRight/2, mBottom/2 - If (Pos = "BR") - WinMove, A,, mRight/2, mBottom/2, mRight/2, mBottom/2 - If (Pos = "BL") - WinMove, A,, 0, mBottom/2, mRight/2, mBottom/2 -} -Return - -#Up::WinMaximize, A -#Down::WinMinimize, A -#Left::Shift("L") -#Right::Shift("R") -#Numpad1::Shift("BL") -#Numpad2::Shift("B") -#Numpad3::Shift("BR") -#Numpad4::Shift("L") -#Numpad5::WinMaximize, A -#Numpad6::Shift("R") -#Numpad7::Shift("TL") -#Numpad8::Shift("T") -#Numpad9::Shift("TR") \ No newline at end of file -- cgit v1.2.3