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 

expressions

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





PostPosted: Sun Nov 01, 2009 6:34 am    Post subject: expressions Reply with quote

Code:

x+=10
y+=20
click, %x%, %y%
 


how can i combine those 3 lines to 1? or can i?

something like:
Code:

click, %x%+10, %y%+20
Back to top
el
Guest





PostPosted: Sun Nov 01, 2009 6:44 am    Post subject: Reply with quote

i think i got it, it seems working correctly with this syntax
Code:
click, % (x+10)","(y+20)

ehmm..interesting, tried many different ways, seems like click is only using one variable input %
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 7159

PostPosted: Sun Nov 01, 2009 6:51 am    Post subject: Reply with quote

You could also user define Commands into Functions.

Code:
X:=0, Y:=0, Click( X:=X+10, Y:=Y+10), Click( X:=X+10, Y:=Y+10), Click( X:=X+10, Y:=Y+10)

Click( X, Y ) {
Click, %X%, %Y%
}

_________________
Suresh Kumar A N
Back to top
View user's profile Send private message
el
Guest





PostPosted: Sun Nov 01, 2009 7:06 am    Post subject: Reply with quote

icic, thanks for the quick tip
Back to top
el
Guest





PostPosted: Sun Nov 01, 2009 7:11 am    Post subject: Reply with quote

one more question
can u please explain a little bit how ahk works differently on these 2 scripts:
Code:
s:=a_tickcount
loop 100000
{
x:=0,y:=0,z:=0
}
e := A_tickcount - s
msgbox, % e
 
Code:

s:=a_tickcount
loop 100000
{
x:=0
y:=0
z:=0
}
e := A_tickcount - s
msgbox, % e

surprisingly, the first script is 30-40% slower
Back to top
sinkfaze



Joined: 18 Mar 2008
Posts: 2427

PostPosted: Sun Nov 01, 2009 7:23 am    Post subject: Reply with quote

The maximum I'm hitting is about 20% difference in speed.

I'm sure to be trumped by those more knowledgeable, but my guess is that with the former, the single line command has to be parsed by AHK before assigning the values to the variables, whereas in the latter there are no steps in between variable assignments.
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message
Guest






PostPosted: Sun Nov 01, 2009 7:37 am    Post subject: Reply with quote

ehm make sense
i dont really care about the performance difference for that 0.001ms
but its good to know, what performance better
well i guess its depends on user's choice, it is tidy+short vs. performance
thank you
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 7159

PostPosted: Sun Nov 01, 2009 8:01 am    Post subject: Reply with quote

el wrote:
can u please explain a little bit how ahk works differently on these 2 scripts


It is tricky - there are instances where comma seperated values can outperform single line declarations owing to many micro-optimizations applied into the code by the developer. I am not aware of all, but I have seen that
X := 1 is faster than X := 0 which is faster that X := ""
Back to top
View user's profile Send private message
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