| View previous topic :: View next topic |
| Author |
Message |
AGU Guest
|
Posted: Tue May 24, 2005 9:43 pm Post subject: If (A_GuiControlEvent) ... |
|
|
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
|
Posted: Tue May 24, 2005 10:29 pm Post subject: |
|
|
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  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Wed May 25, 2005 12:57 am Post subject: |
|
|
| You could make the second one work by enclosing "DoubleClick" in quotes. |
|
| Back to top |
|
 |
AGU Guest
|
Posted: Wed May 25, 2005 1:09 am Post subject: |
|
|
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
|
Posted: Wed May 25, 2005 1:30 am Post subject: Re: If (A_GuiControlEvent) ... |
|
|
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 |
|
 |
AGermanUser
Joined: 12 Feb 2005 Posts: 81
|
Posted: Wed May 25, 2005 1:39 am Post subject: |
|
|
Perfect.
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 |
 _________________ Cheers
BBCodeWriter • ToDo-List • CopyPassage |
|
| Back to top |
|
 |
JBensimon
Joined: 16 Nov 2004 Posts: 130 Location: New York
|
Posted: Wed May 25, 2005 2:01 am Post subject: |
|
|
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!
Jacques. |
|
| Back to top |
|
 |
niwi
Joined: 27 Feb 2005 Posts: 128 Location: Heidelberg, Germany
|
Posted: Wed May 25, 2005 10:01 am Post subject: |
|
|
Hi,
I spend a little bit from my IQ for AGU
| Code: | IQ_NiWi -= 10
IQ_AGermanUser += 10 |
NiWi. |
|
| Back to top |
|
 |
AGermanUser
Joined: 12 Feb 2005 Posts: 81
|
Posted: Wed May 25, 2005 5:06 pm Post subject: |
|
|
Far too kind.
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.  _________________ Cheers
BBCodeWriter • ToDo-List • CopyPassage |
|
| Back to top |
|
 |
Invalid User
Joined: 14 Feb 2005 Posts: 442 Location: Texas, Usa
|
Posted: Thu May 26, 2005 9:16 pm Post subject: |
|
|
| 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!!  _________________ my lame sig  |
|
| Back to top |
|
 |
|