Deye Posted December 2, 2022 Share Posted December 2, 2022 the objective is to highlight text, and when you change the keyboard to another language, the text is translated from the previous keboard setting language to the current keboard language. but it seems hard to get anything done. #include <Array.au3> #include <WinAPISys.au3> HotKeySet("{ESC}", "Terminate") Local $var = '' & 'Hex|Dec|Country' & @LF & '0004|4|zh-CHS' & @LF & '0401|1025|ar-SA' & @LF & '0402|1026|bg-BG' & @LF & '0403|1027|ca-ES' & @LF & '0404|1028|zh-TW' & @LF & '0405|1029|cs-CZ' & @LF & '0406|1030|da-DK' & @LF & '0407|1031|de-DE' & @LF & '0408|1032|el-GR' & @LF & '0409|1033|en-US' & @LF & '040A|1034|es-ES_tradnl' & @LF & '040B|1035|fi-FI' & @LF & '040C|1036|fr-FR' & @LF & '040D|1037|he-IL' & @LF & '040E|1038|hu-HU' & @LF & '040F|1039|is-IS' & @LF & '0410|1040|it-IT' & @LF & '0411|1041|ja-JP' & @LF & '0412|1042|ko-KR' & @LF & '0413|1043|nl-NL' & @LF & '0414|1044|nb-NO' & @LF & '0415|1045|pl-PL' & @LF & '0416|1046|pt-BR' & @LF & '0417|1047|rm-CH' & @LF & '0418|1048|ro-RO' & @LF & '0419|1049|ru-RU' & @LF & '041A|1050|hr-HR' & @LF & '041B|1051|sk-SK' & @LF & '041C|1052|sq-AL' & @LF & '041D|1053|sv-SE' & @LF & '041E|1054|th-TH' & @LF & '041F|1055|tr-TR' & @LF & '0420|1056|ur-PK' & @LF & '0421|1057|id-ID' & @LF & '0422|1058|uk-UA' & @LF & '0423|1059|be-BY' & @LF & '0424|1060|sl-SI' & @LF & '0425|1061|et-EE' & @LF & '0426|1062|lv-LV' & @LF & '0427|1063|lt-LT' & @LF & '0428|1064|tg-Cyr' & @LF & '0429|1065|fa-IR' & @LF & '042A|1066|vi-VN' & @LF & '042B|1067|hy-AM' & @LF & '042C|1068|az-Lat' & @LF & '042D|1069|eu-ES' & @LF & '042E|1070|hsb-DE' & @LF & '042F|1071|mk-MK' & @LF & '0432|1074|tn-ZA' & @LF & '0434|1076|xh-ZA' & @LF & '0435|1077|zu-ZA' & @LF & '0436|1078|af-ZA' & @LF & '0437|1079|ka-GE' & @LF & '0438|1080|fo-FO' & @LF & '0439|1081|hi-IN' & @LF & '043A|1082|mt-MT' & @LF & '043B|1083|se-NO' & @LF & '043e|1086|ms-MY' & @LF & '043F|1087|kk-KZ' & @LF & '0440|1088|ky-KG' & @LF & '0441|1089|sw-KE' & @LF & '0442|1090|tk-TM' & @LF & '0443|1091|uz-Lat' & @LF & '0444|1092|tt-RU' & @LF & '0445|1093|bn-IN' & @LF & '0446|1094|pa-IN' & @LF & '0447|1095|gu-IN' & @LF & '0448|1096|or-IN' & @LF & '0449|1097|ta-IN' & @LF & '044A|1098|te-IN' & @LF & '044B|1099|kn-IN' & @LF & '044C|1100|ml-IN' & @LF & '044D|1101|as-IN' & @LF & '044E|1102|mr-IN' & @LF & '044F|1103|sa-IN' & @LF & '0450|1104|mn-MN' & @LF & '0451|1105|bo-CN' & @LF & '0452|1106|cy-GB' & @LF & '0453|1107|km-KH' & @LF & '0454|1108|lo-LA' & @LF & '0456|1110|gl-ES' & @LF & '0457|1111|kok-IN' & @LF & '0459|1113|sd-Dev' & @LF & '045A|1114|syr-SY' & @LF & '045B|1115|si-LK' & @LF & '045C|1116|chr-Che' & @LF & '045D|1117|iu-Can' & @LF & '045E|1118|am-ET' & @LF & '0461|1121|ne-NP' & @LF & '0462|1122|fy-NL' & @LF & '0463|1123|ps-AF' & @LF & '0464|1124|fil-PH' & @LF & '0465|1125|dv-MV' & @LF & '0468|1128|ha-Lat' & @LF & '046A|1130|yo-NG' & @LF & '046B|1131|quz-BO' & @LF & '046C|1132|nso-ZA' & @LF & '046D|1133|ba-RU' & @LF & '046E|1134|lb-LU' & @LF & '046F|1135|kl-GL' & @LF & '0470|1136|ig-NG' & @LF & '0473|1139|ti-ET' & @LF & '0475|1141|haw-US' & @LF & '0478|1144|ii-CN' & @LF & '047A|1146|arn-CL' & @LF & '047C|1148|moh-CA' & @LF & '047E|1150|br-FR' & @LF & '0480|1152|ug-CN' & @LF & '0481|1153|mi-NZ' & @LF & '0482|1154|oc-FR' & @LF & '0483|1155|co-FR' & @LF & '0484|1156|gsw-FR' & @LF & '0485|1157|sah-RU' & @LF & '0486|1158|quc-Lat' & @LF & '0487|1159|rw-RW' & @LF & '0488|1160|wo-SN' & @LF & '048C|1164|prs-AF' & @LF & '0491|1169|gd-GB' & @LF & '0492|1170|ku-Ara' & @LF & '0801|2049|ar-IQ' & @LF & '0803|2051|ca-E' & @LF & '0804|2052|zh-CN' & @LF & '0807|2055|de-CH' & @LF & '0809|2057|en-GB' & @LF & '080A|2058|es-MX' & @LF & '080C|2060|fr-BE' & @LF & '0810|2064|it-CH' & @LF & '0813|2067|nl-BE' & @LF & '0814|2068|nn-NO' & @LF & '0816|2070|pt-PT' & @LF & '081A|2074|sr-Lat' & @LF & '081D|2077|sv-FI' & @LF & '0820|2080|ur-IN' & @LF & '082C|2092|az-Cyr' & @LF & '082E|2094|dsb-DE' & @LF & '0832|2098|tn-BW' & @LF & '083B|2107|se-SE' & @LF & '083C|2108|ga-IE' & @LF & '083E|2110|ms-BN' & @LF & '0843|2115|uz-Cyr' & @LF & '0845|2117|bn-BD' & @LF & '0846|2118|pa-Ara' & @LF & '0849|2121|ta-LK' & @LF & '0850|2128|mn-Mon' & @LF & '0859|2137|sd-Ara' & @LF & '085D|2141|iu-Lat' & @LF & '085F|2143|tzm-Lat' & @LF & '0867|2151|ff-Lat' & @LF & '086B|2155|quz-EC' & @LF & '0873|2163|ti-ER' & @LF & '0873|2163|ti-ER' & @LF & '0C01|3073|ar-EG' & @LF & '0C04|3076|zh-HK' & @LF & '0C07|3079|de-AT' _ & @LF & '0C09|3081|en-AU' & @LF & '0C0A|3082|es-ES' & @LF & '0C0C|3084|fr-CA' & @LF & '0C1A|3098|sr-Cyr' & @LF & '0C3B|3131|se-FI' & @LF & '0C6B|3179|quz-PE' & @LF & '1001|4097|ar-LY' & @LF & '1004|4100|zh-SG' & @LF & '1007|4103|de-LU' & @LF & '1009|4105|en-CA' & @LF & '100A|4106|es-GT' & @LF & '100C|4108|fr-CH' & @LF & '101A|4122|hr-BA' & @LF & '103B|4155|smj-NO' & @LF & '105F|4191|tzm-Tfn' & @LF & '1401|5121|ar-DZ' & @LF & '1404|5124|zh-MO' & @LF & '1407|5127|de-LI' & @LF & '1409|5129|en-NZ' & @LF & '140A|5130|es-CR' & @LF & '140C|5132|fr-LU' & @LF & '141A|5146|bs-Lat' & @LF & '143B|5179|smj-SE' & @LF & '1801|6145|ar-MA' & @LF & '1809|6153|en-IE' & @LF & '180A|6154|es-PA' & @LF & '180C|6156|fr-MC' & @LF & '181A|6170|sr-Lat' & @LF & '183B|6203|sma-NO' & @LF & '1C01|7169|ar-TN' & @LF & '1c09|7177|en-ZA' & @LF & '1C0A|7178|es-DO' & @LF & '1C1A|7194|sr-Cyr' & @LF & '1C3B|7227|sma-SE' & @LF & '2001|8193|ar-OM' & @LF & '2009|8201|en-JM' & @LF & '200A|8202|es-VE' & @LF & '201A|8218|bs-Cyr' & @LF & '203B|8251|sms-FI' & @LF & '2401|9217|ar-YE' & @LF & '2409|9225|en-029' & @LF & '240A|9226|es-CO' & @LF & '241A|9242|sr-Lat' & @LF & '243B|9275|smn-FI' & @LF & '2801|10241|ar-SY' & @LF & '2809|10249|en-BZ' & @LF & '280A|10250|es-PE' & @LF & '281A|10266|sr-Cyr' & @LF & '2C01|11265|ar-JO' & @LF & '2C09|11273|en-TT' & @LF & '2C0A|11274|es-AR' & @LF & '2C1A|11290|sr-Lat' & @LF & '3001|12289|ar-LB' & @LF & '3009|12297|en-ZW' & @LF & '300A|12298|es-EC' & @LF & '301A|12314|sr-Cyr' & @LF & '3401|13313|ar-KW' & @LF & '3409|13321|en-PH' & @LF & '340A|13322|es-CL' & @LF & '3801|14337|ar-AE' & @LF & '380A|14346|es-UY' & @LF & '3C01|15361|ar-BH' & @LF & '3C0A|15370|es-PY' & @LF & '4001|16385|ar-QA' & @LF & '4009|16393|en-IN' & @LF & '400A|16394|es-BO' & @LF & '4409|17417|en-MY' & @LF & '440A|17418|es-SV' & @LF & '4809|18441|en-SG' & @LF & '480A|18442|es-HN' & @LF & '4C0A|19466|es-NI' & @LF & '500A|20490|es-PR' $sCommand = 'StringRegExpReplace($arr[_ArraySearch($arr,StringRight(@KBLayout, 4))][2], "\-(.*)", "")' Local $arr[0][3] _ArrayAdd($arr, $var, 0, "|", @LF) HotKeySet("!z", "ClipMessage") ; goes to function ;~ HotKeySet("!+", "ClipMessage") ; desired way = fails While 1 Sleep(10) WEnd Func ClipMessage() ;~ use alt + shift intermittently (test starting the script with different keboard sets.) Local Static $KBLayout = Execute($sCommand) Local $KBLayoutNew = Execute($sCommand) ConsoleWrite($KBLayout & @LF) ConsoleWrite( $KBLayoutNew & @LF) EndFunc Func Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
Dan_555 Posted December 3, 2022 Share Posted December 3, 2022 Maybe because the @kblayout is a macro and is set on the script execution ... it does not change in between, see $a=@KBLayout $b=1 while 1 if @KBLayout<>$a then $b=1 If $b=1 Then $a=@KBLayout $b=0 ConsoleWrite (@KBLayout & @CRLF) EndIf Sleep (1) WEnd and if it did, you should have the Quote Local Static $KBLayout = Execute($sCommand) defined outside the ClipMessage function (make it global) to have the initial keyboard set before the change. Some of my script sourcecode Link to comment Share on other sites More sharing options...
Dan_555 Posted December 3, 2022 Share Posted December 3, 2022 (edited) I have searched a bit around , but there was nothing that would work. So here is a crude workaround, (until someone gives a better solution) : save and compile this script as DetermineActiveKeyboardLayout.exe Exit (@KBLayout) Here is a test code for the above script: #include <String.au3> While 1 ConsoleWrite (DetermineActiveKeyboardLayout()& " " & @KBLayout &@CRLF) WEnd Func DetermineActiveKeyboardLayout() Sleep (500) $a= RunWait ("DetermineActiveKeyboardLayout.exe") Return _StringRepeat("0",8-StringLen($a)) & $a EndFunc And here is a working example of your script with my solution: expandcollapse popup#include <Array.au3> #include <WinAPISys.au3> #include <String.au3> HotKeySet("{ESC}", "Terminate") Local $var = '' & 'Hex|Dec|Country' & @LF & '0004|4|zh-CHS' & @LF & '0401|1025|ar-SA' & @LF & '0402|1026|bg-BG' & @LF & '0403|1027|ca-ES' & @LF & '0404|1028|zh-TW' & @LF & '0405|1029|cs-CZ' & @LF & '0406|1030|da-DK' & @LF & '0407|1031|de-DE' & @LF & '0408|1032|el-GR' & @LF & '0409|1033|en-US' & @LF & '040A|1034|es-ES_tradnl' & @LF & '040B|1035|fi-FI' & @LF & '040C|1036|fr-FR' & @LF & '040D|1037|he-IL' & @LF & '040E|1038|hu-HU' & @LF & '040F|1039|is-IS' & @LF & '0410|1040|it-IT' & @LF & '0411|1041|ja-JP' & @LF & '0412|1042|ko-KR' & @LF & '0413|1043|nl-NL' & @LF & '0414|1044|nb-NO' & @LF & '0415|1045|pl-PL' & @LF & '0416|1046|pt-BR' & @LF & '0417|1047|rm-CH' & @LF & '0418|1048|ro-RO' & @LF & '0419|1049|ru-RU' & @LF & '041A|1050|hr-HR' & @LF & '041B|1051|sk-SK' & @LF & '041C|1052|sq-AL' & @LF & '041D|1053|sv-SE' & @LF & '041E|1054|th-TH' & @LF & '041F|1055|tr-TR' & @LF & '0420|1056|ur-PK' & @LF & '0421|1057|id-ID' & @LF & '0422|1058|uk-UA' & @LF & '0423|1059|be-BY' & @LF & '0424|1060|sl-SI' & @LF & '0425|1061|et-EE' & @LF & '0426|1062|lv-LV' & @LF & '0427|1063|lt-LT' & @LF & '0428|1064|tg-Cyr' & @LF & '0429|1065|fa-IR' & @LF & '042A|1066|vi-VN' & @LF & '042B|1067|hy-AM' & @LF & '042C|1068|az-Lat' & @LF & '042D|1069|eu-ES' & @LF & '042E|1070|hsb-DE' & @LF & '042F|1071|mk-MK' & @LF & '0432|1074|tn-ZA' & @LF & '0434|1076|xh-ZA' & @LF & '0435|1077|zu-ZA' & @LF & '0436|1078|af-ZA' & @LF & '0437|1079|ka-GE' & @LF & '0438|1080|fo-FO' & @LF & '0439|1081|hi-IN' & @LF & '043A|1082|mt-MT' & @LF & '043B|1083|se-NO' & @LF & '043e|1086|ms-MY' & @LF & '043F|1087|kk-KZ' & @LF & '0440|1088|ky-KG' & @LF & '0441|1089|sw-KE' & @LF & '0442|1090|tk-TM' & @LF & '0443|1091|uz-Lat' & @LF & '0444|1092|tt-RU' & @LF & '0445|1093|bn-IN' & @LF & '0446|1094|pa-IN' & @LF & '0447|1095|gu-IN' & @LF & '0448|1096|or-IN' & @LF & '0449|1097|ta-IN' & @LF & '044A|1098|te-IN' & @LF & '044B|1099|kn-IN' & @LF & '044C|1100|ml-IN' & @LF & '044D|1101|as-IN' & @LF & '044E|1102|mr-IN' & @LF & '044F|1103|sa-IN' & @LF & '0450|1104|mn-MN' & @LF & '0451|1105|bo-CN' & @LF & '0452|1106|cy-GB' & @LF & '0453|1107|km-KH' & @LF & '0454|1108|lo-LA' & @LF & '0456|1110|gl-ES' & @LF & '0457|1111|kok-IN' & @LF & '0459|1113|sd-Dev' & @LF & '045A|1114|syr-SY' & @LF & '045B|1115|si-LK' & @LF & '045C|1116|chr-Che' & @LF & '045D|1117|iu-Can' & @LF & '045E|1118|am-ET' & @LF & '0461|1121|ne-NP' & @LF & '0462|1122|fy-NL' & @LF & '0463|1123|ps-AF' & @LF & '0464|1124|fil-PH' & @LF & '0465|1125|dv-MV' & @LF & '0468|1128|ha-Lat' & @LF & '046A|1130|yo-NG' & @LF & '046B|1131|quz-BO' & @LF & '046C|1132|nso-ZA' & @LF & '046D|1133|ba-RU' & @LF & '046E|1134|lb-LU' & @LF & '046F|1135|kl-GL' & @LF & '0470|1136|ig-NG' & @LF & '0473|1139|ti-ET' & @LF & '0475|1141|haw-US' & @LF & '0478|1144|ii-CN' & @LF & '047A|1146|arn-CL' & @LF & '047C|1148|moh-CA' & @LF & '047E|1150|br-FR' & @LF & '0480|1152|ug-CN' & @LF & '0481|1153|mi-NZ' & @LF & '0482|1154|oc-FR' & @LF & '0483|1155|co-FR' & @LF & '0484|1156|gsw-FR' & @LF & '0485|1157|sah-RU' & @LF & '0486|1158|quc-Lat' & @LF & '0487|1159|rw-RW' & @LF & '0488|1160|wo-SN' & @LF & '048C|1164|prs-AF' & @LF & '0491|1169|gd-GB' & @LF & '0492|1170|ku-Ara' & @LF & '0801|2049|ar-IQ' & @LF & '0803|2051|ca-E' & @LF & '0804|2052|zh-CN' & @LF & '0807|2055|de-CH' & @LF & '0809|2057|en-GB' & @LF & '080A|2058|es-MX' & @LF & '080C|2060|fr-BE' & @LF & '0810|2064|it-CH' & @LF & '0813|2067|nl-BE' & @LF & '0814|2068|nn-NO' & @LF & '0816|2070|pt-PT' & @LF & '081A|2074|sr-Lat' & @LF & '081D|2077|sv-FI' & @LF & '0820|2080|ur-IN' & @LF & '082C|2092|az-Cyr' & @LF & '082E|2094|dsb-DE' & @LF & '0832|2098|tn-BW' & @LF & '083B|2107|se-SE' & @LF & '083C|2108|ga-IE' & @LF & '083E|2110|ms-BN' & @LF & '0843|2115|uz-Cyr' & @LF & '0845|2117|bn-BD' & @LF & '0846|2118|pa-Ara' & @LF & '0849|2121|ta-LK' & @LF & '0850|2128|mn-Mon' & @LF & '0859|2137|sd-Ara' & @LF & '085D|2141|iu-Lat' & @LF & '085F|2143|tzm-Lat' & @LF & '0867|2151|ff-Lat' & @LF & '086B|2155|quz-EC' & @LF & '0873|2163|ti-ER' & @LF & '0873|2163|ti-ER' & @LF & '0C01|3073|ar-EG' & @LF & '0C04|3076|zh-HK' & @LF & '0C07|3079|de-AT' _ & @LF & '0C09|3081|en-AU' & @LF & '0C0A|3082|es-ES' & @LF & '0C0C|3084|fr-CA' & @LF & '0C1A|3098|sr-Cyr' & @LF & '0C3B|3131|se-FI' & @LF & '0C6B|3179|quz-PE' & @LF & '1001|4097|ar-LY' & @LF & '1004|4100|zh-SG' & @LF & '1007|4103|de-LU' & @LF & '1009|4105|en-CA' & @LF & '100A|4106|es-GT' & @LF & '100C|4108|fr-CH' & @LF & '101A|4122|hr-BA' & @LF & '103B|4155|smj-NO' & @LF & '105F|4191|tzm-Tfn' & @LF & '1401|5121|ar-DZ' & @LF & '1404|5124|zh-MO' & @LF & '1407|5127|de-LI' & @LF & '1409|5129|en-NZ' & @LF & '140A|5130|es-CR' & @LF & '140C|5132|fr-LU' & @LF & '141A|5146|bs-Lat' & @LF & '143B|5179|smj-SE' & @LF & '1801|6145|ar-MA' & @LF & '1809|6153|en-IE' & @LF & '180A|6154|es-PA' & @LF & '180C|6156|fr-MC' & @LF & '181A|6170|sr-Lat' & @LF & '183B|6203|sma-NO' & @LF & '1C01|7169|ar-TN' & @LF & '1c09|7177|en-ZA' & @LF & '1C0A|7178|es-DO' & @LF & '1C1A|7194|sr-Cyr' & @LF & '1C3B|7227|sma-SE' & @LF & '2001|8193|ar-OM' & @LF & '2009|8201|en-JM' & @LF & '200A|8202|es-VE' & @LF & '201A|8218|bs-Cyr' & @LF & '203B|8251|sms-FI' & @LF & '2401|9217|ar-YE' & @LF & '2409|9225|en-029' & @LF & '240A|9226|es-CO' & @LF & '241A|9242|sr-Lat' & @LF & '243B|9275|smn-FI' & @LF & '2801|10241|ar-SY' & @LF & '2809|10249|en-BZ' & @LF & '280A|10250|es-PE' & @LF & '281A|10266|sr-Cyr' & @LF & '2C01|11265|ar-JO' & @LF & '2C09|11273|en-TT' & @LF & '2C0A|11274|es-AR' & @LF & '2C1A|11290|sr-Lat' & @LF & '3001|12289|ar-LB' & @LF & '3009|12297|en-ZW' & @LF & '300A|12298|es-EC' & @LF & '301A|12314|sr-Cyr' & @LF & '3401|13313|ar-KW' & @LF & '3409|13321|en-PH' & @LF & '340A|13322|es-CL' & @LF & '3801|14337|ar-AE' & @LF & '380A|14346|es-UY' & @LF & '3C01|15361|ar-BH' & @LF & '3C0A|15370|es-PY' & @LF & '4001|16385|ar-QA' & @LF & '4009|16393|en-IN' & @LF & '400A|16394|es-BO' & @LF & '4409|17417|en-MY' & @LF & '440A|17418|es-SV' & @LF & '4809|18441|en-SG' & @LF & '480A|18442|es-HN' & @LF & '4C0A|19466|es-NI' & @LF & '500A|20490|es-PR' $sCommand = 'StringRegExpReplace($arr[_ArraySearch($arr,StringRight(DetermineActiveKeyboardLayout(), 4))][2], "\-(.*)", "")' Global $KBLayout Local $arr[0][3] _ArrayAdd($arr, $var, 0, "|", @LF) HotKeySet("!z", "ClipMessage") ; goes to function ;~ HotKeySet("!+", "ClipMessage") ; desired way = fails $KBLayout = Execute($sCommand) While 1 Sleep(10) WEnd Func ClipMessage() ;~ use alt + shift intermittently (test starting the script with different keboard sets.) Local $KBLayoutNew = Execute($sCommand) ConsoleWrite("Old: " & $KBLayout & " new: " & $KBLayoutNew & @CRLF) EndFunc Func Terminate() Exit EndFunc Func DetermineActiveKeyboardLayout() Sleep (500) $a= RunWait ("DetermineActiveKeyboardLayout.exe") Return _StringRepeat("0",8-StringLen($a)) & $a EndFunc Edited December 3, 2022 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
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