Tim D'Annecy

AutoHotkey

#Windows #AutoHotkey

I wrote an AutoHotkey script that inserts commonly used text when a keystroke is pressed.

I had issues using the script with Active Directory Users and Computers. I would press the hotkey, but nothing would happen. This has something to do with how Windows handles UAC. Luckily, AHK has a workaround.

Found out from the AHK FAQ that I needed to rerun the AHK installer, select “Modify” in the installer, and check the box for “Add 'Run with UI Access' to context menus”.

Now, I can run my script and interact with ADUC windows without issues.

Making this note for myself for future reference.

#Windows #AutoHotkey

This AutoHotkey script improves the way Windows inserts accents to be more MacOS-like. I don't like the way the International keyboard handles, so I wrote this script.

Press the right Shift key with one of the letters a,c,e,i,n,o,u to get those characters with commonly used accent or alternative characters. The left Shift key will capitalize as normal. The Control key can also be used for other characters.

  • o + right Shift = ó
  • o + right Shift + left Shift = Ó
  • o + right Shift + Control = ö
  • o + right Shift + left Shift + Control = Ö
  • ? + right Shift = ¿

And so on.

; Accent keys, used with Right Shift key
RShift & 4::Send {€}
return

RShift & A::
    If GetKeyState("LShift", "P")
        Send {Á}
	Else Send {á}
return

RShift & C::
	If GetKeyState("LShift", "P")
		Send {Ç}
	Else Send {ç}
return

RShift & E::
	If GetKeyState("LShift", "P")
		Send {É}
	Else Send {é}
return

RShift & I::
	If GetKeyState("LShift", "P")
		Send {Í}
	Else Send {í}
return

RShift & N::
	If GetKeyState("LShift", "P")
		Send {Ñ}
	Else Send {ñ}
return

RShift & O::
	If GetKeyState("LShift", "P")
		If GetKeyState("Control", "P")
			Send {Ö}
		Else Send {Ó}

	Else If GetKeyState("Control", "P")
			Send {ö}
		Else Send {ó}
return

RShift & U::
	If GetKeyState("LShift", "P")
		If GetKeyState("Control", "P")
			Send {Ü}
		Else Send {Ú}
	Else If GetKeyState("Control", "P")
			Send {ü}
		Else Send {ú}
return

RShift & ?::Send {¿}
return

#Windows #AutoHotkey

This script inserts the date into the current cursor position after a hotkey is pressed.

  • ddd inserts the date like 2021-01-09

  • DDD inserts the date like 2021-Jan-09

  • fff inserts the date like 20210109T084323-0400

  • FFF inserts the date like 20210109 @ 084344-0400

#SingleInstance force

:R*?:DDD::
    if GetKeyState("LShift", "P") {
        FormatTime, CurrentDateTime, , yyy-MMM-dd
        SendInput %CurrentDateTime%
    }
     else {
        FormatTime, CurrentDateTime, , yyy-MM-dd
        SendInput %CurrentDateTime%
    }
return

:R*?:FFF::
    if GetKeyState("LShift", "P") {
        FormatTime, CurrentDate, , yyyyMMdd
        FormatTime, CurrentTime, , HHmmss-0400
        SendInput %CurrentDate% @ %CurrentTime%
    }
     else {
        FormatTime, CurrentDateTime, , yyyyMMddTHHmmss-0400
        SendInput %CurrentDateTime%
    }
return

#Windows #AutoHotkey

Just press the Control + Space keys and it will toggle the current window to lock on top of the others. This can get a bit wonky with multiple windows on top, but most of the time it works great.

^SPACE::  Winset, Alwaysontop, , A

#Windows #AutoHotkey

Just press the Control + shift + Space keys to toggle the currently active window roll status. This is a feature in some Linux window managers that I really wanted on Windows, so I found this script.

This script acts wonky sometimes depending on how the window is composited, so beware.

ws_MinHeight = 0

OnExit, ExitSub
return  

^+SPACE::  
WinGet, ws_ID, ID, A
Loop, Parse, ws_IDList, |
{
    IfEqual, A_LoopField, %ws_ID%
    {
        StringTrimRight, ws_Height, ws_Window%ws_ID%, 0
        WinMove, ahk_id %ws_ID%,,,,, %ws_Height%
        StringReplace, ws_IDList, ws_IDList, |%ws_ID%
        return
    }
}
WinGetPos,,,, ws_Height, A
ws_Window%ws_ID% = %ws_Height%
WinMove, ahk_id %ws_ID%,,,,, %ws_MinHeight%
ws_IDList = %ws_IDList%|%ws_ID%
return

ExitSub:
Loop, Parse, ws_IDList, |
{
    if A_LoopField =  
        continue      
    StringTrimRight, ws_Height, ws_Window%A_LoopField%, 0
    WinMove, ahk_id %A_LoopField%,,,,, %ws_Height%
}
ExitApp  

#AutoHotkey #Windows

This AutoHotkey script generates a pseudo-random password and outputs it to the currently active text field. Just press the p key three times in succession to generate a new password.

I wanted to make the text easy to remember, but hard to crack with a brute force attack (explained nicely by XKCD-936 and more in detail on the wiki page).

There are a two main things that I wanted to accomplish with this quick script:

  • Create a semi-strong password that will be easy to remember, but hard to crack.
  • Be able to give someone the password over the phone without being complicated (“Okay, your new password is '!!FishHook66871', but the O's are zeros, and the I is a 1, and there are two exclamation marks at the beginning, and, and...” or “The first letter is capitalized in the password, also the second H”).

To do both of those things, I decided on a unique phrase using a color, a fruit, a two-digit number, and a punctuation character. The color and fruits will have a capitalized first letter. This combination creates a human readable and memorable string, but rated on password checkers, is exceptionally strong. Some sites estimate that it would take an average of tens of thousands, if not millions, of years to crack.

With that decided, I also wanted to make sure these had following criteria:

  • Colors and fruits should not have the same first letter. It could be confusing to say “Capital B” if Blue and Banana are both used.
  • Colors and fruits need to be non-offensive in any interpretation or culture.
  • Symbols need to be accessible on a non-American keyboard layout (no currency symbols or “dead” accent keys.)

With all of that done, I wrote the following script:

#SingleInstance force
; Press the P key 3 times in a row to type a new password.

ListOfColors:=["Red", "Orange", "Yellow", "Green", "Blue" ]
ListOfFruits:=["Apple", "Kiwi", "Lemon", "Mango", "Peach"]
ListOfSymbols:=["{!}", "{@}", "{#}", "{%}", "{&}", "{*}"]

:R*?:ppp::
    Send % ListOfColors[Random(1, ListOfColors.MaxIndex())]
    Send % ListOfFruits[Random(1, ListOfFruits.MaxIndex())]
    Random, Random, 1, 9
    Send % Random
    Random, Random, 1, 9
    Send % Random
    Send % ListOfSymbols[Random(1, ListOfSymbols.MaxIndex())]
return

Random(a, b)
{
    Random, ReturnVal, a, b
    return ReturnVal
}

#Windows #AutoHotkey

Blocks F1 from opening the Windows Help page. I made this because it kept annoying me. You can hold the Ctrl key down with F1 for normal behavior.

#UseHook
F1::Return
#UseHook off
^F1::Send {F1}