Matching a window Title doesn't work, if it is in Russian Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
swcoll
Posts: 2
Joined: 27 Jul 2021, 15:55

Matching a window Title doesn't work, if it is in Russian

27 Jul 2021, 16:35

Hello! I'm trying to remap Numpad . to be dot . everywhere but Excel and Калькулятор, which is what default Windows calculator titled in Russian version. In this two it must print a comma. I've stumbled upon a problem matching a window title by any phrase in Russian characters. They just don't match, but titles in English do. Here is the code:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

NumpadDot::
WinGetActiveTitle, Title
FileAppend , %Title% `n, lol.txt
if Title not contains Calc, Калькулятор, Excel
	Send, .
Else
{
	MsgBox, The active window is "%Title%".
	Send, ,
}
return
So it works in Excel, any other window containing Excel or Calc, but not in Калькулятор-containg titles.
I tried saving script in UTF8, UTF8-bom, ANSI, but nothing works. I ran the script with the standard autohotkey unicode 64 exe, the ansi 32 one.

I alse tried to write active window titles to a file to see how they are coded:

Code: Select all

NumpadDot::
WinGetActiveTitle, Title
FileAppend , %Title% `n, lol.txt ; <---------
if Title not contains Calc, Калькулятор, Excel
	Send, .
Else
{
	Send, ,
}
return
Russian turned out to be coded with Windows-1251, but saving the script in it didn't help either.

Hope you can help me with this ridiculous puzzle :D Thank you!
User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: Matching a window Title doesn't work, if it is in Russian  Topic is solved

27 Jul 2021, 17:18

Although I did not test it, I believe that your "__,__,__" string in "If.. contains" must not contain spaces unless the spaces are part of the string that you are checking.
Any spaces or tabs around the delimiting commas are significant.
swcoll
Posts: 2
Joined: 27 Jul 2021, 15:55

Re: Matching a window Title doesn't work, if it is in Russian

28 Jul 2021, 04:31

@mikeyww\n
Thanks a lot! This was the case. And the unlucky fact that Cals was in the beginning and Excel window always has a space in the title made me absolutely confident the problem was in encoding :D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 245 guests