Your Autohotkey Config

User avatar
t!ng
Awake Sheep

01 Apr 2014, 23:42

I am using it for a few years now and wanted to look for new inspiration in order to optimize my layout or try out new things.

So it would be cool if you could comment on your script and tell us what might be useful or you just upload it so everybody can take a look.

Here is mine:
Spoiler:

Code: Select all

;Automatisches Reloaden beim Speichern
{
SetTimer,UPDATEDSCRIPT,1000
UPDATEDSCRIPT:
FileGetAttrib,attribs,%A_ScriptFullPath%
IfInString,attribs,A
{
FileSetAttrib,-A,%A_ScriptFullPath%
SplashTextOn,,,Script wurde aktualisiert,
Sleep,500
Reload
}
Return
}
;On Screen Display
OSD(text)
{
#Persistent
Progress, hide x1050 Y900 b1 w150 h27 zh0 FM10 cwEEEEEE ct111111,, %text%, AutoHotKeyProgressBar, Verdana BRK
WinSet, TransColor, 000000 120, AutoHotKeyProgressBar
Progress, show
SetTimer, RemoveToolTip, 1000
Return

RemoveToolTip:
SetTimer, RemoveToolTip, Off
Progress, Off
return
}

;Fenster hin und her schieben
MoveWindow(Cmd)
{
	SysGet, MonitorCount, MonitorCount
	if MonitorCount < 2
		return
	SysGet, Mon1, MonitorWorkArea, 1
	SysGet, Mon2, MonitorWorkArea, 2
	;MsgBox %Mon1Left% %Mon1Right% %Mon2Left% %Mon2Right%
	WinGetActiveStats ,Title, Width, Height, x, y
	WinGet, state, MinMax, A
	if (state == 1)
		WinRestore , A
	if ((Cmd == "Left") and (X > Mon1Right-10))	; 10 Pixel Toleranz
		WinMove, %Title%, , %Mon1Left%, 0
	else if ((Cmd == "Right") and (X < Mon2Left))
		WinMove, %Title%, , %Mon2Left%, 0
	if (state == 1)
		WinMaximize , A
}

^,::Send {<}
^.::Send {>}
^-::Send {|}


;maus mit tastatur steuern
;*#up::MouseMove, 0, -10, 0, R  ; Win + Pfeil oben => Zeiger nach oben bewegen
;*#Down::MouseMove, 0, 10, 0, R  ; Win + Pfeil unten => Zeiger nach unten bewegen
;*#Left::MouseMove, -10, 0, 0, R  ; Win + Pfeil links => Zeiger nach links bewegen
;*#Right::MouseMove, 10, 0, 0, R  ; Win + Pfeil rechts => Zeiger nach rechts bewegen



#Break::Del
#PgUp::Home
#PgDn::End
#Del::Enter

;Für SSK
;LCtrl & d::Send {LWin Down}{d}{LWin Up}
;LCtrl & e::Send {LWin Down}{e}{LWin Up}

;Capslock zu Strg
;Capslock::Ctrl


;Nummernblock
;^h::Send ?
;^m::Send 1
;^,::Send 2
;^.::Send 3
;^j::Send 4
;^n::Send 0
;^k::Send 5
;^l::Send 6
;^u::Send 7
;^i::Send 8
;^o::Send 9

;Pfeiltasten
^j::Send {Left}
^i::Send {Up}
^k::Send {Down}
^l::Send {Right}

;Pfeiltasten mit capslock
CapsLock & j::Send {Left}
CapsLock & i::Send {Up}
CapsLock & k::Send {Down}
CapsLock & l::Send {Right}
CapsLock & u::Send {Home}
CapsLock & o::Send {End}
CapsLock & h::Send {PGUP}
CapsLock & n::Send {PGDN}

CapsLock & c::
SendInput ^c
return

CapsLock & v::
SendInput ^v
return
 
CapsLock & z::
SendInput ^z
return

CapsLock & s::
SendInput ^s
return
CapsLock & t::
SendInput ^t
return
CapsLock & w::
SendInput ^w
return

