Jump to content

little trouble with "Run..." window


Recommended Posts

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:

#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])
EndFunc

I 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 by Dirk Diggler
Link to comment
Share on other sites

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+r

HotKeySet("^+r", "LaunchRunDialog")

While 1

sleep(100)

Wend

Func 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

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. :o 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

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 :o
Link to comment
Share on other sites

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

so, i tried to make my own Run dialog, but i still can't change the layout.

$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 by Dirk Diggler
Link to comment
Share on other sites

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

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 = 1033

Const $RUS = 1049

Const $WM_INPUTLANGCHANGEREQUEST = 0x50

$WinTitle = "Run"

$layout = $ENU

Opt("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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...