So I got this script, works fine. It makes a hotkey (A) cycle output so that AAAA = 1234
Well basically a few people I know want to use this themselves, but all the hotkeys and such need to be changed for each person.
So I made a simple GUI to where you can simply select the keys, put in the values and click okay. After pressing okay, all the keys, and numbers are now stored in a bunch of variables, which for the most part would work fine...EXCEPT, you can't use variables as hotkeys, so I must use the hotkey command to wait for the variables to be plugged in.
So after I changed all the (A:: {code}) style hotkeys to (hotkey , %KeyVar% , Label) method, the function of the hotkeys is very broken, the cycles don't loop, or wait correctly. please help, I'm a lost noob.
I wouldn't be opposed to this script simply taking the variables and creating a new / separate script to run (plugging the vars into the write spots of the working script).
I just didn't really know how to code that up. So instead I went with the way I could picture in mind, just using the vars inside the same script, and using the hotkey command instead of the (A:: {code}) format.
Here is the working script, you can test it in notepad to see how it works. (capslock or scrollLock need to be on to test this script)
Code: Select all
VarList_1 = 1|2|3|4|5|6|7|8|9|0 ; first set of keys to be pressed (vars S1K0 - S1K9)
VarRecast_1 = 15000|10000|5000|30000|10000|15000|30000|120000|50 ;first set of recasts (vars S1W0 - S1W9)
PauseSec_1 = 600 ; first set cast time (var S1CT)
VarList_2 = a|b|c|d|e|f|g|h|i|j ; second set of keys to be pressed (vars S2K0 - S2K9)
VarRecast_2 = 360000|300000|120000|120000|120000|120000|120000|30000|250 ; second set of recasts (vars S2W0 - S2W9)
PauseSec_2 = 3500 ;second cast time (var S2CT)
Loop, 2
{
CurrentIndex := A_Index
Loop, parse, VarList_%CurrentIndex%, |
{
CurrentIndex_%CurrentIndex% := A_Index
Maxnum_%CurrentIndex% := A_Index+1
var%A_Index%_key_%CurrentIndex% := A_LoopField
Loop, parse, VarRecast_%CurrentIndex%, |
{
if (A_Index = CurrentIndex_%CurrentIndex%)
var%A_Index%_recast_%CurrentIndex% := A_LoopField
}
}
}
#IfWinActive, ahk_class Notepad
LButton:: ; First Set Activator (Var S1A1)
Loop
{
if (GetKeyState("CapsLock", "T") = 1)
{
Loop, parse, VarList_1, |
{
num_1 = 1
if (Start%A_Index%_1 = "")
{
Send , % var%A_Index%_key_1
Start%A_Index%_1 := A_TickCount
Sleep, %PauseSec_1%
}
else
{
Elapsed%A_Index%_1 := A_TickCount - Start%A_Index%_1
if (Elapsed%A_Index%_1 >= Var%A_Index%_recast_1)
{
Send , % var%A_Index%_key_1
Start%A_Index%_1 := A_TickCount
Sleep, %PauseSec_1%
}
}
if (GetKeyState("LButton", "P") = 0)
break
}
}
else
{
if (GetKeyState("LButton", "P") = 1)
{
Click down
KeyWait, LButton
Click up
}
break
}
if (GetKeyState("LButton", "P") = 0)
break
}
return
RButton:: ; Second Set Activator (Var S2A1)
Loop
{
if (GetKeyState("CapsLock", "T") = 1)
{
Loop, parse, VarList_2, |
{
num_2 = 1
if (Start%A_Index%_2 = "")
{
Send , % var%A_Index%_key_2
Start%A_Index%_2 := A_TickCount
Sleep, %PauseSec_2%
}
else
{
Elapsed%A_Index%_2 := A_TickCount - Start%A_Index%_2
if (Elapsed%A_Index%_2 >= Var%A_Index%_recast_2)
{
Send , % var%A_Index%_key_2
Start%A_Index%_2 := A_TickCount
Sleep, %PauseSec_2%
}
}
if (GetKeyState("RButton", "P") = 0)
break
}
}
else
{
if (GetKeyState("RButton", "P") = 1)
{
Click down right
KeyWait, RButton
Click up right
}
break
}
if (GetKeyState("RButton", "P") = 0)
break
}
return
a:: ;First Set Activator 2 (Var S1A2)
Loop
{
if (GetKeyState("ScrollLock", "T") = 1)
{
Loop, parse, VarList_1, |
{
num_1 = 1
if (Start%A_Index%_1 = "")
{
Send , % var%A_Index%_key_1
Start%A_Index%_1 := A_TickCount
Sleep, %PauseSec_1%
}
else
{
Elapsed%A_Index%_1 := A_TickCount - Start%A_Index%_1
if (Elapsed%A_Index%_1 >= Var%A_Index%_recast_1)
{
Send , % var%A_Index%_key_1
Start%A_Index%_1 := A_TickCount
Sleep, %PauseSec_1%
}
}
if (GetKeyState("a", "P") = 0)
break
}
}
else
{
if (GetKeyState("a", "P") = 1)
{
send , a
}
break
}
if (GetKeyState("RButton", "P") = 0)
break
}
return
v:: ;Second Set Activator 2 (Var S2A2)
Loop
{
if (GetKeyState("ScrollLock", "T") = 1)
{
Loop, parse, VarList_2, |
{
num_2 = 1
if (Start%A_Index%_2 = "")
{
Send , % var%A_Index%_key_2
Start%A_Index%_2 := A_TickCount
Sleep, %PauseSec_2%
}
else
{
Elapsed%A_Index%_2 := A_TickCount - Start%A_Index%_2
if (Elapsed%A_Index%_2 >= Var%A_Index%_recast_2)
{
Send , % var%A_Index%_key_2
Start%A_Index%_2 := A_TickCount
Sleep, %PauseSec_2%
}
}
if (GetKeyState("v", "P") = 0)
break
}
}
else
{
if (GetKeyState("v", "P") = 1)
{
Send , v
}
break
}
if (GetKeyState("v", "P") = 0)
break
}
return
~CapsLock::
{
if (GetKeyState("CapsLock", "T") = 1)
{
TrayTip, , HotKeys-Mouse: On, 10, 1
}
else if (GetKeyState("CapsLock", "T") = 0)
{
TrayTip, , HotKeys-Mouse: Off, 10, 1
}
}
return
~ScrollLock::
{
if (GetKeyState("ScrollLock", "T") = 1)
{
TrayTip, , HotKeys-Key: On, 10, 1
}
else if (GetKeyState("ScrollLock", "T") = 0)
{
TrayTip, , HotKeys-Key: Off, 10, 1
}
}
return
~MButton & WheelDown::
{
SetStoreCapslockMode, off
send , {capslock}
if (GetKeyState("CapsLock", "T") = 1)
{
TrayTip, , HotKeys-Mouse: On, 10, 1
}
else if (GetKeyState("CapsLock", "T") = 0)
{
TrayTip, , HotKeys-Mouse: Off, 10, 1
}
}
Return
~MButton & WheelUp::
{
SetStoreCapslockMode, off
send , {scrolllock}
if (GetKeyState("ScrollLock", "T") = 1)
{
TrayTip, , HotKeys-Key: On, 10, 1
}
else if (GetKeyState("ScrollLock", "T") = 0)
{
TrayTip, , HotKeys-Key: Off, 10, 1
}
}
Return
#IfWinActive ahk_class Notepad
Code: Select all
DropDownListPart1 = NONE||1|2|3|4|5|6|7|8|9|0|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z
DropDownListPart2 = ``|-|=|[|]|\|,|.|/
DropDownListPart3 = Space|Tab|Enter|Escape|Backspace|Delete|Insert|Home|End|PgUp|PgDn
DropDownListPart4 = Up|Down|Left|Right|ScrollLock|CapsLock|NumLock
DropDownListPart5 = Click Left|Click Right|Click Middle|NumpadDiv|NumpadMult|NumpadAdd|NumpadSub|NumpadEnter|NumpadDel|NumpadIns|NumpadClear
DropDownListPart6 = NumpadUp|NumpadDown|NumpadLeft|NumpadRight|NumpadHome|NumpadEnd|NumpadPgUp|NumpadPgDn
DropDownListPart7 = Numpad0|Numpad1|Numpad2|Numpad3|Numpad4|Numpad5|Numpad6|Numpad7|Numpad8|Numpad9|NumpadDot
DropDownListPart8 = F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12
DropDownListPart9 = AppsKey|LWin|RWin|Alt|Control|LControl|RControl|Shift|LShift|RShift|LAlt|RAlt|PrintScreen|CtrlBreak|Pause
DropDownListPart0 = Joy1|Joy2|Joy3|Joy4|Joy5|Joy6|Joy7|Joy8|Joy9|Joy10|Joy11|Joy12
DropDownListHalf1 = %DropDownListPart1%|%DropDownListPart0%|%DropDownListPart3%|%DropDownListPart4%|%DropDownListPart2%
DropDownListHalf2 = %DropDownListPart8%|%DropDownListPart7%|%DropDownListPart6%|%DropDownListPart9%|%DropDownListPart5%
DropDownListList = %DropDownListHalf1%|%DropDownListHalf2%
Gui,Add,DropDownList,x50 y40 w120 vS1A1 gClick,%DropDownListList%
Gui,Add,DropDownList,x50 y110 w120 vS1K1 gClick,%DropDownListList%
Gui,Add,DropDownList,x50 y130 w120 vS1K2 gClick,%DropDownListList%
Gui,Add,DropDownList,x50 y150 w120 vS1K3 gClick,%DropDownListList%
Gui,Add,DropDownList,x50 y170 w120 vS1K4 gClick,%DropDownListList%
Gui,Add,DropDownList,x50 y190 w120 vS1K5 gClick,%DropDownListList%
Gui,Add,DropDownList,x50 y210 w120 vS1K6 gClick,%DropDownListList%
Gui,Add,DropDownList,x50 y230 w120 vS1K7 gClick,%DropDownListList%
Gui,Add,DropDownList,x50 y250 w120 vS1K8 gClick,%DropDownListList%
Gui,Add,DropDownList,x50 y270 w120 vS1K9 gClick,%DropDownListList%
Gui,Add,DropDownList,x50 y290 w120 vS1K0 gClick,%DropDownListList%
Gui,Add,DropDownList,x330 y40 w120 vS2A1 gClick,%DropDownListList%
Gui,Add,DropDownList,x330 y110 w120 vS2K1 gClick,%DropDownListList%
Gui,Add,DropDownList,x330 y130 w120 vS2K2 gClick,%DropDownListList%
Gui,Add,DropDownList,x330 y150 w120 vS2K3 gClick,%DropDownListList%
Gui,Add,DropDownList,x330 y170 w120 vS2K4 gClick,%DropDownListList%
Gui,Add,DropDownList,x330 y190 w120 vS2K5 gClick,%DropDownListList%
Gui,Add,DropDownList,x330 y210 w120 vS2K6 gClick,%DropDownListList%
Gui,Add,DropDownList,x330 y230 w120 vS2K7 gClick,%DropDownListList%
Gui,Add,DropDownList,x330 y250 w120 vS2K8 gClick,%DropDownListList%
Gui,Add,DropDownList,x330 y270 w120 vS2K9 gClick,%DropDownListList%
Gui,Add,DropDownList,x330 y290 w120 vS2K0 gClick,%DropDownListList%
Gui,Add,Edit,x180 y110 w45 h21 Number vS1W1 gClick,Edit
Gui,Add,Edit,x180 y130 w45 h21 Number vS1W2 gClick,Edit
Gui,Add,Edit,x180 y150 w45 h21 Number vS1W3 gClick,Edit
Gui,Add,Edit,x180 y170 w45 h21 Number vS1W4 gClick,Edit
Gui,Add,Edit,x180 y190 w45 h21 Number vS1W5 gClick,Edit
Gui,Add,Edit,x180 y250 w45 h21 Number vS1W8 gClick,Edit
Gui,Add,Edit,x180 y270 w45 h21 Number vS1W9 gClick,Edit
Gui,Add,Edit,x180 y290 w45 h21 Number vS1W0 gClick,Edit
Gui,Add,Edit,x280 y110 w45 h21 Number vS2W1 gClick,Edit
Gui,Add,Edit,x280 y130 w45 h21 Number vS2W2 gClick,Edit
Gui,Add,Edit,x280 y150 w45 h21 Number vS2W3 gClick,Edit
Gui,Add,Edit,x280 y170 w45 h21 Number vS2W4 gClick,Edit
Gui,Add,Edit,x280 y190 w45 h21 Number vS2W5 gClick,Edit
Gui,Add,Edit,x280 y210 w45 h21 Number vS2W6 gClick,Edit
Gui,Add,Edit,x280 y230 w45 h21 Number vS2W7 gClick,Edit
Gui,Add,Edit,x280 y250 w45 h21 Number vS2W8 gClick,Edit
Gui,Add,Edit,x280 y270 w45 h21 Number vS2W9 gClick,Edit
Gui,Add,Edit,x280 y290 w45 h21 Number vS2W0 gClick,Edit
Gui,Add,Text,x80 y20 w60 h13 Center,Activator 1
Gui,Add,Text,x360 y20 w60 h13 Center,Activator 2
Gui,Add,Text,x80 y90 w60 h13 Center,Keys
Gui,Add,Text,x360 y90 w60 h13 Center,Keys
Gui,Add,Edit,x180 y210 w45 h21 Number vS1W6 gClick,Edit
Gui,Add,Edit,x180 y230 w45 h21 Number vS1W7 gClick,Edit
Gui,Add,Edit,x180 y40 w45 h21 Number vS1CT gClick,Edit
Gui,Add,Edit,x280 y40 w45 h21 Number vS2CT gClick,Edit
Gui,Add,DropDownList,x50 y60 w120 vS1A2 gClick,%DropDownListList%
Gui,Add,Text,x20 y50 w21 h13 Center,OR
Gui,Add,DropDownList,x330 y60 w120 vS2A2 gClick,%DropDownListList%
Gui,Add,Text,x460 y50 w21 h13,OR
Gui,Add,Button,x280 y330 w43 h23 gGuiClose,Submit
Gui,Add,Text,x229 y29 w50 h13,Cast Time
Gui,Add,Text,x220 y90 w65 h13,ReCast Time
Gui,Add,Button,x180 y330 w43 h23 gHelp,Help
Gui,Show,x429 y99 w500 h501 ,
Return
Click:
Gui, Submit , NoHide
Return
Help:
MsgBox, The keys you select for "Activator 1" will set off the keys beneath it, Same for "Activator 2" `nCast Time is the amount of time to wait between each keypress, This should be the amount of time it takes for you to "cast" or "perform" the action before the next press `nReCast Time is the amount of time (milliseconds) before that button is used again, for example if you want one key to go once a minute, and one to go once a second, make the first 60000 make the second 1000
Return
GuiClose:
Gui, Submit , NoHide
SetClose = 1
Gui, Cancel