CapsLock & Space::
Send {BackSpace}
return


CapsLock & b::
SendInput !{F4}
return

 
;Für HHKB
^::BS
;& 1::Send {^}

^Space::bs

^u::Send {Home}
^o::Send {End}


;Lautstärke regeln
;^´::Send {Volume_Down 3}
;^#::Send {Volume_Up 3}
;^ß::Send {Volume_Mute}

;Textersetzungen
::mfg::Mit freundlichen Grüßen
::vg::Viele Grüße

;Taskmanager
RAlt & y::
Run taskmgr.exe
return

;Taschenrechner
RAlt & x::
Run calc.exe
return

;Edit Script
RAlt & v::Edit


;Mediatasten:
{
#F1:: 
Send {Media_Play_Pause}
return 
 
#F2::
Send {Media_Stop}
return
 
#F3::
Send {Media_Prev}
return
 
#F4::
Send {Media_Next}
return
 
#F5::
Send {Volume_Down}
return
 
#F6::
Send {Volume_Up}
return
 
#F7::
Send {Volume_Mute}
return
}

;Rechtes Alt + ESc sendet Alt+F4
RAlt & Esc::Send !{F4}
RAlt & E::Send {€}


LAlt & j::Send {Home}
LAlt & l::Send {End}
LAlt & i::Send {PGUP}
LAlt & k::Send {PGDN}

ScrollLock::LWin

;G80-5000
{
LShift & F3::
SendInput ^c
return

LShift & F4::
SendInput ^v
return

LShift & F5::
SendInput ^x
return

LShift & F6::
SendInput ^a
return

LShift & F7::
Send,  !{F4}
return
}


;Klammern usw
RAlt & u::Send ,(
return

RAlt & i::Send ,)
return

RAlt & j::Send ,{{}
return

RAlt & k::Send ,{}}
return

RAlt & m::Send ,[
return

RAlt & ,::Send ,]
return
For example I made the Caps Lock my FN key. It works quite well and I like it. ( CapsLock + ijkl = Cursor )

Tell me your "tweeks".

User avatar
Daniel Beardsmore

02 Apr 2014, 00:14

Spoiler:

Code: Select all

#NoTrayIcon
^!+Home::Reload
^!+End::ExitApp
+^!Insert::Run, "C:\Program Files (x86)\JujuSoft\JujuEdit\JujuEdit.exe" %A_ScriptFullPath%

+^!-::— ; shift+ctrl+alt+- = em dash
^!-::–  ;       ctrl+alt+- = en dash
+^!8::° ; shift+ctrl+alt+8 = degrees
^!8::•  ;       ctrl+alt+8 = bullet
^!l::…  ;       ctrl+alt+l = ellipsis

