Skip to content

Instantly share code, notes, and snippets.

@ek-db
Created September 14, 2017 04:28
Show Gist options
  • Save ek-db/86b7f6bd80de3710ba3973bea7b07460 to your computer and use it in GitHub Desktop.
Save ek-db/86b7f6bd80de3710ba3973bea7b07460 to your computer and use it in GitHub Desktop.
ahk_db
#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.
Menu, Tray, Icon, shell32.dll, 16 ;this changes the icon into a little laptop thingy. just useful for making it distinct from the others.
;#######THIS IS THE BEST SCRIPT I'VE EVER WRITTEN.#########
;And also one of the simplest. Basically, If you press the "explorer" key (F1) it will instantly:
; 1. Create an explorer window if one is not already running.
; 2. Open the LAST ACTIVE explorer window if Explorer is not already active
; 3. If you keep pressing the key, it will cycle through Explorer windows in the order they were last activated
;Programs like chrome are a little different. It will open Chrome if it's not already open,
;but when you keep pressing the button, it hits "CTRL TAB" to advance you forwards through your tabs.
;This is all significantly superior to switching between applications by CLICKING on them in the taskbar,
;and also very superior to using WIN 1, WIN 2, WIN 3 etc to switch between applications.
;You will want to tailor this script to launch your own most commonly used applications.
;You can use Window Spy (it comes with autohotkey) to figure out the ahk_exe and ahk_class of your applications.
;Applications used in this example:
;explorer
;chrome
;premiere
;word
#IfWinActive
F1::
IfWinNotExist, ahk_class CabinetWClass
Run, explorer.exe
GroupAdd, explorers, ahk_class CabinetWClass
if WinActive("ahk_exe explorer.exe")
GroupActivate, explorers, r
else
WinActivate ahk_class CabinetWClass ;you have to use WinActivatebottom if you didn't create a window group.
Return
F2::
;Pelle showed me that if chrome was opened with this script, it becomes a blank screen, and cannot open unless you restart your computer. I have disabled the opening command for now.
; IfWinNotExist, ahk_class Chrome_WidgetWin_1
; Run, chrome.exe
if WinActive("ahk_class Chrome_WidgetWin_1")
Send ^{tab}
else
WinActivate ahk_class Chrome_WidgetWin_1
Return
F3::
IfWinNotExist, ahk_class Notepad
Run, notepad.exe
WinActivate ahk_class Notepad
Return
;The optional script below allows you to use the TILDE to go DOWN one folder level in explorer
#IfWinActive ahk_exe explorer.exe
`::
Send !{up}
Return
#IfWinActive
;opens the CLOCK / CALENDAR. ;http://superuser.com/questions/290068/windows-keyboard-shortcut-to-view-calendar
#c::
Send #b{left}{enter}
Return
#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.
;super simple script for switching between virtual desktops with f1/f2 SUPER!
F1:: send {LWin down}{LCtrl down}{Left}{LCtrl up}{LWin up} ; switch to previous virtual desktop
F2:: send {LWin down}{LCtrl down}{Right}{LCtrl up}{LWin up} ; switch to next virtual desktop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment