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