Skip to content

Instantly share code, notes, and snippets.

@strayge
Last active March 18, 2018 10:19
Show Gist options
  • Save strayge/8ec9c09046781d3220caa4946f5209d0 to your computer and use it in GitHub Desktop.
Save strayge/8ec9c09046781d3220caa4946f5209d0 to your computer and use it in GitHub Desktop.
windows shortcuts
; # - win, ! - alt, ^ - ctrl, + - shift
#MaxHotkeysPerInterval 200
global en := DllCall("LoadKeyboardLayout", "Str", "00000409", "Int", 1)
ChangeActiveLayoutToEng()
{
WinGet, window_id, ID, A
pid := DllCall("GetWindowThreadProcessId", "UInt", window_id, "Ptr", 0)
layout := DllCall("GetKeyboardLayout", "UInt", pid)
if (layout != en)
{
sleep 200
PostMessage 0x50, 0, %en%,, A
sleep 200
WinActivate, ahk_id %window_id%
sleep 200
}
}
; hibernate win+q
#sc010::DllCall("PowrProf\SetSuspendState", "int", 1, "int", 1, "int", 1)
return
; sleep win+s
#sc01F::
ChangeActiveLayoutToEng()
Send #{vk58sc02D} ; win+x
Send {vk55sc016} ; u
Send {vk53sc01F} ; s
return
; explorer: backspace - top level folder
;#IfWinActive, ahk_class CabinetWClass
;Backspace::SendInput {Alt Down}{Up}{Alt Up}
;return
;#IfWinActive
; explorer: win+c: cmd in current folder
#IfWinActive, ahk_class CabinetWClass
; win+c
#sc02E::
;ClipSaved := ClipboardAll
WinGetText, full_path, A
StringSplit, word_array, full_path, `n
Loop, %word_array0%
{
IfInString, word_array%A_Index%, Address
{
full_path := word_array%A_Index%
break
}
}
full_path := RegExReplace(full_path, "^Address: ", "")
StringReplace, full_path, full_path, `r, , all
IfInString full_path, \
{
Run, cmd /K cd /D "%full_path%"
}
else
{
;Run, cmd /K cd /D "C:\ "
ChangeActiveLayoutToEng()
Send !{vk44sc020} ; !d
Send {ASC 99}{ASC 109}{ASC 100} ; cmd
Send {Enter}
}
return
#IfWinActive
; explorer: win+shift+c: cmd in current folder as admin
#IfWinActive, ahk_class CabinetWClass
; win+shift+c
#+sc02E::
;ClipSaved := ClipboardAll
WinGetText, full_path, A
StringSplit, word_array, full_path, `n
Loop, %word_array0%
{
IfInString, word_array%A_Index%, Address
{
full_path := word_array%A_Index%
break
}
}
full_path := RegExReplace(full_path, "^Address: ", "")
StringReplace, full_path, full_path, `r, , all
IfInString full_path, \
{
Run *RunAs "cmd" /K cd /D "%full_path%"
; /K cd /D "%full_path%"
}
else
{
; powershell.exe -Command "Start-Process cmd \"/k cd /d $((Resolve-Path .\).Path)\" -Verb RunAs"
; sleep, 1000
ClipboardSaved := ClipboardAll ; save
Clipboard = powershell.exe -Command "Start-Process cmd \"/k cd /d $((Resolve-Path .\).Path)\" -Verb RunAs"
ChangeActiveLayoutToEng()
Send !{vk44sc020} ; !d
sleep 100
Send, ^{sc02F} ; ctrl+v
sleep 100
Send {Enter}
Clipboard := ClipboardSaved ; restore
ClipSaved = ; memory free (in case of large clip size)
}
return
#IfWinActive
; always on top
#SPACE:: Winset, Alwaysontop, , A
return
; transparency increase
#WheelUp::
WinGet, transparency, Transparent, A
if (transparency = "")
{
transparency := 255
}
if transparency < 255
{
transparency := Transparency + 10
} else {
transparency := 255
}
Winset, Transparent, %transparency%, A
return
; transparency decrease
#WheelDown::
WinGet, transparency, Transparent, A
if (transparency = "")
{
transparency := 255
}
if transparency > 30
{
transparency := transparency - 10
} else {
transparency := 30
}
Winset, Transparent, %transparency%, A
return
#0::
Winset, Transparent, 255, A
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment