Skip to content

Instantly share code, notes, and snippets.

@amosbird
Created August 16, 2017 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amosbird/068229b7122e94f58f2287adb7f690b9 to your computer and use it in GitHub Desktop.
Save amosbird/068229b7122e94f58f2287adb7f690b9 to your computer and use it in GitHub Desktop.
better windows experience
#SingleInstance force
Loop, %0% ; For each parameter:
{
param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index.
params .= A_ralt . param
}
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
if not A_IsAdmin
{
If A_IsCompiled
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, params , str, A_WorkingDir, int, 1)
ExitApp
}
SetTimer, adskill, 1000
GroupAdd,ads,京东
GroupAdd,ads,系统通知
GroupAdd,ads,淘金币活动消息
GroupAdd,ads,腾讯游戏嘉年华
:*:a@::amosbird@gmail.com
^,::send, ^+{tab}
^.::send, ^{tab}
SetTitleMatchMode, 2
#WinActivateForce
ToggleWinMinimize(WindowExe)
{
DetectHiddenWindows, Off
ifWinActive, %WindowExe%
WinMinimize
Else
IfWinExist, %WindowExe%
{
WinActivate
}
Return
}
ToggleWinMinimizeQQ(WindowExe)
{
SetTitleMatchMode, 2
DetectHiddenWindows, Off
WinGetTitle, qq, A
if (qq = "QQ")
{
send, !m
Return
}
ifWinActive, %WindowExe% ,, QQ
WinMinimize
Else
IfWinExist, %WindowExe% ,, QQ
{
WinActivate
}
Return
}
;!r::ToggleWinMinimize("ahk_exe chrome.exe")
;!i::ToggleWinMinimizeQQ("ahk_class TXGuiFoundation")
!s::ToggleWinMinimize("ahk_class tSkMainForm")
!e::ToggleWinMinimize("ahk_class Vim")
!t::ToggleWinMinimize("ahk_exe AliIM.exe")
!o::ToggleWinMinimize("ahk_class CabinetWClass")
!p::ToggleWinMinimize("ahk_exe powerpnt.exe")
!x::ToggleWinMinimize("ahk_exe EXCEL.EXE")
!w::ToggleWinMinimize("ahk_exe winword.exe")
!i::ToggleWinMinimize("ahk_exe VISIO.exe")
!u::ToggleWinMinimize("ahk_exe Sumatrapdf.exe")
!y::ToggleWinMinimize("ahk_exe xmind.exe")
+Space::send, {space}
; '['
; +SC01A::Send {(}
; ']'
; +SC01B::Send {)}
; '9'
; +SC00A::Send {{}
; '0'
; +SC00B::Send {}}
AppsKey & x::send, {:}
AppsKey & c::send, {;}
AppsKey & s::send, {?}
AppsKey & w::send, {/}
AppsKey & e::send, {{}
AppsKey & r::send, {}}
AppsKey & d::send, {[}
AppsKey & f::send, {]}
AppsKey & t::send, {"}
AppsKey & g::send, {'}
AppsKey & b::send, {\}
AppsKey & v::send, {|}
AppsKey & 1::send, {6}
AppsKey & 2::send, {&}
AppsKey & 3::send, {(}
AppsKey & 4::send, {)}
AppsKey & 5::send, {^}
$+9::send, {+}
$+0::send, {=}
$`;::send, {_}
$+`;::send, {`-}
$_::send, {!}
^j::send, {Down}
^k::send, {Up}
^+i::send, +{tab}
!r::Reload
; readline key mapping
#If !WinActive("ahk_class Vim") &&
!WinActive("ahk_class VirtualConsoleClass") &&
!WinActive("ahk_class mintty") &&
!WinActive("ahk_exe devenv.exe") &&
!WinActive("ahk_exe Code.exe")
!a::send, {Home}
^e::send, {End}
^d::send, {Delete}
^u::send, +{Home}{Delete}
^i::send, {tab}
!k::send, +{End}{Delete}
!f::send, #^{Right}
!b::send, #^{Left}
!Backspace::send, #^+{Left}{Delete}
!d::send, #^+{Right}{Delete}
#If
adskill:
loop, {
WinWait, ahk_group ads
WinClose, ahk_group ads
}
return
#IfWinActive, ahk_class TXGuiFoundation
^j::Down
^k::Up
#IfWinActive
#IfWinActive, ahk_class WeChatMainWndForPC
^j::Down
^k::Up
#IfWinActive
AppsKey & 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.
return
EWD_WatchMouse:
GetKeyState, EWD_LButtonState, LButton, P
if EWD_LButtonState = U ; Button has been released, so drag is complete.
{
SetTimer, EWD_WatchMouse, off
return
}
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%
return
}
; 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
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment