Multiple scripts on 1 ahk

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Multiple scripts on 1 ahk

09 Sep 2016, 14:20

Hi, i can't get to work multiple ahk scripts on 1 exe.
I don't know if i said it correctly, i will explain it:

Code: Select all

#maxhotkeysperinterval 999999999
setkeydelay, 2
SetDefaultMouseSpeed, 0
$space::
loop
{
if not GetKeyState("space", "P")
break
Send {b}
}
Return

$r::
loop
{
if not GetKeyState("r", "P")
break
send, {shift}
mouseclick, left, 726, 146, 1, 0
mouseclick, left, 619, 322, 1, 0
mouseclick, left, 607, 344, 1, 0
mousemove, 283, 304, 0
sleep, 250
Click
}
Return

$*mbutton::
Loop
{
if not GetKeyState("mbutton", "P")
break
click
}
Return

$q::
loop
{
if not GetKeyState("q", "P")
break
send, {Ctrl}
MouseGetPos x, y
send, {Ctrl}
MouseClick, left, 607, 344, 1, 0
send, {Ctrl}
mousemove, %x%, %y%, 0
send, {Ctrl}
sleep, 250
click
send, {Ctrl}
}
Return

~home::suspend
The problem is that when i'm holding any key of this script (Q, Space, MButton or R) i can't use any of the other scripts.
If i'm holding Q down, and i press R, R script won't work. Same for all the other hotkeys on this script.

Hope you can help me with this.
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Multiple scripts on 1 ahk

10 Sep 2016, 10:17

Works fine for me, when I hold down Space and hit r it works, try this simple script:

Code: Select all

$space::
While  GetKeyState("space", "P")
	ToolTip % A_Now
Return

$r::
While GetKeyState("r", "P")
	MsgBox, 0, Title, Text, 0.1
Return
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Multiple scripts on 1 ahk

10 Sep 2016, 12:58

@edit: the code you pasted doesn't work, when i hold down space and R at the same time only 1 works.
I want both to work at the same time if i hold down those 2 buttons.
Yes it works if you hold down space and press R 1 time, but when you press R it will stop Space script. That's the problem, i want to make both work.
If i have them on separated compiled ahk scripts it works fine, but when i merge them on 1 it doesn't. I can't have 10 scripts opened all the time, i want only 1.

Did you try it with the same code i pasted there?
Tried to record it but can't because fraps never start recording when i hit the key and hypercam records it on slow motion.

Ahm, you can try it, open a txt hold down R and then hold down space while you have R. Mouse movement will stop and it will start to spamm B.
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Multiple scripts on 1 ahk

10 Sep 2016, 18:16

Yes the other Hotkey will be suspended because AutoHotkey is not multi-threaded, see Threads.

You would need AutoHotkey.dll or AutoHotkey_H v2 to get what you want:
Example for AutoHotkey.dll:

Code: Select all

#Persistent
thread1:=AhkThread("
(
$space::
While  GetKeyState(""space"", ""P"")
	ToolTip `% A_Now
Return
)")
thread2:=AhkThread("
(
$r::
While GetKeyState(""r"", ""P"")
	MsgBox, 0, Title, Text, 0.1
Return
)")
Example for AutoHotkey_H v2 without using AutoHotkey.dll:

Code: Select all

#Persistent
thread1:=exeThread("
(
$space::
While  GetKeyState("space", "P")
	ToolTip `% A_Now
Return
)")
thread2:=exeThread("
(
$r::
While GetKeyState("r", "P")
	MsgBox, 0, Title, Text, 0.1
Return
)")
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Multiple scripts on 1 ahk

11 Sep 2016, 02:49

kyuuuri wrote: The problem is that when i'm holding any key of this script (Q, Space, MButton or R) i can't use any of the other scripts.
If i'm holding Q down, and i press R, R script won't work. Same for all the other hotkeys on this script.

Hope you can help me with this.
Try this:

Code: Select all

#maxhotkeysperinterval 999999999
setkeydelay, 2
SetDefaultMouseSpeed, 0
CoordMode,ToolTip,Screen

global Keys:=["Space","r","MButton","q"]
dollar:=["$","$","","$"]
Loop,4
	Hotkey,% dollar[A_Index] Keys[A_index],common_routine,On

return

~home::suspend

AnyKey()
{
	Loop,4
		if GetKeyState(Keys[A_Index], "P")
			return 1
	return 0
}

common_routine:
	While AnyKey()
	{
		Loop,4
			if GetKeyState(Keys[A_Index], "P")
				SetTimer,% Keys[A_Index] "_routine",-1
	}
return

Space_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,25,1
return

r_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,50,2
return

MButton_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,75,3
return

q_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,100,4
return
Edit: Since you have sleeps in your hotkeys, this is not good. Try this instead, remove the sleeps in your hotkey routines and setup the Cooldown array instead. And of course, consider using Hotkeys suggestion, I'm sure it works fine.

Code: Select all

setkeydelay, 2
SetDefaultMouseSpeed, 0
CoordMode,ToolTip,Screen
global Keys:=["Space","r","MButton","q"]
global Cooldown:=[250,0,0,250]				; Instead of sleeps, Space_routine has cooldown of 250, r_routine cooldown 0,...
global timerStart:=[]

dollar:=["$","$","","$"]
Loop,4
{
	Hotkey,% dollar[A_Index] Keys[A_index],common_routine,On
	timerStart[A_Index]:=A_TickCount
}
Sleep,250
return

~home::suspend

AnyKey()
{
	Loop,4
		if GetKeyState(Keys[A_Index], "P")
			return 1
	return 0
}

common_routine:
	While AnyKey()
		Loop,4
			if GetKeyState(Keys[A_Index], "P") && A_TickCount-timerStart[A_Index]>=Cooldown[A_Index] && timerStart[A_Index]:=A_TickCount
				SetTimer,% Keys[A_Index] "_routine",-1
return

Space_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,25,1
return

r_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,50,2
return

MButton_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,75,3
return

q_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,100,4
return
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Multiple scripts on 1 ahk

11 Sep 2016, 13:14

Helgef wrote:
kyuuuri wrote: The problem is that when i'm holding any key of this script (Q, Space, MButton or R) i can't use any of the other scripts.
If i'm holding Q down, and i press R, R script won't work. Same for all the other hotkeys on this script.

Hope you can help me with this.
Try this:

Code: Select all

#maxhotkeysperinterval 999999999
setkeydelay, 2
SetDefaultMouseSpeed, 0
CoordMode,ToolTip,Screen

global Keys:=["Space","r","MButton","q"]
dollar:=["$","$","","$"]
Loop,4
	Hotkey,% dollar[A_Index] Keys[A_index],common_routine,On

return

~home::suspend

AnyKey()
{
	Loop,4
		if GetKeyState(Keys[A_Index], "P")
			return 1
	return 0
}

common_routine:
	While AnyKey()
	{
		Loop,4
			if GetKeyState(Keys[A_Index], "P")
				SetTimer,% Keys[A_Index] "_routine",-1
	}
return

Space_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,25,1
return

r_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,50,2
return

MButton_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,75,3
return

q_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,100,4
return
Edit: Since you have sleeps in your hotkeys, this is not good. Try this instead, remove the sleeps in your hotkey routines and setup the Cooldown array instead. And of course, consider using Hotkeys suggestion, I'm sure it works fine.

Code: Select all

setkeydelay, 2
SetDefaultMouseSpeed, 0
CoordMode,ToolTip,Screen
global Keys:=["Space","r","MButton","q"]
global Cooldown:=[250,0,0,250]				; Instead of sleeps, Space_routine has cooldown of 250, r_routine cooldown 0,...
global timerStart:=[]

dollar:=["$","$","","$"]
Loop,4
{
	Hotkey,% dollar[A_Index] Keys[A_index],common_routine,On
	timerStart[A_Index]:=A_TickCount
}
Sleep,250
return

~home::suspend

AnyKey()
{
	Loop,4
		if GetKeyState(Keys[A_Index], "P")
			return 1
	return 0
}

common_routine:
	While AnyKey()
		Loop,4
			if GetKeyState(Keys[A_Index], "P") && A_TickCount-timerStart[A_Index]>=Cooldown[A_Index] && timerStart[A_Index]:=A_TickCount
				SetTimer,% Keys[A_Index] "_routine",-1
return

Space_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,25,1
return

r_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,50,2
return

MButton_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,75,3
return

q_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,100,4
return
Hi, i can't use that global cooldown thing because i need sleeps inside the script, i mean i don't want r to have X cooldown, i want R to have a cooldown between 2 sendinputs.

HotKeyIt wrote:Yes the other Hotkey will be suspended because AutoHotkey is not multi-threaded, see Threads.

You would need AutoHotkey.dll or AutoHotkey_H v2 to get what you want:
Example for AutoHotkey.dll:

Code: Select all

#Persistent
thread1:=AhkThread("
(
$space::
While GetKeyState(""space"", ""P"")
 ToolTip `% A_Now
Return
)")
thread2:=AhkThread("
(
$r::
While GetKeyState(""r"", ""P"")
 MsgBox, 0, Title, Text, 0.1
Return
)")
Example for AutoHotkey_H v2 without using AutoHotkey.dll:

Code: Select all

#Persistent
thread1:=exeThread("
(
$space::
While GetKeyState("space", "P")
 ToolTip `% A_Now
Return
)")
thread2:=exeThread("
(
$r::
While GetKeyState("r", "P")
 MsgBox, 0, Title, Text, 0.1
Return
)")
I don't understand ahk_h v2. I downloaded it, pasted compile folder on ahk compile folder and now what? should i compile as always and it will work?


@edit: Forgot to say, thank you all for the answer, english is not my main language hope you can understand what i'm trying to say :D
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Multiple scripts on 1 ahk

11 Sep 2016, 13:22

To compile AHK_H:
1. Extract Compiler folder
2. Copy AutoHotkey.exe from Win32w or x64w folder into Compile folder
3. Rename copied AutoHotkey.exe to Ahk2Exe.exe
4. Run Ahk2Exe.exe and select your script
5.Then select destination exe file
6. Press compile
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Multiple scripts on 1 ahk

11 Sep 2016, 13:32

And that should make my exe work as i want?

Will try it and edit this post.

It says "Could not extract script from exe" when i try to open the compiled script.
Last edited by kyuuuri on 11 Sep 2016, 13:35, edited 1 time in total.
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Multiple scripts on 1 ahk

11 Sep 2016, 13:37

Oh kk, sry for being annoying haha, it's my first time with multi-thread things on ahk.
Ahm, from the "Base File (.Bin)" Should i select v2.0.0.0 Ahk2Exe.exe? because the others won't work they give me the error i wrote on last post "Could not extract script from exe"

@edit: Yay it works!!! thanks
Now i have another problem, sorry. Ahm it is so slooooooooooow i don't know why, i didn't change something

Here is the code:

Code: Select all

#maxhotkeysperinterval 999999999
SetDefaultMouseSpeed, 0
setkeydelay, 2

thread1:=exeThread("
(
$*mbutton::
Loop
{
if not GetKeyState("mbutton", "P")
break
sendinput {click}
}
Return
)")



thread2:=exeThread("
(
$r::
loop
{
if not GetKeyState("r", "P")
break
sendinput {shift}
sendinput {click left, 726, 146}
sendinput {click left, 619, 322}
sendinput {click left, 607, 344}
sleep, 250
sendinput {click, 283, 304, left}
}
Return
)")



thread3:=exeThread("
(
$q::
loop
{
if not GetKeyState("q", "P")
break
sendinput {Ctrl}
MouseGetPos x, y
sendinput {Ctrl}
sendinput {click, 607, 344, left}
sendinput {Ctrl}
sendinput {Ctrl}
sleep, 250
sendinput {click, %x%, %y%, left}
sendinput {Ctrl}
}
Return
)")



thread4:=exeThread("
(
space::
loop
{
if not GetKeyState("space", "P")
break
Sendinput {b}
sleep, 50
}
Return
)")

~Home::Suspend
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Multiple scripts on 1 ahk

11 Sep 2016, 14:09

Sorry for double post i can't edit idk why. Ahm i'm still having that problem that the compiled ahk with basebin v2.0.0.0 Ahk2Exe.exe is too slow.

Ahm and i have the error "could not extract script from exe" everytime i compile with other basebin (tried all options, all give the same error)
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Multiple scripts on 1 ahk

11 Sep 2016, 15:52

kyuuuri wrote: Hi, i can't use that global cooldown thing because i need sleeps inside the script, i mean i don't want r to have X cooldown, i want R to have a cooldown between 2 sendinputs.
I see, I missed that, I think this might fix it. The actions after the sleeps goes in the if hasSlept[x] blocks, and, unfortunatley, needs to be in the x_routine_up sub-routine too. My original intent was of course that this should do the job, while still being easy to maintain, I might have missed both those goals by now...

Code: Select all

SetBatchLines,-1 ; If it is slow, this might help
setkeydelay, 2
SetDefaultMouseSpeed, 0
CoordMode,ToolTip,Screen
global Keys:=["Space","r","MButton","q"]
global Cooldown:=[0,250,0,250]				; Instead of sleeps.
global timerStart:=[]
hasSlept:=[0,0,0,0]

dollar:=["$","$","","$"]
Loop,4
{
	Hotkey,% dollar[A_Index] Keys[A_index],common_routine,On
	timerStart[A_Index]:=A_TickCount
}

Hotkey,% dollar[2] Keys[2] " up",% Keys[2] "_routine_up",On
Hotkey,% dollar[4] Keys[4] " up",% Keys[4] "_routine_up",On

Sleep,250
return

r_routine_up:
	; After sleep routine - again
	if hasSlept[2]
	{
		; After sleep routine
		ToolTip, % A_ThisLabel " after sleep up" A_TickCount,150,50,5
		hasSlept[2]:=0
		timerStart[2]:=0
		return 
	}
return

q_routine_up:
	; After sleep routine - again	
	if hasSlept[4]
	{
		; After sleep routine
		ToolTip, % A_ThisLabel " after sleep up" A_TickCount,150,100,6
		hasSlept[4]:=0
		timerStart[4]:=0
		return 
	}
return

~home::suspend

AnyKey()
{
	Loop,4
		if GetKeyState(Keys[A_Index], "P")
			return 1
	return 0
}

common_routine:
	While AnyKey()
		Loop,4
			if GetKeyState(Keys[A_Index], "P") && A_TickCount-timerStart[A_Index]>=Cooldown[A_Index] && timerStart[A_Index]:=A_TickCount
				SetTimer,% Keys[A_Index] "_routine",-1
return

Space_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,25,1
return

r_routine:
	if hasSlept[2]
	{
		; After sleep routine
		ToolTip, % A_ThisLabel " after sleep " A_TickCount,150,50,5
		hasSlept[2]:=0
		timerStart[2]:=0
		return 
	}
	ToolTip, % A_ThisLabel " " A_TickCount,0,50,2
	hasSlept[2]:=1
	
return

MButton_routine:
	ToolTip, % A_ThisLabel " " A_TickCount,0,75,3
return

q_routine:
	if hasSlept[4]
	{
		; After sleep routine
		ToolTip, % A_ThisLabel " after sleep " A_TickCount,150,100,6
		hasSlept[4]:=0
		timerStart[4]:=0
		return 
	}
	ToolTip, % A_ThisLabel " " A_TickCount,0,100,4
	hasSlept[4]:=1
return
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Multiple scripts on 1 ahk

11 Sep 2016, 15:55

kyuuuri wrote: Here is the code:

Code: Select all

#maxhotkeysperinterval 999999999
SetDefaultMouseSpeed, 0
setkeydelay, 2
;[...]
I'm guessing you need that code, i.e., the Mouse speed and KeyDelays in each "thread-code".
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Multiple scripts on 1 ahk

11 Sep 2016, 16:21

You can do this too, It's sort of what you didn't want to, i.e., run many scripts, but I don't think it is noticable, all scripts are made in this script, and closed when this exits. There are no tray icons. I think it works and is maintainable.

Code: Select all

OnExit("eF")
topcode=
(
#NoTrayIcon
#maxhotkeysperinterval 999999999
SetDefaultMouseSpeed, 0
setkeydelay, 2
)

thread1=
(
$*mbutton::
Loop
{
if not GetKeyState("mbutton", "P")
break
sendinput {click}
}
Return
)



thread2=
(
$r::
loop
{
if not GetKeyState("r", "P")
break
sendinput {shift}
sendinput {click left, 726, 146}
sendinput {click left, 619, 322}
sendinput {click left, 607, 344}
sleep, 250
sendinput {click, 283, 304, left}
}
Return
)



thread3=
(
$q::
loop
{
if not GetKeyState("q", "P")
break
sendinput {Ctrl}
MouseGetPos x, y
sendinput {Ctrl}
sendinput {click, 607, 344, left}
sendinput {Ctrl}
sendinput {Ctrl}
sleep, 250
sendinput {click, %x%, %y%, left}
sendinput {Ctrl}
}
Return
)



thread4=
(
space::
loop
{
if not GetKeyState("space", "P")
break
Sendinput {b}
sleep, 50
}
Return
)

; Delete old scripts
Loop,4
	FileDelete,script%A_Index%.ahk
; Make new scripts
Loop,4
	FileAppend,% topcode "`n" thread%A_Index%,script%A_Index%.ahk
; Run new scripts
Loop,4
	Run, %A_AHKPath% script%A_Index%.ahk,,,pid%A_Index%



eF()
{
	global
	; Close all scripts on exit.
	Loop,4
		Process, Close,% pid%A_Index%
	ExitApp
}

~Home::Suspend
Edit: Be aware that this deletes script1.ahk,...,script4.ahk in the folder you run this script.
Last edited by Helgef on 11 Sep 2016, 16:47, edited 1 time in total.
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Multiple scripts on 1 ahk

11 Sep 2016, 16:27

kyuuuri wrote:Sorry for double post i can't edit idk why. Ahm i'm still having that problem that the compiled ahk with basebin v2.0.0.0 Ahk2Exe.exe is too slow.

Ahm and i have the error "could not extract script from exe" everytime i compile with other basebin (tried all options, all give the same error)
Just tried it and pressing r and space at the same time seems to perform well for me.
Are you running the script from your hard drive, I remember a user had similar problem when he was running the script from ramdisk but I could not find out why.

In AHK_H v2 there is only AutoHotkey.exe or AutoHotkey.dll, you can't compile any other bin files!
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Multiple scripts on 1 ahk

11 Sep 2016, 17:42

HotKeyIt wrote:
kyuuuri wrote:Sorry for double post i can't edit idk why. Ahm i'm still having that problem that the compiled ahk with basebin v2.0.0.0 Ahk2Exe.exe is too slow.

Ahm and i have the error "could not extract script from exe" everytime i compile with other basebin (tried all options, all give the same error)
Just tried it and pressing r and space at the same time seems to perform well for me.
Are you running the script from your hard drive, I remember a user had similar problem when he was running the script from ramdisk but I could not find out why.

In AHK_H v2 there is only AutoHotkey.exe or AutoHotkey.dll, you can't compile any other bin files!
Hi, first of all, thanks for all the help!.
Ahm, i have it on my hard drive, i have it on same place i have the others ahk. It is very slow idk why, it is supposed to move as fast as possible and now it's like slow motion hahahaah,
Will explain what i did, hope you can help me with this problem.

1_ installed AHK
2_ downloaded AHK_H v2
2_ Copied compiler folder inside AHK_H V2 and pasted on autohotkey in program files.
3_ Opened x64w folder and copied ONLY AutoHotkey.exe and pasted it on compile folder in C:...Autohotkey (won't write all the url :D)
4_ changed "AutoHotkey.exe" name to "Ahk2Exe.exe" and opened it as administrator
5_ selected the file i want to compile, on Base Bin selected V2.0.0.0 Ahk2Exe.exe
6_ Compiled it
7_ Opened compiled file as administrator and press R. It moves slow
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Multiple scripts on 1 ahk

11 Sep 2016, 22:40

Those threads only share Hotkeys, everything else is separated so you will need the settings for each thread SetDefaultMouseSpeed, 0 where you need it.

Code: Select all

thread2:=exeThread("
(
SetDefaultMouseSpeed, 0
$r::
loop
{
if not GetKeyState("r", "P")
break
sendinput {shift}
sendinput {click left, 726, 146}
sendinput {click left, 619, 322}
sendinput {click left, 607, 344}
sleep, 250
sendinput {click, 283, 304, left}
}
Return
)")
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Multiple scripts on 1 ahk

12 Sep 2016, 03:04

HotKeyIt wrote:Those threads only share Hotkeys, everything else is separated so you will need the settings for each thread SetDefaultMouseSpeed, 0 where you need it.

Code: Select all

thread2:=exeThread("
(
SetDefaultMouseSpeed, 0
$r::
loop
{
if not GetKeyState("r", "P")
break
sendinput {shift}
sendinput {click left, 726, 146}
sendinput {click left, 619, 322}
sendinput {click left, 607, 344}
sleep, 250
sendinput {click, 283, 304, left}
}

Return
)")

Hi, thannks for the answer.
I'm still having this problem, it's like slowmotion. I mean it's not like speed is slow. The script is being slow, as if it had sleep, 5000 between each line.

Code: Select all

thread1:=exeThread("
(
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
$*mbutton::
Loop
{
if not GetKeyState("mbutton", "P")
break
sendinput {click}
}
Return
)")



thread2:=exeThread("
(
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
$r::
loop
{
if not GetKeyState("r", "P")
break
sendinput {shift}
sendinput {click left, 726, 146}
sendinput {click left, 619, 322}
sendinput {click left, 607, 344}
sleep, 250
sendinput {click, 283, 304, left}
}
Return
)")



thread3:=exeThread("
(
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
$q::
loop
{
if not GetKeyState("q", "P")
break
sendinput {Ctrl}
MouseGetPos x, y
sendinput {Ctrl}
sendinput {click, 607, 344, left}
sendinput {Ctrl}
sendinput {Ctrl}
sleep, 250
sendinput {click, %x%, %y%, left}
sendinput {Ctrl}
}
Return
)")



thread4:=exeThread("
(
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
space::
loop
{
if not GetKeyState("space", "P")
break
Sendinput {b}
sleep, 50
}
Return
)")

~Home::Suspend
That's the code i'm using right now
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Multiple scripts on 1 ahk

12 Sep 2016, 16:13

That is really odd, can you try on another computer, also can you try running as user, not admin.
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: Multiple scripts on 1 ahk

12 Sep 2016, 16:58

Same on all computers, i don't know why. When i press R it takes like 10 seconds for each action. The code i'm using is the same i pasted there, i compiled it again and i'm still having the same problem.

If i compile only this:

Code: Select all

thread2:=exeThread("
(
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
$r::
loop
{
if not GetKeyState("r", "P")
break
sendinput {shift}
sendinput {click left, 726, 146}
sendinput {click left, 619, 322}
sendinput {click left, 607, 344}
sleep, 250
sendinput {click, 283, 304, left}
}
Return
)")
it makes that action 1 time and then exits idk why

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Ineedhelplz, penguinautomator, Spawnova and 297 guests