Dirk Diggler Posted February 18, 2006 Share Posted February 18, 2006 (edited) I wrote a little script that helps me in my work(plz don't mind my English, i'm Russian,so speak not very well). It does one thing - waits for window titled $title is active, then changes keyboard layout to english(0x409), then waits for this window deactivation. So, this is script:expandcollapse popup#NoTrayIcon Const $DEU = "00000407" Const $ENU = "00000409" Const $FRA = "0000040C" Const $FIN = "0000040D" Const $ITA = "00000410" Const $PLK = "00000415" Const $RUS = "00000419" Const $UKR = "00000422" Const $BLR = "00000423" Const $EST = "00000425" Const $LTH = "00000426" Const $LVI = "00000427" Const $CHS = "00000804" Const $CHT = "00000404" ; --------=========================parameters========================------------- ; $WinTitle = "cmd.exe" $layout = $CHS ; --------========================code=======================------------- Opt("TrayIconDebug", 1) Opt("WinTitleMatchMode", 2) WinWaitActive($WinTitle) Opt("WinTitleMatchMode",4) $hWnd = WinGetHandle("last") ; uncomment(discomment?) next line to make sure that $hWnd contains correct handle ;WinClose($hWnd) _SetKeyboardLayout($layout, $hWnd) Opt("WinTitleMatchMode", 2) WinWaitNotActive($WinTitle) ; or WinWaitNotActive($hWnd) Exit Func _SetKeyboardLayout($sLayoutID, $hWnd) Local $WM_INPUTLANGCHANGEREQUEST = 0x50 Local $ret = DllCall("user32.dll", "long", "LoadKeyboardLayout", "str", $sLayoutID, "int", 0) DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hWnd, "int", $WM_INPUTLANGCHANGEREQUEST, "int", 1, "int", $ret[0]) EndFuncI have a problem with changing layout in window that appears when you press Win+R. Recieved by WinGetHandle("last") handle is correct, but when i activate this window, layout is still russian(or any other). With other windows this script works correctly. What should i do ??? Edited February 18, 2006 by Dirk Diggler Link to comment Share on other sites More sharing options...
greenmachine Posted February 18, 2006 Share Posted February 18, 2006 I don't think you can change keyboard layout without restarting the computer. Link to comment Share on other sites More sharing options...
CyberSlug Posted February 18, 2006 Share Posted February 18, 2006 You might need to ProcessClose("explorer.exe") and restart it for the language change to affect the Run Dialog.Or you can try the following program which launches the run dialog in a different way RunDialog.exe. (I forget the website that has technical details, but I think this EXE should work.)Unfortunately, AutoIt will not let you HotKeySet("#r",...) so you might want to assign another hotkey such as Alt+Ctrl+rHotKeySet("^+r", "LaunchRunDialog")While 1sleep(100)WendFunc LaunchRunDialog()Run("runDialog.exe")EndFunc Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Dirk Diggler Posted February 18, 2006 Author Share Posted February 18, 2006 Thanks fo replies.May be, i should try to send keystrokes that switches layout? but, i don't know how to receive current layout of window to check, if it already is English.Unfortunately, AutoIt will not let you HotKeySet("#r",...)it's not a problem. i will schedule it in nnCron, nnCron lets set any key combination as hotkey. originally, i want to make this script in nnCron, but nnCron can't switch layout in console window. Link to comment Share on other sites More sharing options...
Dirk Diggler Posted February 19, 2006 Author Share Posted February 19, 2006 Or you can try the following program which launches the run dialog in a different way RunDialog.exe.How i should try this? just launch it, then switch layout in it's window - doesn't work, layout still remains russian (or what set as default). First switch, then launch - i don't know where switch, in what window Link to comment Share on other sites More sharing options...
CyberSlug Posted February 19, 2006 Share Posted February 19, 2006 just launch it, then switch layout in it's window - doesn't work, layout still remains russian (or what set as default).I did not know for sure if it would work. In this case, the explorer.exe process might need restarted. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Dirk Diggler Posted February 19, 2006 Author Share Posted February 19, 2006 may be, you can help me in other task - how to retrieve current layout of "Run" window? Link to comment Share on other sites More sharing options...
Dirk Diggler Posted February 21, 2006 Author Share Posted February 21, 2006 (edited) so, i tried to make my own Run dialog, but i still can't change the layout. expandcollapse popup$layout = "00000409" HotKeySet("{ESC}", "MyExit") #region --- GuiBuilder code Start --- ; Script generated by AutoBuilder 0.6 Prototype #include <GuiConstants.au3> $hWnd=GuiCreate("Run", 351, 79,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $ComboRun = GuiCtrlCreateCombo("cmd", 50, 10, 280, 21) $Label_2 = GuiCtrlCreateLabel("Run...", 10, 10, 30, 20) $ButtonRun = GuiCtrlCreateButton("Run", 10, 40, 110, 30,$BS_DEFPUSHBUTTON) $ButtonCancel = GuiCtrlCreateButton("Cancel", 130, 40, 110, 30) $ButtonBrowse = GuiCtrlCreateButton("Browse...", 250, 40, 90, 30) _SetKeyboardLayout($layout, $hWnd) GuiSetState() FillComboListHistory() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $ButtonRun Run(GUICtrlRead($ComboRun),@WindowsDir & "\System32") MyExit() Case $msg = $ButtonBrowse GUICtrlSetData($ComboRun,FileOpenDialog("Choose program to run","c:\","All (*.*)")) Case $msg = $ButtonCancel MyExit() Case Else ;;; EndSelect WEnd Exit #endregion --- GuiBuilder generated code End --- Func MyExit() Exit EndFunc Func FillComboListHistory() EndFunc Func _SetKeyboardLayout($sLayoutID, $hWnd) Local $WM_INPUTLANGCHANGEREQUEST = 0x50 Local $ret = DllCall("user32.dll", "long", "LoadKeyboardLayout", "str", $sLayoutID, "int", 0) DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hWnd, "int", $WM_INPUTLANGCHANGEREQUEST, "int", 1, "int", $ret[0]) MsgBox(0,"",@error) EndFunc what is wrong now??? Edited February 21, 2006 by Dirk Diggler Link to comment Share on other sites More sharing options...
andyswarbs Posted February 21, 2006 Share Posted February 21, 2006 There is a 3rd party tool called SetLocale that may help. Get a copy at http://www.spectrodisplay.nl/download/setlocale.zip Licensing.au3Extended _Max & _Min_MsgBoxExitVarious extensions to _GuiCtrl...Run Dos programs output into an array etc (Updated 19-Feb-06)Extensions to Array library, primarily in two dimensions (updated 20-Feb-06)Version dependency calculator, _IsVer1GEVer2User Management, answering some domain questions (updated 19-Feb-06, various bugfixes and new functions added)Extensions to registry manipulation, including a recursive search & replaceDelimited string library (updated 19-Feb-03, added _DelimListSort)String library extensionsTerminal Server supportFile libraryCommand line parser (added 18-Feb-06)(UDF homepage) (Scit4Au3 UserCallTips added 21-Feb-06) Link to comment Share on other sites More sharing options...
Dirk Diggler Posted February 21, 2006 Author Share Posted February 21, 2006 this is not what i want, i guess... This utility will change system locale instead of keyboard layout, isn't? I don't understand why this function(i mean _SetKeyboardLayout) is able to change layout in console windows like cmd.exe, but can't do it in ordinary gui window.... Link to comment Share on other sites More sharing options...
Dirk Diggler Posted February 21, 2006 Author Share Posted February 21, 2006 well, i solved the problem. i don't know why, but this script can't change layout of console windows, but can do it in standart "Run" dialog:Const $ENU = 1033Const $RUS = 1049Const $WM_INPUTLANGCHANGEREQUEST = 0x50$WinTitle = "Run"$layout = $ENUOpt("TrayIconDebug", 1)Opt("WinTitleMatchMode", 2)WinWaitActive($WinTitle)Opt("WinTitleMatchMode",4)$hWnd = WinGetHandle("last")GUICtrlSendMsg($hWnd,$WM_INPUTLANGCHANGEREQUEST,0,$layout)Opt("WinTitleMatchMode", 2)WinWaitNotActive($hWnd)Exit Link to comment Share on other sites More sharing options...
Dirk Diggler Posted February 24, 2006 Author Share Posted February 24, 2006 it is very strange, but it WORKS on my computer in office, but on my home computer, as it must be, doesn't. i don't understand, why it works at least at one computer ? Link to comment Share on other sites More sharing options...
greenmachine Posted February 25, 2006 Share Posted February 25, 2006 Well, if you have the specs of the computer at home and the computer at work, I'm sure that would help the rest of us (possible bug? who knows). Also, is the version of AutoIt the same at home and work? That could make a difference as well. 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