开发者

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 b开发者_如何学Goeyond 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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