 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Mauser Guest
|
Posted: Fri May 16, 2008 9:01 pm Post subject: Problem with blocks {} |
|
|
I am very new for AHK and I have problem with {} blocks.
This is code is not compiled:
activate:
cont=0
loop %repeat_number% {
if cont=0 {
mouseclickdrag, left, %from_x%, %from_y%, %to_x%, %to_y%, %mouse_speed%
cont=1
}
sleep, %ms_between%
}
return
This code is compiled correctly:
activate:
cont=0
loop %repeat_number% {
mouseclickdrag, left, %from_x%, %from_y%, %to_x%, %to_y%, %mouse_speed%
sleep, %ms_between%
}
return
Could you please tell how to add "if" block in to the loop? |
|
| Back to top |
|
 |
TheIrishThug
Joined: 19 Mar 2006 Posts: 370
|
Posted: Fri May 16, 2008 9:21 pm Post subject: |
|
|
If you are going to do if statements without parenthesis, which i don't recommend, you can't put the open bracket on the same line.
| Code: | ;works
if (count = 1) {
...
}
;works
if count = 1
{
...
}
;DOESN'T WORK
; this would be equivalent to if (count = "1 {")
if count = 1 {
...
} |
|
|
| Back to top |
|
 |
crxvfr
Joined: 10 Mar 2006 Posts: 54
|
Posted: Fri May 16, 2008 9:25 pm Post subject: Re: Problem with blocks {} |
|
|
1. Registered users get better answers
2. Use the code tags when posting code. It keeps indents intact.
3. If you aren't already, use indents to keep better track of opening and closing braces
4. See below.
| Code: |
activate:
cont=0
loop %repeat_number%
{
if cont=0
{
mouseclickdrag, left, %from_x%, %from_y%, %to_x%, %to_y%, %mouse_speed%
cont=1
}
sleep, %ms_between%
}
return
|
This code is compiled correctly:
| Code: |
activate:
cont=0
loop %repeat_number%
{
mouseclickdrag, left, %from_x%, %from_y%, %to_x%, %to_y%, %mouse_speed%
sleep, %ms_between%
}
return
|
It may be easier to see whats inside what. |
|
| Back to top |
|
 |
Mauser Guest
|
Posted: Fri May 16, 2008 9:58 pm Post subject: |
|
|
| TheIrishThug, crxvfr, got it, thank you |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|