Code: Select all
;~ ^1 ---- +1!1
;~ ^2 ---- +2!2
;~ ^a ---- +a!a
Loop 10
Hotkey "^" A_Index, a.b(A_Index) ;~ Error: Nonexistent hotkey.
class a {
static b(s){
Send "+" s "!" s
}
}
Code: Select all
;~ ^1 ---- +1!1
;~ ^2 ---- +2!2
;~ ^a ---- +a!a
Loop 10
Hotkey "^" A_Index, a.b(A_Index) ;~ Error: Nonexistent hotkey.
class a {
static b(s){
Send "+" s "!" s
}
}
Code: Select all
Hotkey "<^" 1, (*) => a.b("Test 1")
Hotkey "<^" 2, (*) => a.b("Test 2")
class a {
static b(s){
SendText "+" s "!" s
}
}
Code: Select all
Loop 10
Hotkey "<^" A_Index-1, f.Bind(A_Index-1) ; Left Ctrl + 0 - 9, binds A_Index-1
f(Parameter, ThisHotkey) => a.b(Parameter, ThisHotkey) ; You can certainly write this in the line above but I don't know how.
class a {
static b(para1, para2){
SendText "+" para1 "!" para1 ", Hotkey= " para2
}
}
I realized my mistake after. Didn't catch the control modifier symbol because it's six in the morning and haven't slept lol.Noitalommi_2 wrote: ↑19 May 2024, 06:55@niCode
Had this as my first attempt as well, check the return Value, it's not correct.
Edit: Post is gone or I'm hallucinating.
Code: Select all
loop 10 {
num := SubStr(A_Index, -1)
Hotkey('^' num, ObjBindMethod(a, 'b', num))
}
class a {
static b(s, key) {
SendText('+' s '!' s)
}
}
Code: Select all
#Requires AutoHotkey v2.0
For Key In StrSplit("0123456789")
Hotkey('^' Key, (HK) => A.B(SubStr(HK, -1)))
Class A {
Static B(K) {
ToolTip('+' K '!' K)
}
}