7/30/2018 - 3:03 AM

Hotkeys AHK

Hotkeys AHK

; Script for a bunch of a+ hotkeys idek what I would do w/o.
; There's one to open Volume Mixer, Notepad, Personalization window, Dual Wallpaper, turning the volume up and down, playing and pausing mpc (mpc doesn't need to be active, how gr8), showing and hiding titlebars and moving windows by holding down alt with the left mouse button (basically AltDrag).
; Remove the semicolons in front of line 61 and 62 if you want to be able to move windows by holding down the left and right click buttons, it's a great hotkey but caused problems for me while playing vidyas, so idk use it if you wish.

#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.

; Modifiers

; # = Windows Key;
; ! = Alt;        
; ^ = Control;
; + = Shift;
; & = Used to combine keys (ctrl+alt = ^&!);

; Hide taskbar
if toggle := !toggle
WinHide ahk_class Shell_TrayWnd
WinHide Start ahk_class Button
WinShow ahk_class Shell_TrayWnd
WinShow Start ahk_class Button

; Win+A - Open Volume Mixer
    Run sndvol

; Ctrl+Alt+P - Open Personalization menu
    Run "::{26EE0668-A00A-44D7-9371-BEB064C98683}\1\::{ED834ED6-4B5A-4BFE-8F11-A626DCB6A921}"

; Ctrl+Alt+C - Open Control Panel
    Run "::{26EE0668-A00A-44D7-9371-BEB064C98683}"

; Win+N - Open Notepad
    Run Notepad

; Win+w - Open DualWallpaper
    Run "E:\Programs\DualMonitor\DualWallpaper.exe"

; Win+U - Open UxStyle
    Run "C:\UxStyle.exe"

; Media Keys - Ctrl Left/Right to previous/next song - F8 to pause/play

^NumpadEnd::Send   {Media_Prev}
F8::Send {Media_Play_Pause}
^NumpadPgdn::Send  {Media_Next}

; Win+H - Hide Titlebar
      WinSet, Style, -0xc00000, A

; Win+S - Show Titlebar
      WinSet, Style, +0xc00000, A

 ; Ctrl+Up - Turn volume up 
     SoundSet +5

; Ctrl+Down - Turn volume down
     SoundSet -5

; F7 to play/pause MPC-HC
    SendMessage,0x0111,889,,,ahk_class MediaPlayerClassicW  

; Move windows using Alt and left click (altdrag replacement), and left and right click together
;~LButton & RButton::
;~RButton & LButton::
CoordMode, Mouse  ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin% 
if EWD_WinState = 0  ; Only if the window isn't maximized 
    SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it.

GetKeyState, EWD_LButtonState, LButton, P
if EWD_LButtonState = U  ; Button has been released, so drag is complete.
    SetTimer, EWD_WatchMouse, off
GetKeyState, EWD_EscapeState, Escape, P
if EWD_EscapeState = D  ; Escape has been pressed, so drag is cancelled.
    SetTimer, EWD_WatchMouse, off
    WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY%
; Otherwise, reposition the window to match the change in mouse coordinates
; caused by the user having dragged the mouse:
CoordMode, Mouse
MouseGetPos, EWD_MouseX, EWD_MouseY
WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin%
SetWinDelay, -1   ; Makes the below move faster/smoother.
WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY
EWD_MouseStartX := EWD_MouseX  ; Update for the next timer-call to this subroutine.
EWD_MouseStartY := EWD_MouseY