ioa747 Posted 7 hours ago Posted 7 hours ago (edited) _ConvertKeyboardLayout many times i start typing without having watched the keyboard to the language i'm typing in, and when I look to see what I've typed I see gibberish. Function to convert "gibberish" text (e.g., "kalhmera se oloyw") into correct text (e.g., "καλημερα σε ολους") and vice versa (e.g., "Γοοδ μορνινγ εωερυονε") into correct text (e.g., "Good morning everyone") (you will need to adapt it to your language) 😁 StringProper.au3 expandcollapse popup; https://www.autoitscript.com/forum/topic/213301-_convertkeyboardlayout/ ;---------------------------------------------------------------------------------------- ; Title...........: _ConvertKeyboardLayout.au3 ; Description.....: Convert the currently selected text from gibberish to the appropriate language ; AutoIt Version..: 3.3.18.0 Author: ioa747 Script Version: 0.1 ; Note............: Testet in Windows 11 Pro 24H2 Date:4/11/2025 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; Hotkey to trigger the conversion HotKeySet("+^q", "_ConvertKeyboardLayout") ; <<--(Shift+Ctrl+Q)--<< ; Main loop to keep the script running While 1 Sleep(300) WEnd ;-------------------------------------------------------------------------------------------------------------------------------- ; many times i start typing without having watched the keyboard to the language i'm typing in, ; and when I look to see what I've typed I see gibberish. ; Function to convert "gibberish" text (e.g., "kalhmera se oloyw") into correct text (e.g., "καλημερα σε ολους") ; and vice versa (e.g., "Γοοδ μορνινγ εωερυονε") into correct text (e.g., "Good morning everyone") ;-------------------------------------------------------------------------------------------------------------------------------- Func _ConvertKeyboardLayout() Local $hWnd = WinGetHandle("[ACTIVE]") ; Get the handle of the active window Local Static $mEN[] Local Static $mGR[] If UBound($mEN) = 0 Then Local Const $sEN = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" Local Const $sGR = ";ςερτυθιοπασδφγηξκλζχψωβνμ:΅ΕΡΤΥΘΙΟΠΑΣΔΦΓΗΞΚΛΖΧΨΩΒΝΜ" For $i = 1 To StringLen($sEN) $mEN[StringMid($sGR, $i, 1)] = StringMid($sEN, $i, 1) $mGR[StringMid($sEN, $i, 1)] = StringMid($sGR, $i, 1) Next EndIf ; Local $hTimer = TimerInit() Local Const $CHANGE_THE_KEYBOARD = 1 ; constant if you want to send key for change the keyboard too Local Const $iTimeout = 1000 ; Max wait time for clipboard (1 second) Local $sOriginalClipboard = ClipGet() ; Backup original clipboard content Local $sInputText = "" ClipPut("") ; Clear clipboard to detect new content Send("{CTRLDOWN}") Send("c") ; Copy selected text to clipboard Send("{CTRLUP}") ; Wait for clipboard content to be updated Local $iStartTime = TimerInit() While TimerDiff($iStartTime) < $iTimeout $sInputText = ClipGet() If $sInputText <> "" Then ; Check if new content arrived ExitLoop EndIf Sleep(50) WEnd If $sInputText = "" Then ConsoleWrite("! No text copied to clipboard or clipboard timed out." & @CRLF) ClipPut($sOriginalClipboard) ; Restore clipboard Return SetError(1, 0, 0) EndIf ; Determine conversion direction (English to Greek or Greek to English) ; check if the input text contains English or Greek characters Local $sChar, $bEnglishTxt = False $sChar = StringLeft($sInputText, 1) If Not MapExists($mEN, $sChar) Then $bEnglishTxt = True Local $sOutputText = "" If $bEnglishTxt Then ; converted to Greek For $i = 1 To StringLen($sInputText) $sChar = StringMid($sInputText, $i, 1) If MapExists($mGR, $sChar) Then $sOutputText &= $mGR[$sChar] Else $sOutputText &= $sChar EndIf Next Else ; converted to English For $i = 1 To StringLen($sInputText) $sChar = StringMid($sInputText, $i, 1) If MapExists($mEN, $sChar) Then $sOutputText &= $mEN[$sChar] Else $sOutputText &= $sChar EndIf Next EndIf ClipPut($sOutputText) ; Put the converted text back to clipboard WinActivate($hWnd) ; Re-activate the window where text was copied from Sleep(50) ; Give a small delay ; Paste the converted text Send("{CTRLDOWN}") Send("v") Send("{CTRLUP}") If $CHANGE_THE_KEYBOARD Then Send("# ") ; Win + space, if you want to change the keyboard ClipPut($sOriginalClipboard) ; Restore the original clipboard content ; ConsoleWrite("Original Clipboard Restored. Processed in: " & Round(TimerDiff($hTimer) / 1000, 3) & " seconds" & @CRLF) EndFunc ;==>_ConvertKeyboardLayout Please, every comment is appreciated! leave your comments and experiences here! Thank you very much Edited 2 hours ago by ioa747 more appropriate name I know that I know nothing
jchd Posted 3 hours ago Posted 3 hours ago The name you choose is a misnomer. "proper case" refers to capitalizing the first letter of each word in a sentence, like this: "Proper Case" Refers To Capitalizing The First Letter Of Each Word In A Sentence ioa747 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now