Jump to content

Support for different user languages


Wiwo
 Share

Recommended Posts

Hello *,

how do you implement support for multiple user languages?

For example I want to use the WinWaitActive() function which expects a title match. But I have to automate this package for different user languages in Windows. The predefined macro @OSlang only returns the system language - not the language the user is working with. So I will have to define this title for multiple languages - this is not supported in AutoIT.

Do you have any suggestions? Has anyone else already implemented a function which returns the user language?

Thanx a lot!

Wolfgang

Link to comment
Share on other sites

Hello *,

how do you implement support for multiple user languages?

For example I want to use the WinWaitActive() function which expects a title match. But I have to automate this package for different user languages in Windows. The predefined macro @OSlang only returns the system language - not the language the user is working with. So I will have to define this title for multiple languages - this is not supported in AutoIT.

Do you have any suggestions? Has anyone else already implemented a function which returns the user language?

Thanx a lot!

Wolfgang

Maybe a part of title is same in all languages and then you can use WinTitleMatchMod.

When the words fail... music speaks.

Link to comment
Share on other sites

Hello rasim,

thanx a lot. This solution now works fine for me for the WinWaitActive function. Now I've tried to click a control by ID without success. Do you can help me once again.

WinWaitActive("[Class:#32770]", "", 60) -> is OK

ControlClick("[Class:#32770]", "", 1) -> FAILS

----- Window Info -----

>>>> Window <<<<

Title: Ausführen als

Class: #32770

Position: 448, 328

Size: 384, 314

Style: 0x94C80BCC

ExStyle: 0x00010101

Handle: 0x00020A56

>>>> Control <<<<

Class: Button

Instance: 5

ClassnameNN: Button5

Advanced (Class): [CLASS:Button; INSTANCE:5]

ID: 1

Text: OK

Position: 209, 255

Size: 75, 23

ControlClick Coords: 48, 9

Style: 0x50010000

ExStyle: 0x00000004

Handle: 0x000D0A20

----- Window Info -----

Best Regards,

Wolfgang

Wiwo

By window class, example for notepad:

WinWaitActive("[Class:Notepad]")

Posted Image

Link to comment
Share on other sites

Hello rasim,

thanx a lot. This solution now works fine for me for the WinWaitActive function. Now I've tried to click a control by ID without success. Do you can help me once again.

WinWaitActive("[Class:#32770]", "", 60) -> is OK

ControlClick("[Class:#32770]", "", 1) -> FAILS

----- Window Info -----

>>>> Window <<<<

Title: Ausführen als

Class: #32770

Position: 448, 328

Size: 384, 314

Style: 0x94C80BCC

ExStyle: 0x00010101

Handle: 0x00020A56

>>>> Control <<<<

Class: Button

Instance: 5

ClassnameNN: Button5

Advanced (Class): [CLASS:Button; INSTANCE:5]

ID: 1

Text: OK

Position: 209, 255

Size: 75, 23

ControlClick Coords: 48, 9

Style: 0x50010000

ExStyle: 0x00000004

Handle: 0x000D0A20

----- Window Info -----

Best Regards,

Wolfgang

Try this:

ControlClick ( "[Class:#32770]", "","[CLASSNN:Button5]")
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

Hmm, now the function executes without an error but the control is not being clicked.

ControlClick ( "[Class:#32770]", "","[CLASSNN:Button5]")

Wouldn't it be better do implement support for different languages? I then only need a function to determine the user language setting, the script is better readable, but I didn't find any solution.

Switch $language

Case "de"

ControlClick("Ausführen als", "Benutzer", 1)

Case "en"

ControlClick("Run as", "User", 1)

EndSwitch

Sorry, I forget this "]", look at my edit and try now.

Link to comment
Share on other sites

You can use a Language.ini file and read GUI title, controls,... in any language, and then ControlClick is not a problem:

IniWrite(@ScriptDir & "\Language.ini","EN","TITLE","Run as")
IniWrite(@ScriptDir & "\Language.ini","EN","TEXT","User")
IniWrite(@ScriptDir & "\Language.ini","DE","TITLE","Ausführen als")
IniWrite(@ScriptDir & "\Language.ini","DE","TEXT","Benutzer")

