Execute a block of code multiple times in a single line? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
naseem87
Posts: 7
Joined: 20 Mar 2017, 11:51

Execute a block of code multiple times in a single line?

20 Mar 2017, 12:02

Hi,

I'm sorry but i'm not sure what to call this in a specific word but i'll try to explain it as much as i simply can.

So i have these lines of code for example:

{
Send {a}
Send {b}
Send {c}
}

And i want to be able to use it any time i want inside a single .ahk file without having to type it out again, i hope you understand what i meant.. I swear i used to know the word but i'm not even sure anymore. Thank you!

EDIT: like a function in jquery
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Execute a block of code multiple times in a single line?  Topic is solved

20 Mar 2017, 12:08

Code: Select all

MyFunc() {
Send {a}
Send {b}
Send {c}
} ; 

run % A_WinDir . "/notepad.exe"
WinActivate, ahk_class Notepad
MyFunc()
sleep, 1000
MyFunc()
sleep, 1000
MyFunc()
see https://autohotkey.com/docs/Functions.htm
my scripts
naseem87
Posts: 7
Joined: 20 Mar 2017, 11:51

Re: Execute a block of code multiple times in a single line?

20 Mar 2017, 12:17

A_AhkUser wrote:

Code: Select all

MyFunc() {
Send {a}
Send {b}
Send {c}
} ; 

run % A_WinDir . "/notepad.exe"
WinActivate, ahk_class Notepad
MyFunc()
sleep, 1000
MyFunc()
sleep, 1000
MyFunc()
see https://autohotkey.com/docs/Functions.htm
Thanks, i tried that before but i must have mistyped something. Your example helped me!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mebelantikjaya and 332 guests