Skip to content

Instantly share code, notes, and snippets.

@benyaminl
Last active October 30, 2021 15:11
Show Gist options
  • Save benyaminl/44c473e6ebb8acde47a90a6e73374847 to your computer and use it in GitHub Desktop.
Save benyaminl/44c473e6ebb8acde47a90a6e73374847 to your computer and use it in GitHub Desktop.
Remaping the X220 Key for some usage like Browser back and Forward into PgUp and Down to various app, like Acrobat, Mendeley, Vim, Word, 7zip, Etc
#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.
SetTitleMatchMode, 2 ; contain
; remap global Win+E jadi Win+1
#e::#1
;#z::#!s
; Calendar
#c::#!d
; Not Applicable, to slow
; winToggle = true
;
; AppsKey::
; KeyWait, AppsKey ; https://www.autohotkey.com/boards/viewtopic.php?t=10747
; If (A_TimeSinceThisHotkey > 150) {
; If (winToggle) {
; Send {RWin up}
; ToolTip, Win Key Released
; SetTimer, RemoveToolTip, -2500
; }
; Else {
; Send {RWin down}
; ToolTip, Win Key Pressed
; SetTimer, RemoveToolTip, -2500
; }
; winToggle := !winToggle
; }
; Else
; {
; Send {AppsKey}
; }
; return
;
; RemoveToolTip:
; ToolTip
; return
; #IfWinExist ahk_class Notepad
; #n::WinActivate ; Activates the window found by #IfWin.
#F1::#5
#F2::#6
#F3::#7
#F4::#8
#Esc::#9
#`::#0
#s::
If WinExist("ahk_exe Sumatrapdf.exe")
{
if (WinActive("ahk_exe Sumatrapdf.exe") == 0) {
WinActivate
;GroupAdd,SumatraPDF, ahk_class SUMATRA_PDF_FRAME
;GroupActivate,SumatraPDF,r
} else {
WinMinimize
;GroupDeactivate,SumatraPDF
}
}
else
{
Run C:\Apps\Sumatrapdf.exe
}
return
#n::
If WinExist("ahk_exe notepad.exe")
{
if (WinActive("ahk_exe notepad.exe") == 0) {
WinActivate
} else {
WinMinimize
}
}
else if WinExist("ahk_exe notepad2.exe") {
if (WinActive("ahk_exe notepad2.exe") == 0) {
WinActivate
} else {
WinMinimize
}
}
else
{
Run notepad.exe
}
return
; Open Firefox
#!b::
If WinExist("ahk_exe firefox.exe") {
if (WinActive("ahk_exe firefox.exe") == 0) {
WinActivate
} else {
WinMinimize
}
} else {
;Run "C:\Program Files\Mozilla Firefox\firefox.exe"
Run, firefox.exe, "C:\Program Files\Mozilla Firefox"
}
return
; Open GVIM kalau ga ada, kalau ada switch ke GVIM yang ada
#g::
If WinExist("ahk_exe gvim.exe")
{
if (WinActive("ahk_exe gvim.exe") == 0) {
WinActivate
} else {
WinMinimize
}
}
else
{
Run gvim.exe
}
return
; Remap Tab in Notepad
#IfWinActive, Notepad
Tab::Send {SPACE}{SPACE}{SPACE}{SPACE}
#IfWinActive
; Show Quick Control
#q::
Send #b
Send +{Tab}
return
; End quick control
#IfWinActive, Acrobat ; hotstrings & hotkeys only works in Acrobat
Browser_Back::!Left
Browser_Forward::!Right
Return
#IfWinActive
#If WinActive("ahk_exe winword.exe") || WinActive("ahk_exe MendeleyDesktop.exe") ; Word
Browser_Back::Send {PgUp}
Browser_Forward::Send {PgDn}
; Map CTRL+TAB, make word application like tabbing!
^Tab::
GroupAdd,MSWord, ahk_exe WINWORD.EXE
GroupActivate,MSWord,r
return
#If
#If WinActive("ahk_exe MendeleyDesktop.exe") ; Ini Untuk Tab next dan prev
^Browser_Back::Send ^{PgUp}
^Browser_Forward::Send ^{PgDn}
Home::Send ^{Home}
End::Send ^{End}
^G::Send ^!{G}
#If
#If WinActive("ahk_exe 7zFM.exe") ; Word
Browser_Forward::
Send !{F12}
Send {Down}
Send {Down}
Send {Enter}
Return
Browser_Back::
Send !{F12}
Send {Down}
Send {Enter}
Return
F12::Send !{F12}
!Up::Send {BackSpace}
#If
#IfWinActive, GVIM ; hotstrings & hotkeys only works in Notepad
Browser_Back::^o
Browser_Forward::^i
Return
#IfWinActive
#IfWinActive, Annotations ; SumatraPDF
Esc::!F4
Return
#IfWinActive
#If WinActive("ahk_exe sumatrapdf.exe") ;
; Open Acrobat from SumatraPDF
!o::
Send !{f}a
return
; Save annotation
F3::
Send +{F10}
Send {Up}
Send {Enter}
return
#IfWinActive
#If WinActive("ahk_exe Olb.exe") ; Sabda
F1::Send ^{F1}
Return
#IfWinActive
; #IfWinActive, ahk_exe explorer.exe ; hotstrings & hotkeys only works in Notepad
; ^t::
; Send !,
; Send {Down}
; Send {Enter}{Enter}
; Return
;
; #IfWinActive
; ---------- Start of Firefox ----------------
#IfWinActive, ahk_class MozillaWindowClass ; hotstrings & hotkeys only works in Firefox
; DeleteFlag=false
; F1::
; DeleteFlag:=true
; Send ^+{Tab}
; return
;
; Enter::
; DeleteFlag:=false
; Send {Enter}
; return
;
; Esc::
; DeleteFlag:=false
; Send {Esc}
; return
;
; Delete::
; if (DeleteFlag) {
; Send {AppsKey}
; Send c
; } else {
; Send {Delete}
; }
; return
; ^+n::Send ^+{P}
; WinMove Full Screen
; #Up::
; if (WinActive("ahk_class MozillaDialogClass")) {
; WinMove ahk_class MozillaDialogClass, , 0,0, A_ScreenWidth, 732
; } else {
; Send #{Up}
; }
; return
;
; ; WinMove Normal Screen
; #Down::
; if (WinActive("ahk_class MozillaDialogClass")) {
; WinGetPos, X, Y, W, H, A
; if (X = 0 and Y = 0 and W > 683 and H > 370) {
; WinMove ahk_class MozillaDialogClass, , A_ScreenWidth/2 - A_ScreenWidth/4, A_ScreenHeight/2 - A_ScreenHeight/4, A_ScreenWidth/2, A_ScreenHeight/2
; } else {
; Send #{Down}
; }
; } else {
; Send #{Down}
; }
; return
; Container Tabs
!.::
; Send ^+{Tab}
Send !{f}
Sleep 90
Send {Down}
Send {Enter}
Return
; Ctrl+S to Ctrl+Alt+S
;^s::^!s
; Firefox make Blank, Tab Suspend blank!
; F4::
; Send !d
; Sleep 90
; Send {Delete}
; Sleep 90
; Send about:blank
; Sleep 90
; Send {Enter}
; Return
; Search Bookmark in url bar
F8::
Send !d
Sleep 90
Send {Delete}
Sleep 90
Send *{Space}
Sleep 90
Send {Enter}
Return
; Focus on App Button
; F10::
; Send !d
; Sleep 90
; Send {TAB}{TAB}
; Sleep 90
; Send {Right}
; Send {Right}
; Send {Right}
; Send {Right}
; Send {Right}
; Send {Enter}
; Return
; Synced Tabs
!/::
Send !{s}
Sleep 90
Send {Down}
Sleep 90
Send {Down}
Send {Enter}
Return
; Buka Password Manager
^l::
Send ^t
; Sleep 100
; Send {F6}
; Sleep 100
Send about:logins
Send {Enter}
Return
; Open Processes
+Esc::
Send ^t
; Sleep 100
; Send {F6}
; Sleep 100
Send about:processes
Send {Enter}
Return
; Search Tab Hotkey
F2::
Send !d
Sleep 100
; Send {F6}
; Sleep 100
Send, `% `
return
#IfWinActive
#IfWinActive, ahk_class MozillaDialogClass
; Mouse Key Click Check
~LButton:: ; ~ will let the button works normally if remap doing nothing
; If the button is Double Click
if (A_TimeSincePriorHotkey < 400) {
CoordMode, Mouse, Window ; Get Location based on Active Window
MouseGetPos, xpos, ypos
; If mouse within title bar (0 <-> 35)
if (ypos >= 0 and ypos <= 35) {
WinGetPos, X, Y, W, H, A
if (X = 0 and Y = 0 and W > 683 and H > 370) {
WinMove ahk_class MozillaDialogClass, , A_ScreenWidth/2 - A_ScreenWidth/4, A_ScreenHeight/2 - A_ScreenHeight/4, A_ScreenWidth/2, A_ScreenHeight/2
} else {
WinMove ahk_class MozillaDialogClass, , 0,0, A_ScreenWidth, 732
}
}
}
return
#IfWinActive
; ---------- End of Firefox ----------------
#IfWinActive, ahk_exe powershell.exe ; hotstrings & hotkeys only works in Firefox
^Browser_Back::Send ^{PgDn}
^Browser_Forward::Send ^{PgUp}
Browser_Back::Send {Home}
Browser_Forward::Send {End}
Return
+!c::Run C:\Apps\cheat-sheet.ps1
#IfWinActive
#IfWinActive, ahk_exe navicat.exe ; Navicat map ke dbeaver
F5::Send ^{r}
^Enter::Send ^{r}
Return
#IfWinActive
#IfWinActive, Films & TV ahk_exe ApplicationFrameHost.exe
F11::Send !{enter}
#IfWinActive
; Pin to desktop
; #o::
; Current := WinExist("A")
; ;ParentID := WinExist("ahk_exe Explorer.EXE ahk_class Progman ")
; ;MsgBox, %ParentID%
; Parent := Parent ? 0 : DllCall("GetShellWindow") ; <-- toggle
; ;Parent := Parent ? 0 : ParentID ; <-- toggle
; ; the window will be dettached if 0 is passed as parent's hWnd
; DllCall("SetParent", UInt, Current, UInt, Parent )
; Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment