AutoHotkey Community

It is currently May 26th, 2012, 11:01 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: expressions
PostPosted: November 1st, 2009, 7:34 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 1st, 2009, 7:44 am 
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 %


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 1st, 2009, 7:51 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
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%
}

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 1st, 2009, 8:06 am 
icic, thanks for the quick tip


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 1st, 2009, 8:11 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 1st, 2009, 8:23 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 1st, 2009, 8:37 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 1st, 2009, 9:01 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
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 := ""


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], hyper_, JSLover, Kirtman, Leef_me, Miguel, XstatyK, Yahoo [Bot] and 61 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group