AutoHotkey Community

It is currently May 26th, 2012, 2:35 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: January 10th, 2008, 5:43 pm 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
Hey guys,

I have this code that appears loads of times in my script, and rather than have it clog up the page, id like to have it once, and then reference it multiple times.

Code:
WinWait, Information,
WinActivate, Information,
Sleep, 200
Send, {ENTER}

WinWait, Information,
WinActivate, Information,
Sleep, 200
Send, {ENTER}

WinActivate, Create Document: Basic Data
SendInput, {ENTER 5}
return


So i'd like that at the start, or end, and to be able to insert a shortened name in the code.

GoSub?

Or is there a way to store it like a a variable?

Cheers guys


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Functions
PostPosted: January 10th, 2008, 6:05 pm 
Offline

Joined: January 18th, 2006, 12:37 am
Posts: 290
I think a function is what you're looking for.

http://www.autohotkey.com/docs/Functions.htm

_________________
My AutoHotkey Program for Warcraft III:
Warkeys
http://warkeys.sourceforge.net/

Remap your hotkeys
Healthbars always on
Remap inventory


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2008, 3:25 am 
Offline

Joined: June 27th, 2006, 2:38 pm
Posts: 385
Location: Canada
Why function? Labels are easier for beginners.


Code:
gosub TheLabel    ; use this line of code whenever you want the label triggered.
; ...
; ...
return

TheLabel:      ; Feel free to change ;)
WinWait, Information,
WinActivate, Information,
Sleep, 200
Send, {ENTER}

WinWait, Information,
WinActivate, Information,
Sleep, 200
Send, {ENTER}

WinActivate, Create Document: Basic Data
SendInput, {ENTER 5}
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2008, 3:02 pm 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
Thanks very much Conquer!

Thats really helped streamline my code. :P


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, Exabot [Bot] and 16 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