$GUI = GUICreate("Select language",100,55,-1,-1)
$LANG = GUICtrlCreateCombo("",10,5,80,20)
GUICtrlSetData($LANG,"EN" & "|" & "DE","EN")
$SELECT = GUICtrlCreateButton("OK",20,30,60,20)
GUISetState(@SW_SHOW,$GUI)

While 1
    $MSG = GUIGetMsg()
    If $MSG = $SELECT Then
        $LANGUAGE = GUICtrlRead($LANG)
        GUIDelete($GUI)
        Program($LANGUAGE)
    EndIf
    Sleep(10)
WEnd

Func Program($LANGUAGE)
    Local $MSG,$TITLE,$TEXT
    $TITLE = IniRead(@ScriptDir & "\Language.ini",$LANGUAGE,"TITLE","Error")
    $TEXT = IniRead(@ScriptDir & "\Language.ini",$LANGUAGE,"TEXT","Error")
    Local $GUI = GUICreate($TITLE,400,400,-1,-1)
    GUISetState()
    While 1
        $MSG = GUIGetMsg()
        If $MSG = -3 Then
            Exit
        EndIf
    WEnd
EndFunc
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

Thanx a lot for your effort. But the script should do an unattended installation -> no user interaction. Therefore I will need a function to get the current user language setting from windows.

You can use a Language.ini file and read GUI title, controls,... in any language, and then ControlClick is not a problem:

IniWrite(@ScriptDir & "\Language.ini","EN","TITLE","Run as")
IniWrite(@ScriptDir & "\Language.ini","EN","TEXT","User")
IniWrite(@ScriptDir & "\Language.ini","DE","TITLE","Ausführen als")
IniWrite(@ScriptDir & "\Language.ini","DE","TEXT","Benutzer")

$GUI = GUICreate("Select language",100,55,-1,-1)
$LANG = GUICtrlCreateCombo("",10,5,80,20)
GUICtrlSetData($LANG,"EN" & "|" & "DE","EN")
$SELECT = GUICtrlCreateButton("OK",20,30,60,20)
GUISetState(@SW_SHOW,$GUI)

While 1
    $MSG = GUIGetMsg()
    If $MSG = $SELECT Then
        $LANGUAGE = GUICtrlRead($LANG)
        GUIDelete($GUI)
        Program($LANGUAGE)
    EndIf
    Sleep(10)
WEnd

Func Program($LANGUAGE)
    Local $MSG,$TITLE,$TEXT
    $TITLE = IniRead(@ScriptDir & "\Language.ini",$LANGUAGE,"TITLE","Error")
    $TEXT = IniRead(@ScriptDir & "\Language.ini",$LANGUAGE,"TEXT","Error")
    Local $GUI = GUICreate($TITLE,400,400,-1,-1)
    GUISetState()
    While 1
        $MSG = GUIGetMsg()
        If $MSG = -3 Then
            Exit
        EndIf
    WEnd
EndFunc
Link to comment
Share on other sites

The Installer is running in the user context, therefore the user language setting is taken for installation. The predefined macro @OSlang only returns the system language - not the language the user is working with.

You use OSLang to get language?

Link to comment
Share on other sites

  • Moderators

Try ControlFocus(same 1st 3 params as controlclick()) before ControlClick().

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I've tried your suggestion but this does not help. The focus is not the problem.

When I try to execute the following function, it works:

ControlClick("[Class:#32770]", "OK", 1)

There must be a problem with the parameter "[CLASSNN:Button5]"

Try ControlFocus(same 1st 3 params as controlclick()) before ControlClick().

Link to comment
Share on other sites

  • Moderators

I've tried your suggestion but this does not help. The focus is not the problem.

When I try to execute the following function, it works:

ControlClick("[Class:#32770]", "OK", 1)

There must be a problem with the parameter "[CLASSNN:Button5]"

Might try: [CLASS:Button; INSTANCE:5], other than that I don't know. There should be no issue with the ControlID (1) unless it changes randomly like some apps do.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

No success, the ControlID does not change. Now I think I have to look for an API function to detect the current user language.

Might try: [CLASS:Button; INSTANCE:5], other than that I don't know. There should be no issue with the ControlID (1) unless it changes randomly like some apps do.

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