Sign in to follow this  
Followers 0
MvGulik

[solved] Detecting current used language setting for a app ?

4 posts in this topic

#1 ·  Posted (edited)

Have not looked at it yet (trying to tame some Pythons). But is it possible to detect what (windows-) language setting a app is using. (if you have windows setup to have more then one language settings.)

Having a minor issue with Scite(4AutoIt3) switching its language on its own (and than also being locked to that language setting.)

Figure having something popup when it happens is in need if I like to figure out what the trigger(s) might be.

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

I'll try that one, and @KBLayout.

Mmm, don't think @OSLang will work. as its probably returns the global window language, not the used language-setting ... but I try anyway.

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

_WinAPI_GetKeyboardLayout($hWnd) [WinAPIEx UDF] should/will do the trick.

---

Yep/solved.

Update(+code|1.3): Not a Scite issue ... But a general windows issue/feature. :)

;; (v1.3)
#include <WinAPIEx.au3>

main()
Exit

Func main()
    ;; mmm ... issue ... not sure if target case will actual return a detectable language change.
    ;; - behavior might change without actual returning a detectable state change. ... [todo]
    If MsgBox(1, 'MsgBox', 'Detect Language Change: Start?') = 1 Then

        Local Const $NL = @LF
        Local Const $iApps = 2
        Local Const $aCLASS[$iApps] = ['[CLASS:SciTEWindow]', '[CLASS:Chrome_WidgetWin_0]']

        Local $ahWnd[$iApps] = [0, 0], $aKeyboard[$iApps] = [0, 0], $aKeyboard_old = $aKeyboard
        Local $sClass, $hWnd, $Keyboard, $Keyboard_old, $fUpdate
        Local $sTooltip = ''
        Local $fQuit = False

        Do
            $sTooltip = ''
            For $id = 0 To $iApps - 1

                ;; retrieve array data. (minimize general array use in main code part.)
                $hWnd = $ahWnd[$id]
                $Keyboard = $aKeyboard[$id]
                $Keyboard_old = $aKeyboard_old[$id]

                $sClass = $aCLASS[$id]
                $fUpdate = False

                ;; detect new target window. (not really intended/tested for multi-win-cases ... ok so far.)
                If Not $hWnd And WinExists($sClass) Then
                    $hWnd = WinGetHandle($sClass)

                    ;; error check.
                    If Not $hWnd Then
                        If MsgBox(1, 'MsgBox', '$hWnd = WinGetHandle(' & $sClass & ') failed.') <> 1 Then
                            $fQuit = True
                            ExitLoop 2
                        EndIf
                    EndIf

                    $sTooltip &= 'New: ' & $sClass & $NL
                    $fUpdate = True

                ElseIf $hWnd  And Not WinExists($hWnd) Then ;; detect removal of target window.
                    $hWnd = 0
                    $sTooltip &= 'Gone:  ' & $sClass & $NL
                    $fUpdate = True
                EndIf

                ;; detect language state change on target window.
                If $hWnd Then
                    $Keyboard = _WinAPI_GetKeyboardLayout($hWnd)

                    If _
                            $Keyboard And $Keyboard_old And _
                            $Keyboard <> $Keyboard_old Then
                        If 1 Then
                            $sTooltip &= 'Change: ' & $sClass & $NL
                        Else
                            If MsgBox(1, 'MsgBox', 'Language Change on ' & $sClass & ' !') <> 1 Then
                                $fQuit = True
                                ExitLoop 2
                            EndIf
                        EndIf
                        $Keyboard_old = $Keyboard
                        $fUpdate = True

                    ElseIf $Keyboard <> $Keyboard_old Then
                        $Keyboard_old = $Keyboard
                        $fUpdate = True

                    EndIf
                EndIf

                ;; update arrays
                If $fUpdate Then
                    $ahWnd[$id] = $hWnd
                    $aKeyboard[$id] = $Keyboard
                    $aKeyboard_old[$id] = $Keyboard_old
                    ;$fUpdate = False
                EndIf

            Next

            If $sTooltip Then
                TrayTip('Detect Language Change', $sTooltip, 3)
                ;$sTooltip = ''
            EndIf

            Sleep(1000)
        Until $fQuit
        MsgBox(0, 'MsgBox', 'Detect Language Change: Exit')
    EndIf
EndFunc

---

mmm, CTRL+SHIFT <> Using Language Bar. Not sure why, or what I'm missing, Don't really care either (for later). Know now why and how to (normally) undo it again. [solved]x2

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

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