All three of these lines are wrong:
Code: Select all
ControlGetText, Text, %SysTabControl321%, A ; ClassNN here
If (Text = Shortcut)
MsgBox ClassNN: %SysTabControl321%
Should be:
Code: Select all
ControlGetText, Text, SysTabControl321, A ; ClassNN here
If (Text = "Shortcut")
MsgBox The selected tab for ClassNN:SysTabControl321 is 'Shortcut' ; this is what it seems you are trying to report
SysTabControl321 is not a variable, so you wouldn’t put
% symbols around it. It is a literal string, so in legacy syntax, you put nothing around it. This is true for both the first and third line,
In the second line, it is an expression, so you need to put quotation marks around the literal string
Shortcut.
There is never a case where you put
% symbols around literal strings in either legacy syntax or expressions.
What you are telling the
ControlGetText command is that you want to get the text from the control named
SysTabControl321. You are not getting the name of the control and putting it in a variable named
SysTabControl321.
SysTabControl321 is the name of the control.
You wouldn’t break the loop based on the value of ErrorLevel. That doesn’t make sense here. You are checking the condition you want, so you would break based on the result of that
if statement. Just replace the
MsgBox line with the
break command.
By the way, I have done no testing to see if
ControlGetText returns the name of the selected tab (and only the name of the selected tab) for this control as your code is expecting.