^!c::SendInput {U+00A9} ;        ctrl+alt+C = copyright (doesn't work with a raw character binding, acts all weird)

^!N::SendInput {U+2192} ;        ctrl+alt+N = right arrow
^!M::SendInput {U+2212} ;        ctrl+alt+M = minus
^+!M::SendInput {U+2122} ;       ctrl+shift+alt+M = trademark

#j::Run, "C:\Program Files (x86)\JujuSoft\JujuEdit\JujuEdit.exe"

F10::WinMinimize, A

F11::
IfWinActive, ahk_exe foobar2000.exe
{
	WinMinimize
	return
}

IfWinExist, ahk_exe foobar2000.exe
	WinActivate
else
	Run, foobar2000.exe

return

#c::
IfWinExist, ahk_class CalcFrame
	WinActivate
else
	Run, calc.exe
return

#IfWinActive ahk_class JujuEdit
	^w::WinClose, A
#IfWinActive

#IfWinActive ahk_class IrfanView
	^w::WinClose, A
#IfWinActive

#IfWinActive ahk_class ConsoleWindowClass
  	^d::WinClose, A
#IfWinActive

; Don't know how to give DOSBox priority of F11 over Winamp, but this stops F11 bringing SDL applications out of full-screen mode
; by mistake -- you'll still have to select prod in Worms with the mouse
#IfWinActive ahk_class SDL_app
	F10::return
 	F11::return
#IfWinActive

#IfWinActive ahk_class classFoxitReader
	F6::!6
#IfWinActive

#IfWinActive ahk_exe thunderbird.exe
	; !s::^k does absolutely nothing
	!s::Send ^k
#IfWinActive
From the top:
  • Self-referential bindings: keyboard shortcuts to restart and exit the script, and to open it for editing (technically that last one should use an Explorer shell execute call, but it's hard-coded to my beloved text editor)
  • Extended ASCII and Unicode supplementary bindings over those provided by the United Kingdom International keyboard layout
  • Globay hotkey for a new text document, and one to minimise a document with F10, which is of course useless on my work PC, as you simply can't smack F10 on a Poker
  • A possibly hamfisted way to toggle foobar2000 with F11, and it won't return to the tray this way (I can't find any way to truly toggle it with the keyboard)
  • Start or focus the shoddy Windows Calculator
  • Extension shortcuts for closing JujuEdit, IrfanView and console windows; in the case of the last one, I picked ^D to match Linux shells
  • Bindings to stop existing global bindings from pulling me out of DOSBox, as F10 and F11 are weapon bindings in Worms, although as a result those keys are killed off completely; either Windows 8 or a later DOSBox corrected this priority fault and now DOSBox reads keys at high priority, like with RDP etc. instead of letting standard global bindings win
  • Make Foxit Reader use F6 instead of shift-6 to enter text selection mode
  • I actually have keyconfig installed in Thunderbird, but even that cannot enable Alt+S for send mail (since that focuses the subject field) so I've used AutoHotkey to make Thunderbird think I pressed ^K
At work I've also got a binding to a set of regexes etc that fix the mess that Outlook 2003 makes of copying text from e-mails, and one that puts a GUID into the clipboard (due to a bug in JujuEdit).

TL;DR: What the hell is wrong with AutoHotkey?
Spoiler:
I've tried writing software in it, but I'm left unable to find a suitably abhorrent fate for the person responsible for how retarded AutoHotkey actually is. It tops my chart of things that could be so good if only they were ripped apart and started over to be what the person was trying to do but failed. I spent a whole hour the other day trying to do nothing more than display a window with an empty listbox, and dynamically add some items to it. The documentation is atrocious -- the least you can do with the make-it-up-as-you-go-along syntax is document it thoroughly.

"Control, Add, somelistbox, Some string" does literally nothing. Even with warnings enabled, nothing. No errors, nothing. Eventually I realised that if I put it inside try/catch it might die, since even in warning mode, errors are just eaten. The exception? "1". Just simply the digit "1".

Turns out I wanted "GuiControl, , somelistbox, Some string", which does work (give or take arg order). Note that after GuiControl, no verb is given. It's the magic "don't write a verb, we'll just pick something for you". Apple got this right a long time ago. For AppleScript, they went with named parameters.

I can't even write a syntax highlighter for AutoHotkey as there is no syntax. You can't parse AutoHotkey in a normal orthogonal manner, as every keyword potentially has its own syntax.

AutoHotkey says "look how easily you could write little GUI applets with very little code and dynamic window layout that Microsoft still don't understand, but no, you can't, because you'll live drenched in sweat from the fear of using "=" to assign somewhere, and end up with a line of code inside your variable, or forget to write % to stop a code fragment being read as a string instead of code." Yes I've wasted ages on a bug where I'd assigned a piece of code into a variable using = instead of := — I don't care which operator means assign, so long as the other one is a syntax error.

Argh. AutoHotkey gives me rage.

User avatar
ne0phyte
Toast.

02 Apr 2014, 00:18

I've been using this for sane window handling:
http://corz.org/windows/software/access ... -Vista.php

Also this to toggle always-on-top with Win+A:
Spoiler:

Code: Select all

#InstallKeybdHook
#SingleInstance force
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

SetCapsLockState, AlwaysOff

#Persistent
SetTimer, UpdateWindowTitles, 500

#a::
{
	WinGet, currentWindow, ID, A
	WinGet, winExStyle, ExStyle, ahk_id %currentWindow%
	if (winExStyle & 0x8)  ; 0x8 = WS_EX_TOPMOST.
	{
	   Winset, AlwaysOnTop, off, ahk_id %currentWindow%
	}
	else
	{
	   WinSet, AlwaysOnTop, on, ahk_id %currentWindow%
	}
	GoSub, UpdateWindowTitles
}
return

UpdateWindowTitles:
	WinGet, id, list,,, Program Manager
	Loop, %id%
	{
		this_id := id%A_Index%
		
		WinGetTitle, winTitle, ahk_id %this_id%
		WinGet, ExStyle, ExStyle, ahk_id %this_id%
		if (ExStyle & 0x8)  ; 0x8 is WS_EX_TOPMOST.
		{		
			if SubStr(winTitle, 1, 4) != "[A] "
			{
				newTitle = [A] %winTitle%
				WinSetTitle, %winTitle%, , %newTitle%
			}
		}
		else
		{
			if SubStr(winTitle, 1, 4) == "[A] "
			{
				newTitle := SubStr(winTitle, 5)
				WinSetTitle, %winTitle%, , %newTitle%
			}
		}

}
return
This for creating screenshots (download irfanview and place it in the script dir):
Spoiler:

Code: Select all

scrDir=%A_Desktop%\screenshots

; Capture whole screen
LControl & PrintScreen::
{
	ifNotExist, %scrDir%
	fileCreateDir, %scrDir%
	Run, "irfanview.exe" /capture=0 /convert=%scrDir%\capture_$U(`%Y-`%m-`%d_`%H`%M`%S).jpg
	return
}

; Capture active screen
LWin & PrintScreen::
{
	ifNotExist, %scrDir%
	fileCreateDir, %scrDir%
	Run, "irfanview.exe" /capture=1 /convert=%scrDir%\capture_$U(`%Y-`%m-`%d_`%H`%M`%S).jpg
	return
}

; Capture active window
LShift & PrintScreen::
{
	ifNotExist, %scrDir%
	fileCreateDir, %scrDir%
	Run, "irfanview.exe" /capture=2 /convert=%scrDir%\capture_$U(`%Y-`%m-`%d_`%H`%M`%S).jpg
	return
}
I have lots of small AHK snippets somewhere but I don't use Window apart from gaming anymore because even with AHK it's annoying to use.

User avatar
Eszett

02 Apr 2014, 03:36

I use many concepts. One is, that I use “#” followed by any nickname to autocomplete to the person’s email:
:*:#linda::[email protected]
:*:#john::[email protected]
:*:#marc::[email protected]

The idea behind this is, that triggering these by accident is nearly impossible with using “#”.

One concept you’ve posted above which I like is to swap PageUp with Home, and PageDown with End, because by this PageUp and PageDown are in vertical line with Up and Down, which feels more intuitive.

User avatar
fifted

02 Apr 2014, 04:33

Daniel Beardsmore wrote:I can't even write a syntax highlighter for AutoHotkey as there is no syntax.
Funny because it's true!

My script:

https://github.com/shayneholmes/general ... r/Mine.ahk

Things I think are nice about my script:
  • Ctrl+? displays a tooltip with all my shortcuts. (Sometimes I forget them.)
  • Hotstrings for dates:
    • "ts" expands to "2014-04-01" (helpful for quick filenames)
    • "td" to "Tuesday, 1 April 2014" (useful in correspondence or journal)
  • Disable F1 for most apps ('cause it always pops up Help when I bump it accidentally)
  • Media keys go straight to MediaMonkey (my player of choice)
  • Ctrl-v paste to cmd window! (Love this...)
  • Win+t sets a five-minute timer, then chimes at the end. I use it to stay focused on short tasks.
I also use Ctrl+Alt+a to stick a window on top.

Will be incorporating the self-referential bindings shortly... :like:

Post Reply

Return to “Keyboards”