Skip to content

Commit

Permalink
New settings and command line paramters
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaifm committed Feb 23, 2024
1 parent 76b5444 commit 05329df
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 27 deletions.
39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
## Screenkey.ahk
# Screenkey.ahk

Screenkey.ahk is a tool that displays the keys that you type on the screen.
Screenkey.ahk is a tool that displays the keys that you type anywhere in Windows.
It can be useful for screencasts or remote help.

It is implemented as an [Autohotkey](http://www.autohotkey.com/) script.
It is available as an [Autohotkey](http://www.autohotkey.com/) script or standalone executable.

![screenshot](https://cloud.githubusercontent.com/assets/981184/5126844/7eb761e6-70d0-11e4-9ba9-136273490cab.png)
![image](https://github.com/mihaifm/screenkey.ahk/assets/981184/b94d0fd0-ba0b-4ae2-baa5-5b1faeda5b82)

### Customization
## Customization

There are a few customization options that can be tweaked at the top of the script:

Font settings:
Font settings

fontSize = 20
fontName = Verdana
fontStyle = Bold
fontSize := 20
fontName := "Verdana"
fontStyle := "Bold"

Maximum number of keys that can be displayed on the screen at any time:
Maximum number of keys that can be displayed on the screen at any time

numButtons := 5

Expand All @@ -29,12 +29,21 @@ Distance from the buttons to the edge of the window

winMargin := 25

Speed typing settings:
Combo timer (in miliseconds). Old keys are cleared from display when a new key is pressed after the interval.
All keys typed within the interval will be displayed at the same time. Set to 0 to disable.

useSpeedTimer := true
speedTimer := 1000
comboTimer := 1000

When `useSpeedTimer` is true, previous keys will be cleared when typing new keys after the specified interval (`speedTimer`)
This is handy when trying to show key combos.
Clear timer (in miliseconds). Clear everything in the UI after this interval. Set to 0 to never clear.

clearTimer := 5000

Hide UI hotkey. Press this hotkey to hide the UI elements of the Screenkey window (the captured keys will still be displayed). Default is `Ctrl+Shift+h`

hideUIHotkey := ^+h

## Command line parameters

The script or the exe can be run with command line parameters. The name of the params is the same as the settings above. Use `-notransparent` to turn transparency off.

screenkey.exe -numButtons 9 -fontName Rockwell -fontSize 50 -comboTimer 300 -notransparent
84 changes: 72 additions & 12 deletions screenkey.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
; Config area

; Font settings
fontSize = 20
fontName = Verdana
fontStyle = Bold
fontSize := 30
fontName := "Verdana"
fontStyle := "Bold"

; The max number of keys that are listed on the screen
numButtons := 5
Expand All @@ -15,9 +15,41 @@ transparent := true
; Distance from the buttons to the edge of the window
winMargin := 25

; When this is true, old keys are cleared after the speed timer interval
useSpeedTimer := true
speedTimer := 1000
; Clear old keys after the combo timer interval. Set to 0 to disable
comboTimer := 1000

; Clear everything in the UI after this interval. Set to 0 to never clear
clearTimer := 5000

; Hide UI hotkey
hideUIHotkey = ^+h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Command line arguments

for n, param in A_Args
{
if (param == "-hideUIHotkey" && n != A_Args.Length-1)
hideUIHotkey := A_Args[n+1]
if (param == "-fontSize" && n != A_Args.Length-1)
fontSize := A_Args[n+1]
if (param == "-fontName" && n != A_Args.Length-1)
fontName := A_Args[n+1]
if (param == "-fontStyle" && n != A_Args.Length-1)
fontStyle := A_Args[n+1]
if (param == "-numButtons" && n != A_Args.Length-1)
numButtons := A_Args[n+1]
if (param == "-transparent")
transparent := true
if (param == "-notransparent")
transparent := false
if (param == "-winMargin" && n != A_Args.Length-1)
winMargin := A_Args[n+1]
if (param == "-comboTimer" && n != A_Args.Length-1)
comboTimer := A_Args[n+1]
if (param == "-clearTimer" && n != A_Args.Length-1)
clearTimer := A_Args[n+1]
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Font metrics functions
Expand Down Expand Up @@ -63,6 +95,9 @@ If (transparent)
WinSet TransColor, %TransColor% 220, ahk_id %k_ID%
}

uiHidden := false
Hotkey, %hideUIHotkey%, HideUILabel, UseErrorLevel

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Hotkeys

Expand Down Expand Up @@ -159,10 +194,16 @@ KeyHandle()

WinMove ahk_id %k_ID%,,,, winWidth + 2 * winMargin

; install the speed timer that clears all the buttons when the next key is hit
if (useSpeedTimer)
; install the combo timer that clears all the buttons when the next key is hit
if (comboTimer > 0)
{
SetTimer HandleSpeedType, %speedTimer%
SetTimer HandleComboType, %comboTimer%
}

if (clearTimer > 0)
{
SetTimer HandleClearTimer, Off
SetTimer HandleClearTimer, %clearTimer%
}
}

Expand Down Expand Up @@ -284,6 +325,15 @@ Up(inkey)
; Install hotkeys

CaptureKeyboardInputs()
return

HideUILabel:
uiHidden := !uiHidden
if (uiHidden)
Gui, -Caption
else
Gui, +Caption
return

; special handling for special characters
~*;::
Expand All @@ -293,13 +343,23 @@ CaptureKeyboardInputs()
KeyHandle()
return

HandleSpeedType:
HandleComboType:
current := 1
clear := true
SetTimer HandleSpeedType, Off
SetTimer HandleComboType, Off
return

HandleClearTimer:
Loop % numButtons
{
i := A_Index
GuiControl Move, Button%i%, w0
}
WinMove ahk_id %k_ID%,,,,200
SetTimer HandleClearTimer, Off
return

GuiClose:
ExitApp
ExitApp
return

0 comments on commit 05329df

Please sign in to comment.