Multiple Scripts

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
arpit12
Posts: 56
Joined: 10 Apr 2022, 04:19

Multiple Scripts

Post by arpit12 » 24 May 2022, 12:06

Hi
I have Multiple script that i have added to GUI. Is it possible to convert it to single EXE or is there any other way than to that.

User avatar
mikeyww
Posts: 26854
Joined: 09 Sep 2014, 18:38

Re: Multiple Scrpits

Post by mikeyww » 24 May 2022, 20:16

AutoHotkey comes with a compiler. It will convert the whole script file to an EXE program file that you can run directly. Have fun!

Rohwedder
Posts: 7616
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Multiple Scripts

Post by Rohwedder » 25 May 2022, 03:00

Hallo,
no, multiple scripts cannot be compiled into one exe!
With Timers instead of the Loops full of Sleeps so popular with beginners, it is usually possible to produce a working single script.

arpit12
Posts: 56
Joined: 10 Apr 2022, 04:19

Re: Multiple Scripts

Post by arpit12 » 25 May 2022, 03:30

Hi @Rohwedder,
Rohwedder wrote: Hallo,
no, multiple scripts cannot be compiled into one exe!
With Timers instead of the Loops full of Sleeps so popular with beginners, it is usually possible to produce a working single script.
What do you mean by timers instead of the loops full of sleeps?

Rohwedder
Posts: 7616
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Multiple Scripts

Post by Rohwedder » 25 May 2022, 07:06

These are two loops which cannot run simultaneously because only one thread can be active per script:

Code: Select all

*q::
While, GetKeyState("q","P")
{
	SendInput, H
	Sleep, 500
	SendInput, e
	Sleep, 200
	SendInput, l
	Sleep, 500
	SendInput, l
	Sleep, 300
	SendInput, o
	Sleep, 100
	SendInput, {Enter}
	Sleep, 300
}
Return
*w::
While, GetKeyState("w","P")
{
	SendInput, W
	Sleep, 500
	SendInput, o
	Sleep, 200
	SendInput, r
	Sleep, 500
	SendInput, l
	Sleep, 300
	SendInput, d
	Sleep, 100
	SendInput, {Enter}
	Sleep, 100
}
Return
If you need them simultaneously you use two scripts or these two timers which do the same as above loops also simultaneously:

Code: Select all

*q::
IF QCount
    Return
QKeys := ["H","e","l","l","o","Enter"]
QSleeps := [500,200,500,300,100,300], QCount := 0
QSendKeys:
Send,% "{" QKeys[QCount:=Mod(QCount,QKeys.Count())+1] "}"
SetTimer, QSendKeys,% GetKeyState("q","P")?QSleeps[QCount]:"Off"
Return
*w::
IF WCount
    Return
WKeys := ["W","o","r","l","d","Enter"]
WSleeps := [500,200,500,300,100,100], WCount := 0
WSendKeys:
SendInput,% "{" WKeys[WCount:=Mod(WCount,WKeys.Count())+1] "}"
SetTimer, WSendKeys,% GetKeyState("w","P")?WSleeps[WCount]:"Off"
Return

Post Reply

Return to “Ask for Help (v1)”