Skip to content

Instantly share code, notes, and snippets.

@divinity76
Last active November 28, 2021 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save divinity76/c50513750d2dde36dc42ae8f19b8b5f6 to your computer and use it in GitHub Desktop.
Save divinity76/c50513750d2dde36dc42ae8f19b8b5f6 to your computer and use it in GitHub Desktop.
autoit KVM paste
AutoItSetOption("SendKeyDelay",20); dont send too fast
AutoItSetOption("SendKeyDownDelay",20);; dont send too fast
Func TranslateNorwegianKeyboardLayoutToEnglish($str)
; warning: important to do translations in correct order,
; for example: \ => ' must be done BEFORE = => \
; a proper fix would be strtr() instead of StringReplace, but i don't have a strtr in AutoIt
; and cba writing one, at least right now
$str = StringReplace ( $str, ":", "{SHIFTDOWN}ø{SHIFTUP}" );
$str = StringReplace ( $str, "|", "{SHIFTDOWN}<{SHIFTUP}" );
$str = StringReplace ( $str, "-", "{+}" );
$str = StringReplace ( $str, "/", "-" );
$str = StringReplace ( $str, "\", "'" );
$str = StringReplace ( $str, "=", "\" );
; LOTS more should be on this list, but i dont know what they are.
return $str;
EndFunc
Func Paste()
Sleep(2000);
Local $str = ClipGet();
$str = TranslateNorwegianKeyboardLayoutToEnglish($str);
$str = StringReplace( StringReplace( $str , @CRLF, "{ENTER}"), @LF, "{ENTER}");
Send($str);
EndFunc
HotKeySet("æ","Paste");
While 1
Sleep(2000);
WEnd
;:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment