AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

If (A_GuiControlEvent) ...

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
AGU
Guest





PostPosted: Tue May 24, 2005 9:43 pm    Post subject: If (A_GuiControlEvent) ... Reply with quote

What's the difference between
Code:
If A_GuiControlEvent = DoubleClick
{
...
}
and
Code:
If (A_GuiControlEvent = DoubleClick)
{
...
}
?

The one without parantheses works correctly but the one with parantheses doesn't work. A_GuiControlEvent everytime holds just normal.
Back to top
Invalid User



Joined: 14 Feb 2005
Posts: 442
Location: Texas, Usa

PostPosted: Tue May 24, 2005 10:29 pm    Post subject: Reply with quote

As far as i know the ( ... ) are used for expressions in if commands. But your not solving an expression with your use. So go with out. example for its use

Code:

If (A_Index + 2) = %X%
{
...
}

_________________
my lame sig Smile
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Wed May 25, 2005 12:57 am    Post subject: Reply with quote

You could make the second one work by enclosing "DoubleClick" in quotes.
Back to top
View user's profile Send private message Send e-mail
AGU
Guest





PostPosted: Wed May 25, 2005 1:09 am    Post subject: Reply with quote

Thanks.

I got used to use parantheses with if-statements whether there follows an expression or not. So I don't have to pay attention whether it's one or not.
Back to top
JBensimon



Joined: 16 Nov 2004
Posts: 130
Location: New York

PostPosted: Wed May 25, 2005 1:30 am    Post subject: Re: If (A_GuiControlEvent) ... Reply with quote

It took me a while to figure this out when I started looking at AutoHotkey, so let's see if I can help:
AGU wrote:
What's the difference between
Code:
If A_GuiControlEvent = DoubleClick
{
...
}

This is an example of what the documentation refers to as a "non-expression If" and is equivalent to
Code:
IfEqual, A_GuiControlEvent, DoubleClick

As the documentatoin of IfEqual states, the first parameter is expected to be a variable name (so no %'s are required), and the second parameter is expected to be a value, so DoubleCick is taken literally, not as the name of a variable. (If it were a variable name and you wanted to compare its contents, you'd have to place it between %'s).
AGU wrote:
... and
Code:
If (A_GuiControlEvent = DoubleClick)
{
...
}

Here, the parentheses turn this into an "expression If", and in expressions, non-numeric tokens (like A_GuiControlEvent and DoubleClick) are taken as the contents of variables with those names (no %'s required), which since DoubleClick is not a variable, causes the comparison to fail. Using "DoubleClick" (with the quotes) is how literal strings are used in expressions, and the comparison works again (as Chris stated in his reply).

Jacques.
Back to top
View user's profile Send private message Visit poster's website
AGermanUser



Joined: 12 Feb 2005
Posts: 81

PostPosted: Wed May 25, 2005 1:39 am    Post subject: Reply with quote

Perfect. Smile

Thanks for your explaining words. Now I understand that non-expression if and all about it. So I'm a little bit wiser now.
Code:
IQ_AGermanUser += 1

Laughing Laughing Laughing Laughing
_________________
Cheers
BBCodeWriterToDo-ListCopyPassage
Back to top
View user's profile Send private message
JBensimon



Joined: 16 Nov 2004
Posts: 130
Location: New York

PostPosted: Wed May 25, 2005 2:01 am    Post subject: Reply with quote

You're welcome, .. and you're being modest: understanding the difference between "traditional" AHK and "expression" AHK is worth at least +=10 on the IQ scale! Smile

Jacques.
Back to top
View user's profile Send private message Visit poster's website
niwi



Joined: 27 Feb 2005
Posts: 128
Location: Heidelberg, Germany

PostPosted: Wed May 25, 2005 10:01 am    Post subject: Reply with quote

Hi,

I spend a little bit from my IQ for AGU Laughing
Code:
IQ_NiWi -= 10
IQ_AGermanUser += 10


NiWi.
Back to top
View user's profile Send private message
AGermanUser



Joined: 12 Feb 2005
Posts: 81

PostPosted: Wed May 25, 2005 5:06 pm    Post subject: Reply with quote

Far too kind. Smile

I hope the 10 points you spent weren't exactly these 10 points that let you understand the difference between "traditional" AHK and "expression" AHK. In this case just read JBensimon explaining lines above and hope for someone else to spend you 10 of his/her own IQ points. Cause I'll keep mine now. Laughing Laughing
_________________
Cheers
BBCodeWriterToDo-ListCopyPassage
Back to top
View user's profile Send private message
Invalid User



Joined: 14 Feb 2005
Posts: 442
Location: Texas, Usa

PostPosted: Thu May 26, 2005 9:16 pm    Post subject: Reply with quote

Code:

Loop, Parse, AhkUserList, `n
{
    IQ_%A_LoopField% -= 10
    IQ_InvalidUser += 10
}
MsgBox, Invalud user has %IQ_InvalidUser% point, and thus wins the game


yippy I win, I win!! Very Happy Very Happy Exclamation
_________________
my lame sig Smile
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group