Jump to content

Recommended Posts

Posted (edited)

I work as an IT technician, I recently moved country. This poses a minor problem (sometimes) in the sense that the operating systems I work on are quite often in Swedish.

I just started work on a script that will change the current display language to English, then back again to Swedish.

I would looked into ways to do this silently, it seems to be that you need to create a ini or xml (depending on the OS), then run intl.cpl with a command line parameter pointing to the ini or xml. (Source: http://www.microsoft.com/middleeast/arabicdev/DevTools/more/RegionalSettings.aspx#4_1)

After fighting with it for 2 days, with no success, I gave up and automated opening regional language settings.

So my questions are:

1. Why does @OSLang return English when the PC is set to Swedish?

2. Has any one done this, or anything similar before? I've repeatedly looked and turned up little-to-nothing.

3. Is there a way to change the display language through dll calls?

Of course, here is what I have got so far.

Let it be known I tried on my own to do this, using different methods. Only when I felt I had exhausted my resources that I came to ask for help.

Thanks for your time.

;Returns english when swedish is set as the display language?
Select
    Case @MUILang == 0000
        MsgBox(0, "No dice...", "MUI not installed")
        ;Detect active language, then silently install appropriate language pack?
        ;Note: I must find standalone language packages.
        Exit
    Case StringInStr("0409 0809 0c09 1009 1409 1809 1c09 2009 2409 2809 2c09 3009 3409", @OSLang)
        _ChangeLanguage("Eng", @OSVersion) 
    Case StringInStr("041d 081d", @OSLang)
        _ChangeLanguage("Swe", @OSVersion)
    Case Else
        MsgBox(0, "No dice...", "Unrecognised local language")
EndSelect

Func _ChangeLanguage($Language, $OS)
    Select
        Case $Language == "Eng" And $OS == "WIN_7"
            Global $Title = "Region and Language"
            ToolTip("Current language: English", 5, 21)
            Run("control intl.cpl")
            If @error Then
                MsgBox(0, "Uhhhh..", "Houston, we have a problem")
                Exit
            EndIf
            WinWait($Title, "", 3)
            If WinExists("Nationella inställningar och språkinställningar") Then ContinueCase ;Workaround!!!
            ControlClick($Title, "", "SysTabControl321", "Primary", 1, 155, 10)
            WinWait($Title, "To change your keyboard or inp", 10)
            ToolTip("")
            ControlCommand($Title, "", "ComboBox1", "SelectString", 'svenska')
            If @error Then ControlCommand($Title, "", "ComboBox1", "SelectString", 'Svenska')
            ;Click apply, then click ok on log out now, possible to log back in?
        Case $Language == "Swe" And $OS == "WIN_7"
            Global $Title = "Nationella inställningar och språkinställningar"
            ToolTip("Current language: Svensk", 5, 21)
            Run("control intl.cpl")
            If @error Then
                MsgBox(0, "Uhhhh..", "Houston, we have a problem")
                Exit
            EndIf
            WinWait($Title, "", 3)
            ControlClick($Title, "", "SysTabControl321", "Primary", 1, 155, 10)
            WinWait($Title, "Tangentbord och språk", 10)
            ToolTip("")
            ControlCommand($Title, "", "ComboBox1", "SelectString", 'English')
            If @error Then ControlCommand($Title, "", "ComboBox1", "SelectString", 'english')
            ;Click apply, then click ok on log out now, possible to log back in?
        Case Else
            MsgBox(0,"Need more cases!",$Language & " - "& $OS)
    EndSelect
EndFunc   ;==>_ChangeLanguage

;http://www.microsoft.com/middleeast/arabicdev/DevTools/more/RegionalSettings.aspx#4_1 = Silently set in XP
;http://technet.microsoft.com/en-us/library/cc721887(WS.10).aspx = Vista, probably Windows 7 also.
;Registy: HKEY_Local_Machine\System\CurrentControlSet\Control\MUI\UILanguages\
#cs XP Ini.
;Rundll32 shell32,Control_RunDLL intl.cpl,,/f:"c:\unattend.txt"
;[RegionalSettings] ;XP Ini
;LanguageGroup=13
;SystemLocale=0401
#ce
#cs Vista XML
    <gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
    <!-- User List -->
    <gs:UserList>
    <gs:User UserID="Current" CopySettingsToSystemAcct="true" />
    </gs:UserList>
    <!-- MUI-->
    <gs:MUILanguagePreferences>
    <gs:MUILanguage Value="sv-SE" />
    <gs:MUIFallback Value="en-US" />
    </gs:MUILanguagePreferences>
    </gs:GlobalizationServices>
#ce
Edited by BitByteBit
Posted

Thanks for the quick response Yashied. Nice script, but this isn't quite what I'm looking to do; unless I'm missing something and this can be done through your WinApiEx UDF?

Rather than changing the keyboard layout, I'm looking for a way to silently change the OS language if that makes any sense.

Should I just stick with automating the process of opening Regional and Language Settings?

  • 10 years later...
  • Jos locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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