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 

Probably so easy you'll laugh.

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



Joined: 14 Nov 2007
Posts: 20
Location: London, England

PostPosted: Thu Jan 10, 2008 5:43 pm    Post subject: Probably so easy you'll laugh. Reply with quote

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
Back to top
View user's profile Send private message
POINTS



Joined: 18 Jan 2006
Posts: 284

PostPosted: Thu Jan 10, 2008 6:05 pm    Post subject: Functions Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Conquer



Joined: 27 Jun 2006
Posts: 383
Location: Canada

PostPosted: Fri Jan 11, 2008 3:25 am    Post subject: Reply with quote

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

_________________
Back to top
View user's profile Send private message
doyle



Joined: 14 Nov 2007
Posts: 20
Location: London, England

PostPosted: Fri Jan 11, 2008 3:02 pm    Post subject: Reply with quote

Thanks very much Conquer!

Thats really helped streamline my code. Razz
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