Deye Posted July 24 Posted July 24 please try and explain the major culprits in various ways to the problems you find in this script HotKeySet("^g", "_gibrish_to_he-en") While 1 Sleep(500) WEnd Func _gibrish_to_hebrew() Local $allighn Local Const $aArrayABC[60][2] = [[' ', ' '], ['t', 'א'], ['T', 'א'], ['c', 'ב'], ['C', 'ב'], ['d', 'ג'], ['D', 'ג'], ['s', 'ד'], ['S', 'ד'], ['v', 'ה'], ['V', 'ה'], ["u", 'ו'], ['U', 'ו'], ['z', 'ז'], ['Z', 'ז'], ['j', 'ח'], ['J', 'ח'], ['y', 'ט'], ['Y', 'ט'], ['h', 'י'], ['H', 'י'], ['f', 'כ'], ['F', 'כ'], ['l', 'ך'], ['L', 'ך'], ['k', 'ל'], ['K', 'ל'], ['n', 'מ'], ['N', 'מ'], ['o', 'ם'], ['O', 'ם'], ['b', 'נ'], ['B', 'נ'], ['i', 'ן'], ['I', 'ן'], ['x', 'ס'], ['X', 'ס'], ['g', 'ע'], ['G', 'ע'], ['p', 'פ'], ['P', 'פ'], [';', 'ף'], ['m', 'צ'], ['M', 'צ'], ['.', 'ץ'], ['e', 'ק'], ['E', 'ק'], ['r', 'ר'], ['R', 'ר'], ['a', 'ש'], ['A', 'ש'], ['W', "'"], ['w', "'"], [',', 'ת'], ['/', '.'], ["'", ','], ['q', '/']] Local $outputText = "", $inputText , $char Send("{CTRLDOWN}c{CTRLUP}") Sleep(500) Local $inputText = ClipGet() Sleep(500) For $i = 1 To StringLen($inputText) Local $char = StringMid($inputText, $i, 1) For $j = 0 To UBound($aArrayABC) - 1 MsgBox(0, $aArrayABC[$j][0] , $aArrayABC[$j][0]) If $aArrayABC[$j][0] = $char Then $outputText &= $aArrayABC[$j][1] Else $outputText &= $aArrayABC[$j][0] EndIf MsgBox(0, $aArrayABC[$j][0] , $aArrayABC[$j][0]) ExitLoop Next Next MsgBox(0, $char, $outputText, 1) ClipPut($outputText) EndFunc ;==>_gibrish_to_hebrew
argumentum Posted July 24 Posted July 24 ..now am curious. Why @Deye ?, is it a challenge ?, a problem ? 🤷♂️ Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Deye Posted July 24 Author Posted July 24 1 hour ago, argumentum said: ..now am curious. Why @Deye ?, is it a challenge ?, a problem ? 🤷♂️ What change ?
ioa747 Posted July 24 Posted July 24 (edited) I think your main problem is the Send("{CTRLDOWN}c{CTRLUP}") If you use Send in a script and you have a problem with keys being stuck down then Send is the most likely culprit. A similar problem can occur with BlockInput. The solution is generally quite simple. If there is a key like Shift or Alt held down at the start of the Send sequence, but that key is released by the time the Send sequence finishes then the key will get 'stuck' down Func _SendEx($ss, $warn = "") ;https://www.autoitscript.com/wiki/FAQ#Why_does_the_Ctrl_key_get_stuck_down_after_I_run_my_script? ;Send the string $ss after the Shift Alt and Ctrl keys are released. ;Optionally give a warning after 1 sec if any of those keys are still down. ;Requires misc.au3 to be included in the script for the _ispressed function. ;10 SHIFT key ;11 CTRL key ;12 ALT key Local $iT = TimerInit() While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") If $warn <> "" And TimerDiff($iT) > 1000 Then MsgBox($MB_TOPMOST, "Warning", $warn) EndIf Sleep(10) WEnd Send($ss) EndFunc ;==>_SendEx and an alternative approach with maps expandcollapse popup#include <MsgBoxConstants.au3> #include <Misc.au3> Global $m = _InitializeHebrewMap() HotKeySet("^g", "_gibrish_to_hebrew") While 1 Sleep(100) WEnd Func _gibrish_to_hebrew() Local $outputText = "" ; Stores the converted Hebrew text Local $inputText ; Stores the input text from the clipboard Local $char ; Stores each character being processed Local $iStartTime ; Timer start time for clipboard wait Local Const $iTimeout = 1000 ; Max wait time for clipboard (1 second) Local $ClipData = "" ; Temporary variable for clipboard content _SendEx("^c") ; Start a timer to wait for clipboard content $iStartTime = TimerInit() While TimerDiff($iStartTime) < $iTimeout $ClipData = ClipGet() If $ClipData <> "" Then $inputText = $ClipData ExitLoop EndIf Sleep(10) WEnd If StringLen($inputText) = 0 Then Return ; Exit the function EndIf ; Iterate through each character of the input text For $i = 1 To StringLen($inputText) $char = StringMid($inputText, $i, 1) ; Get the current character ; Check if the character exists as a key in our global Hebrew map If MapExists($m, $char) Then $outputText &= $m[$char] ; Append the corresponding Hebrew character Else $outputText &= $char ; If no match, append the original character EndIf Next ; Put the converted Hebrew text back into the clipboard ClipPut($outputText) ConsoleWrite("$outputText=" & $outputText & @CRLF) EndFunc Func _InitializeHebrewMap() Local $map[] $map[" "] = " " $map["t"] = "א" $map["T"] = "א" $map["c"] = "ב" $map["C"] = "ב" $map["d"] = "ג" $map["D"] = "ג" $map["s"] = "ד" $map["S"] = "ד" $map["v"] = "ה" $map["V"] = "ה" $map["u"] = "ו" $map["U"] = "ו" $map["z"] = "ז" $map["Z"] = "ז" $map["j"] = "ח" $map["J"] = "ח" $map["y"] = "ט" $map["Y"] = "ט" $map["h"] = "י" $map["H"] = "י" $map["f"] = "כ" $map["F"] = "כ" $map["l"] = "ך" $map["L"] = "ך" $map["k"] = "ל" $map["K"] = "ל" $map["n"] = "מ" $map["N"] = "מ" $map["o"] = "ם" $map["O"] = "ם" $map["b"] = "נ" $map["B"] = "נ" $map["i"] = "ן" $map["I"] = "ן" $map["x"] = "ס" $map["X"] = "ס" $map["g"] = "ע" $map["G"] = "ע" $map["p"] = "פ" $map["P"] = "פ" $map[";"] = "ף" $map["m"] = "צ" $map["M"] = "צ" $map["."] = "ץ" $map["e"] = "ק" $map["E"] = "ק" $map["r"] = "ר" $map["R"] = "ר" $map["a"] = "ש" $map["A"] = "ש" $map["W"] = "'" $map["w"] = "'" $map[","] = "ת" $map["/"] = "." $map["'"] = "," $map["q"] = "/" Return $map EndFunc Func _SendEx($ss, $warn = "") ;https://www.autoitscript.com/wiki/FAQ#Why_does_the_Ctrl_key_get_stuck_down_after_I_run_my_script? ;Send the string $ss after the Shift Alt and Ctrl keys are released. ;Optionally give a warning after 1 sec if any of those keys are still down. ;Requires misc.au3 to be included in the script for the _ispressed function. ;10 SHIFT key ;11 CTRL key ;12 ALT key Local $iT = TimerInit() While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") If $warn <> "" And TimerDiff($iT) > 1000 Then MsgBox($MB_TOPMOST, "Warning", $warn) EndIf Sleep(10) WEnd Send($ss) EndFunc ;==>_SendEx Edited July 24 by ioa747 pixelsearch 1 I know that I know nothing
pixelsearch Posted July 24 Posted July 24 (edited) 24 minutes ago, ioa747 said: I think your main problem is the Send("{CTRLDOWN}c{CTRLUP}") For the record @Nine suggested in this post a 3 line method which works great, I use it everywhere now and the sticky issue has gone. It has been added to the wiki, without crediting Nine (why is that ? He should be credited in the wiki) So, no more... Send("{CTRLDOWN}c{CTRLUP}") ...but always Send("{CTRLDOWN}") Send("c") Send("{CTRLUP}") Edited July 24 by pixelsearch typo ioa747 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
argumentum Posted July 24 Posted July 24 33 minutes ago, Deye said: What change ? lol, challenge !. At times people come up with challenges as a game, for fun. The name of the function could not run, the MsgBox everywhere, ..I stopped right there and then, and asked Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
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