Results 1 to 5 of 5
  1. #1
    ghatrify's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Posts
    83
    Reputation
    10
    Thanks
    656
    My Mood
    Confused

    Cyrillic letters.

    Hello, i have to have a char *variable that is able to hold both English and Cyrillic letters.

    This code works well.
    Code:
    char *s = "Example Title";
    if(FindWindow(NULL, LPCSTR(s))) cout<<"Found."<<endl;
    else cout<<"Not Found."<<endl;
    but when i test a Cyrillic word like the code below, it doesn't work.
    Code:
    char *s = "Клиент";

    I tried to use this, but it always prints "Found" even if there is no window called "Клиент".
    Code:
    char *s = "\0x41a\0x43b\0x438\0x435\0x43d\0x442" //"Клиент"
    sorry for bad English.

  2. #2
    eukaryote's Avatar
    Join Date
    Jun 2013
    Gender
    male
    Posts
    5
    Reputation
    10
    Thanks
    0
    My Mood
    Tired
    Try "FindWindowW".

  3. #3
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    msdn: https://msdn.microsof*****m/en-us/libr...=vs.85%29.aspx
    Code:
    HWND WINAPI FindWindow(
      _In_opt_  LPCTSTR lpClassName,
      _In_opt_  LPCTSTR lpWindowName
    );

    https://social.msdn.microsof*****m/For...rum=vclanguage
    Brian says:
    Code:
    LPSTR = char*
    LPCSTR = const char*
    LPWSTR = wchar_t*
    LPCWSTR = const wchar_t*
    LPTSTR = char* or wchar_t* depending on _UNICODE
    LPCTSTR = const char* or const wchar_t* depending on _UNICODE
    LPCTSTR = const char* or const wchar_t* depending on _UNICODE

    const char * vs. const wchar_t*

    I think by using LPCSTR, "if(FindWindow(NULL, LPCSTR(s)))", you forced a call to FindWindowA() instead of FindWindowW() (mentioned above)? maybe?

    Try calling FindWindowW() explicitly as mentioned above.


    "\0x41a\0x43b\0x438\0x435\0x43d\0x442" //"Клиент"

    0x41a = 1050 , 0000 0100 0001 1010
    0x43b = 1083 , 0000 0100 0011 1011
    0x438 = 1080 , 0000 0100 0011 1000
    0x435 = 1077 , 0000 0100 0011 0101
    0x43d = 1085 , 0000 0100 0011 1101
    0x442 = 1090 , 0000 0100 0100 0010

    if it was calling FindWindowA(), it would try to interperet it as ascii
    00000100 , 00011010 , 00000100 , 00111011 , 00000100 , 00111000 , 00000100 , 00110101 , 00000100, 00111101 , 00000100 , 01000010 .

    00000100 is 4, which isn't a displayable character in ascii. Maybe that's causing FindWindowA() to bug? Just a guess really.
    edit: googled ascii table and 4 is "EOT (end of transmission)". Probably not important, but made me lol. FindWindowA() could limit which characters are considered valid, but I'm not sure why it would return true :/

    edit: I tried


    and a few other things and couldn't get it to work. idk. disregard above text.
    Last edited by abuckau907; 02-07-2014 at 09:35 PM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  4. The Following User Says Thank You to abuckau907 For This Useful Post:

    ghatrify (02-09-2014)

  5. #4
    ghatrify's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Posts
    83
    Reputation
    10
    Thanks
    656
    My Mood
    Confused
    @abuckau907 Thanks for your reply, but it's not a solution ? or am i wrong ?

  6. #5
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    you are correct - I was just thinking out loud (and don't know C++/strings well enough).

    I tried again and got...


    Code:
    int main()
    {
    	char* _appTitle = "Клиент";
    
    	if (FindWindowW(NULL,L"Клиент"))
    	{
    		cout <<"aaa:window found" << endl;
    	}
    	else
    	{
    		cout <<"aaa: window not found" << endl;
    	}
    
    	if (FindWindowW(NULL,(LPCWSTR)_appTitle))
    	{
    		cout <<"zzz:window found" << endl;
    	}
    	else
    	{
    		cout <<"zzz:window not found" << endl;
    	}
    
    
    
    
    
    
    system("PAUSE");
    return 0;
    }


    Code:
    int main()
    {
    	LPWSTR _appTitle = L"Клиент";
    
    	if (FindWindowW(NULL,L"Клиент"))
    	{
    		cout <<"aaa:window found" << endl;
    	}
    	else
    	{
    		cout <<"aaa: window not found" << endl;
    	}
    
    	if (FindWindowW(NULL,_appTitle))
    	{
    		cout <<"zzz:window found" << endl;
    	}
    	else
    	{
    		cout <<"zzz:window not found" << endl;
    	}
    
    
    
    system("PAUSE");
    return 0;
    }
    Last edited by abuckau907; 02-09-2014 at 03:20 AM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

Similar Threads

  1. Korean Letters
    By renten2314 in forum WarRock Korea Hacks
    Replies: 0
    Last Post: 02-02-2008, 05:15 PM
  2. [Help] random letter
    By noobi4life in forum Visual Basic Programming
    Replies: 4
    Last Post: 11-01-2007, 10:02 AM
  3. how do u change hard drive letters
    By prox32 in forum General
    Replies: 9
    Last Post: 07-31-2007, 07:12 PM
  4. (TUT) Korean Letters
    By ll11ll in forum WarRock Korea Hacks
    Replies: 19
    Last Post: 06-27-2007, 10:25 PM
  5. Letter: Dave84311's Usertitle
    By Bull3t in forum Suggestions, Requests & General Help
    Replies: 12
    Last Post: 07-23-2006, 09:13 AM