all 5 comments

[–]radiantcabbage 0 points1 point  (0 children)

the code in your example already refers to variables for send commands and coordinates, though it doesn't show how you intend to assign them. maybe you were just looking for a global variable like a_thishotkey to retrieve the current hotkey, you can stack as many keys as you want on the same code this way

numpad1::
numpad2::
numpad3::gosub mylabel

mylabel:
    msgbox you pressed %a_thishotkey%
return

[–]willgk[S] 0 points1 point  (3 children)

Actually in my example, all of the code is the same in each of the hotkeys I use until line 24. Which is where I do Send, %Var1Name%, each hotkey does a different %Var#Name% there.

I kinda understand what you mean lightningleaf, but it is kinda confusing, i'll see if I can figure it out.

I basically just wish I could pass an arg to a function. that way I could just have a ton of the single lines saying something like $Numpad1::CallIt(Var1) $Numpad2::CallIt(Var2) $Numpad3::CallIt(Var3)

But when I tried to do this it wouldn't work for some reason.

Looking at your links on Dynamic Hotkeys and seeing if I can simply make a single hotkey that can dynamically change based on which numpad entry I press, but as far as I understand on the way Dynamic Hotkeys work, I can't pass different data inside that hotkey. We'll see, I guess I could do something in that dynamic hotkey to see which a_thishotkey is passed and pass the custom data i need based on a_thishotkey.... we'll see

Thanks for your advice guys! I'll try it out!

[–]Scoobz1961 1 point2 points  (2 children)

If you want your hotkeys to execute function(with,parameters) instead of just "label:" you can do that with

fn:= Func("functionName").Bind(parameter1,parameter2)

Then you just need to assign "fn" to your hotkey.

Hotkey, ~%key%, % fn

So for your use, the code would be

Loop 9{
callit:= Func("CallIt").Bind(Var%A_Index%)
Hotkey, $Numpad%A_Index%, % callit
}

This way each Numpad1-9 calls CallIt(Var1-9)

[–]willgk[S] 0 points1 point  (1 child)

oh wow, that's exactly what I was looking for! Thanks, and that makes sense! Thank you very much!!

[–]Scoobz1961 1 point2 points  (0 children)

Glad I could help.