简体   繁体   中英

Forcing .NET/C# UI Automation to use a specific culture (Turkish)

I have a UI Automation application that is written in C# and uses .NET(currently 3.5 but if 4 solves the issue I will gladly change). I am running in an English version of Windows 7. I want be able to run this application on any given UI, and have it behave as follows, regardless of how the given UI is setup or what the current system language is, as those things are generally beyond my control:

I want to force an application using UI Automation to use the Turkish rules for capitalization. Particularly, if the automation application was being run on a UI that contained the character 'i', I want the portions of UI automation that automatically convert a string/character to uppercase to convert that character to 'İ' not 'I'.

This is particularly an issue with access and accelerator keys. For example, if a button in a UI had 'i' as it's access key, then the AutomationElement in the UI automation application for that button would list its access key as 'I', which is incorrect in Turkish.

I have tried setting the Thread culture and Thread ui culture to Turkish but that does not work. I am unsure how else to go about forcing the AutomationElement class to do this. Any suggestions/help/examples would be greatly appreciated.

If this was unclear please let me know and I will try to explain it better.

If you want to just uppercase strings correctly, it is as easy as that:

string turkish = "iptal";
CultureInfo turkishCulture = new CultureInfo("tr-TR");
string upperCased = turkish.ToUpper(turkishCulture);

Unfortunately, you would have to do this for each string. Unfortunately, I don't quite know what is your use case, so my answer might be not very useful...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM