Sign in to follow this  
Followers 0
Wiwo

Support for different user languages

17 posts in this topic

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

No, there is no partial match in the title text.

Share this post


Link to post
Share on other sites

Wiwo

By window class, example for notepad:

WinWaitActive("[Class:Notepad]")

Posted Image

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Does not work :-(

Try this:

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

Share this post


Link to post
Share on other sites

Does not work :-(

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


When the words fail... music speaks

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

You use OSLang to get language?


When the words fail... music speaks

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

Share this post


Link to post
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().

Share this post


Link to post
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]"

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.

[center]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.[/center]

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0