Variables

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fedek
Posts: 60
Joined: 17 May 2016, 12:17
Contact:

Variables

30 Dec 2016, 12:58

gg:=Добро
if !(gg contains Вход or Добро)
MsgBox +
ExitApp

Why + ?
garry
Posts: 3774
Joined: 22 Dec 2013, 12:50

Re: Variables

30 Dec 2016, 13:14

msgbox + if contains

Code: Select all

gg=Добро
if gg contains Вход,Добро
MsgBox +
ExitApp
or not contains

Code: Select all

gg=Добро
if gg not contains Вход,Добро
MsgBox +
ExitApp
fedek
Posts: 60
Joined: 17 May 2016, 12:17
Contact:

Re: Variables

30 Dec 2016, 13:19

Thanks. There is another question:
gg:=ттт
if gg != ууу1,contains еее
MsgBox 1
ExitApp

Why 1 ?
garry
Posts: 3774
Joined: 22 Dec 2013, 12:50

Re: Variables

30 Dec 2016, 14:06

see also some examples with AND / OR etc
and also INSTR , Regex...

Code: Select all

g1:="TTT"
g2:="AAA"
if (g1 ="TTT" and g2 = "AAA" )
  MsgBox,(g1 ="TTT" and g2 = "AAA" )

if (g1 ="TTT" or g2 != "AAC" )
  MsgBox,(g1 ="TTT" or g2 != "AAC" )

if (g1 ="TTT" and g2 = "AAC" )
  MsgBox,CASE-1
else
  MsgBox,CASE-2
ExitApp



/*
;- if GG containsx Instrxx
If InStr( GG, "by:" ) || InStr( GG, "CCCC" ) || InStr( GG, "Summar" ) || InStr( GG, " " )
    Continue

;-or also

If GG Contains by:,CCCC, ,Summar
    Continue
;-or

If ( RegExMatch(GG, "i)" . "by:|CCCC| |Summar") )      ;- "i)" means "Case-Insensitive"
    Continue

;-or


If ( GG ~= "(?i:" . "by:|CCCC| |Summar" . ")" )         ;- "?i:" means "Case-Insensitive"
    Continue
*/
lexikos
Posts: 9621
Joined: 30 Sep 2013, 04:07
Contact:

Re: Variables

01 Jan 2017, 18:02

fedek,

You must use the syntax shown and explained in the manual:
if Var contains MatchList
if Var not contains MatchList
You have written:

Code: Select all

if !(gg contains Вход or Добро)

Code: Select all

if gg != ууу1,contains еее
It seems that you've just made up your own syntax. That won't work.

The first is if (expression).
An if-statement that contains an expression is differentiated from a traditional-if such as If FoundColor <> Blue by making the character after the word "if" an open-parenthesis. [...] the open-parenthesis may be omitted entirely if the first item after the word "if" is a function call or an operator such as "not" or "!".
Source: if (expression)
The second is IfNotEqual.
IfNotEqual, var, value (same: if var <> value) (!= can be used in place of <>)
Source: If/IfEqual/IfNotEqual/IfLess/IfLessOrEqual/IfGreater/IfGreaterOrEqual
Your variable gg does not contain the literal value "yyy1,contains eee", so the MsgBox is shown.
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: Variables

01 Jan 2017, 20:06

also you are assigning the variable incorrectly

Code: Select all

gg:=Добро    ; wrong

; either :
gg := "Добро"
; or
gg = Добро
read the variables help page


Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 346 guests