Alexxander Posted August 2, 2013 Share Posted August 2, 2013 hi all i have this small code HotKeySet ("ش", "sh") HotKeySet ("a", "a") Func sh() MsgBox (0, "", "AR") EndFunc Func a() MsgBox(0, "", "EN") EndFunc While 1 Sleep (1000) WEnd letter "a" is english if u used and arabic language then pressed letter "a" you will have letter "ش" so the same key on keyboard but it differ in output depends on what is the language u r using when i run the script if the language was english at the moment i ran the script then i pressed "a" it will give me a msgbox "EN" and when i run the script if the language was arabic at the moment i run the script then i pressed "ش" it will give me a msgbox "AR" and that is what i want.. the problem is if the language was english and i pressed "a" it will give "EN" but when i switch language (and the script is still running) and make it arabic then i press "ش" it will still give me "EN" if i closed the script then reopened it with arabic language then pressed "ش" it will give arabic so when i switch the lang when the script still running it will still give me a msgbox about the old lang i want it to give me the right msgbox even if i switched the lang when the script is running i hope u got the idea ? Link to comment Share on other sites More sharing options...
Edano Posted August 2, 2013 Share Posted August 2, 2013 (edited) try the macros in msgboxes: @OSLang and @KBLayout and tell us the results in each configuration. that might help. this i mean: . MsgBox(0,@OSLang,@KBLayout) Edited August 2, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Mat Posted August 2, 2013 Share Posted August 2, 2013 I'd try using EnvUpdate. AutoIt Project Listing Link to comment Share on other sites More sharing options...
FireFox Posted August 2, 2013 Share Posted August 2, 2013 (edited) Hi,Try this:expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> _HotKey_Enable() #region GUI Local $hGUI = GUICreate("MyGUI") GUIRegisterMsg($WM_INPUTLANGCHANGE, "WM_INPUTLANGCHANGE") GUISetState(@SW_SHOW, $hGUI) #endregion While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd GUIDelete($hGUI) Func WM_INPUTLANGCHANGE($hWnd, $iMsg, $wParam, $lParam) HotKeySet("ش") HotKeySet("a") _HotKey_Enable() Return $GUI_RUNDEFMSG EndFunc ;==>WM_INPUTLANGCHANGE Func _HotKey_Enable() HotKeySet("ش", "sh") HotKeySet("a", "a") EndFunc ;==>_HotKey_Enable Func sh() MsgBox(0, "", "AR") EndFunc ;==>sh Func a() MsgBox(0, "", "EN") EndFunc ;==>aBr, FireFox. Edited August 2, 2013 by FireFox Link to comment Share on other sites More sharing options...
Edano Posted August 2, 2013 Share Posted August 2, 2013 GUIRegisterMsg($WM_INPUTLANGCHANGE, "WM_INPUTLANGCHANGE") . wow. [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Alexxander Posted August 2, 2013 Author Share Posted August 2, 2013 try the macros in msgboxes: @OSLang and @KBLayout and tell us the results in each configuration. that might help. this i mean: . MsgBox(0,@OSLang,@KBLayout) tnx bro this is useful but the result differ from a country to another even if it is the same lang so it won't work for me i want it to just look for the keyboard lang whatever the country is I'd try using EnvUpdate. it didn't work for me it hadn't done any Hi, Try this: expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> _HotKey_Enable() #region GUI Local $hGUI = GUICreate("MyGUI") GUIRegisterMsg($WM_INPUTLANGCHANGE, "WM_INPUTLANGCHANGE") GUISetState(@SW_SHOW, $hGUI) #endregion While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd GUIDelete($hGUI) Func WM_INPUTLANGCHANGE($hWnd, $iMsg, $wParam, $lParam) HotKeySet("ش") HotKeySet("a") _HotKey_Enable() Return $GUI_RUNDEFMSG EndFunc ;==>WM_INPUTLANGCHANGE Func _HotKey_Enable() HotKeySet("ش", "sh") HotKeySet("a", "a") EndFunc ;==>_HotKey_Enable Func sh() MsgBox(0, "", "AR") EndFunc ;==>sh Func a() MsgBox(0, "", "EN") EndFunc ;==>a Br, FireFox. tnx bo that works but it is too complicated to me i'm still new to autoit is there is a way without using GUI ? Link to comment Share on other sites More sharing options...
FireFox Posted August 2, 2013 Share Posted August 2, 2013 (edited) tnx bo that works but it is too complicated to me i'm still new to autoit is there is a way without using GUI ?Just hide the GUI, remove the GUISetState function Edited August 2, 2013 by FireFox Link to comment Share on other sites More sharing options...
Alexxander Posted August 2, 2013 Author Share Posted August 2, 2013 (edited) Just hide the GUI, remove the GUISetState function what about this code ? HotKeySet ("a", "a") While 1 Sleep (100) WEnd Func a() $hWnd = 0 Local $aRet = DllCall('user32.dll', 'long', 'GetWindowThreadProcessId', 'hwnd', $hWnd, 'ptr', 0) $aRet = DllCall('user32.dll', 'long', 'GetKeyboardLayout', 'long', $aRet[0]) Global $var = Hex($aRet[0], 4) if $var = 2801 then MsgBox(0, "", "AR") if $var = 0409 then MsgBox(0, "", "EN") EndFunc it workes for me without restarting the scriptbit it give the old lang 2 times i mean if the lang was EN then i pressed "A" it will msgbox "EN" and when i switched it to AR then pressed "a" it will msgbox "EN"but at the second time i press "A" without changing lang wit will give the right choice aany ideas ? Edited August 2, 2013 by alexander95 Link to comment Share on other sites More sharing options...
Edano Posted August 3, 2013 Share Posted August 3, 2013 (edited) what about this code ? HotKeySet ("a", "a") While 1 Sleep (100) WEnd Func a() $hWnd = 0 Local $aRet = DllCall('user32.dll', 'long', 'GetWindowThreadProcessId', 'hwnd', $hWnd, 'ptr', 0) $aRet = DllCall('user32.dll', 'long', 'GetKeyboardLayout', 'long', $aRet[0]) Global $var = Hex($aRet[0], 4) if $var = 2801 then MsgBox(0, "", "AR") if $var = 0409 then MsgBox(0, "", "EN") EndFunc it workes for me without restarting the scriptbit it give the old lang 2 times i mean if the lang was EN then i pressed "A" it will msgbox "EN" and when i switched it to AR then pressed "a" it will msgbox "EN"but at the second time i press "A" without changing lang wit will give the right choice aany ideas ? . just fyi: your solution is the same as mine - @KBLayout E then just make a loop and do the function twice and then the msgbox Edited August 3, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Edano Posted August 3, 2013 Share Posted August 3, 2013 (edited) looking deeper into your code ..... makes me wonder you force a hexadecimal expression and then use it as a number and not a string and not a hex ....... very mysterious how that gets you a correct result. . $aRet = DllCall('user32.dll', 'long', 'GetKeyboardLayout', 'long', 0) MsgBox(0,@KBLayout,Hex($aRet[0],4)) Edited August 3, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Edano Posted August 3, 2013 Share Posted August 3, 2013 (edited) it is hard to help, because we cannot reproduce the problem, but try this: . ;http://www.autoitscript.com/forum/topic/153257-msgbox-error-need-help/#entry1102671 ;Post #8 ;D:\DOKUME~1\ADMINI~1\LOKALE~1\Temp\SLICER\Avatar\photo-thumb-80182.gif ;by alexander95 ;Script grabbed by SLICER by Edano here: http://www.autoitscript.com/forum/topic/152402-slicer-autoit-forum-script-grabber/?p=1093575 HotKeySet ("a", "a") While 1 Sleep (100) WEnd Func a() $var=@KBLayout $var=@KBLayout; =====> call it twice ? if $var = 2801 then MsgBox(0, "", "AR") if $var = 0409 then MsgBox(0, "", "EN") EndFunc . E or use melba's luxus version, technically the best solution: . expandcollapse popup;http://www.autoitscript.com/forum/topic/153257-msgbox-error-need-help/#entry1102671 ;Post #4 ;D:\DOKUME~1\ADMINI~1\LOKALE~1\Temp\SLICER\Avatar\photo-thumb-42741.jpg ;by FireFox ;Script grabbed by SLICER by Edano here: http://www.autoitscript.com/forum/topic/152402-slicer-autoit-forum-script-grabber/?p=1093575 #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> _HotKey_Enable() #region GUI Local $hGUI = GUICreate("MyGUI") GUIRegisterMsg($WM_INPUTLANGCHANGE, "WM_INPUTLANGCHANGE") ;GUISetState(@SW_SHOW, $hGUI) #endregion While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd ;GUIDelete($hGUI) Func WM_INPUTLANGCHANGE($hWnd, $iMsg, $wParam, $lParam) HotKeySet("Ø´") HotKeySet("a") _HotKey_Enable() Return $GUI_RUNDEFMSG EndFunc ;==>WM_INPUTLANGCHANGE Func _HotKey_Enable() HotKeySet("Ø´", "sh") HotKeySet("a", "a") EndFunc ;==>_HotKey_Enable Func sh() MsgBox(0, "", "AR") EndFunc ;==>sh Func a() MsgBox(0, "", "EN") EndFunc ;==>a Edited August 3, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Alexxander Posted August 3, 2013 Author Share Posted August 3, 2013 it is hard to help, because we cannot rreproduce the problem, but try this: . ;http://www.autoitscript.com/forum/topic/153257-msgbox-error-need-help/#entry1102671 ;Post #8 ;D:\DOKUME~1\ADMINI~1\LOKALE~1\Temp\SLICER\Avatar\photo-thumb-80182.gif ;by alexander95 ;Script grabbed by SLICER by Edano here: http://www.autoitscript.com/forum/topic/152402-slicer-autoit-forum-script-grabber/?p=1093575 HotKeySet ("a", "a") While 1 Sleep (100) WEnd Func a() $var=@KBLayout $var=@KBLayout; =====> call it twice ? if $var = "2801" then MsgBox(0, "", "AR") if $var = "0409" then MsgBox(0, "", "EN") EndFunc . E it didnt worked at all when i press "a" nothing happens Link to comment Share on other sites More sharing options...
Edano Posted August 3, 2013 Share Posted August 3, 2013 i edited it; try it again. [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Alexxander Posted August 3, 2013 Author Share Posted August 3, 2013 or use melba's luxus version, technically the best solution: yes it is the only working but u cant fully understand it i can't write think i don't understand to my script it will make more problems Link to comment Share on other sites More sharing options...
Edano Posted August 3, 2013 Share Posted August 3, 2013 (edited) yes it is the only working but u cant fully understand it i can't write think i don't understand to my script it will make more problems . did you try my edited version again ???? ok i repost it once again. seem to be communication problems. . ;http://www.autoitscript.com/forum/topic/153257-msgbox-error-need-help/#entry1102671 ;Post #8 ;D:\DOKUME~1\ADMINI~1\LOKALE~1\Temp\SLICER\Avatar\photo-thumb-80182.gif ;by alexander95 ;Script grabbed by SLICER by Edano here: http://www.autoitscript.com/forum/topic/152402-slicer-autoit-forum-script-grabber/?p=1093575 HotKeySet ("a", "a") While 1 Sleep (100) WEnd Func a() $var=@KBLayout $var=@KBLayout; =====> call it twice ? if $var = 2801 then MsgBox(0, "", "AR") if $var = 0409 then MsgBox(0, "", "EN") EndFunc Edited August 3, 2013 by Edano [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
Alexxander Posted August 3, 2013 Author Share Posted August 3, 2013 . did you try my edited version again ???? ok i repost it once again. seem to be communication problems. . ;http://www.autoitscript.com/forum/topic/153257-msgbox-error-need-help/#entry1102671 ;Post #8 ;D:\DOKUME~1\ADMINI~1\LOKALE~1\Temp\SLICER\Avatar\photo-thumb-80182.gif ;by alexander95 ;Script grabbed by SLICER by Edano here: http://www.autoitscript.com/forum/topic/152402-slicer-autoit-forum-script-grabber/?p=1093575 HotKeySet ("a", "a") While 1 Sleep (100) WEnd Func a() $var=@KBLayout $var=@KBLayout; =====> call it twice ? if $var = 2801 then MsgBox(0, "", "AR") if $var = 0409 then MsgBox(0, "", "EN") EndFunc it only works for EN it never gives AR Link to comment Share on other sites More sharing options...
Edano Posted August 3, 2013 Share Posted August 3, 2013 oh boy, and if you add HotKeySet ("ش", "a") . at the top ? [color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font] Link to comment Share on other sites More sharing options...
FireFox Posted August 3, 2013 Share Posted August 3, 2013 (edited) or use melba's luxus versionhm?? yes it is the only working but u cant fully understand iti can't write think i don't understand to my script it will make more problemsI added some comments :expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> ; Call the function to set the hotkeys _HotKey_Enable() ; Create a hidden GUI and register to the INPUTLANGCHANGE window message. ; This WM (Window Message) will trigger its function when the user changes its keyboard layout. #region GUI Local $hGUI = GUICreate("MyGUI") GUIRegisterMsg($WM_INPUTLANGCHANGE, "WM_INPUTLANGCHANGE") #endregion ; Keep the script alive While 1 Sleep(10) WEnd Func WM_INPUTLANGCHANGE($hWnd, $iMsg, $wParam, $lParam) ; Unset the hotkeys HotKeySet("ش") HotKeySet("a") ; Re-set the hotkeys _HotKey_Enable() Return $GUI_RUNDEFMSG EndFunc ;==>WM_INPUTLANGCHANGE Func _HotKey_Enable() HotKeySet("ش", "sh") HotKeySet("a", "a") EndFunc ;==>_HotKey_Enable Func sh() MsgBox(0, "", "AR") EndFunc ;==>sh Func a() MsgBox(0, "", "EN") EndFunc ;==>aAll clear? Br, FireFox. Edited August 3, 2013 by FireFox Link to comment Share on other sites More sharing options...
AZJIO Posted August 17, 2013 Share Posted August 17, 2013 You have the same problem? My other projects or all 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