How to pass parameters in hotstring function Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rakibkhan7496
Posts: 8
Joined: 11 May 2021, 06:53
Contact:

How to pass parameters in hotstring function

28 Sep 2021, 10:19

Code: Select all

#SingleInstance, Force
SendMode Input
SetWorkingDir, %A_ScriptDir%

;Code 1
;need to pass param in msg like msg("Hello")
Hotstring(":X:hi","msg")
msg(){
    MsgBox,,Message, % x,2
}

;Code 2
:X:btw::btw("By The Way")
btw(x){
    MsgBox,,Message, % x,2
}
Sorry If I'm being naive, But I can't find a solution
In this code above how can I pass parameters in Code 1 just like Code 2?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: How to pass parameters in hotstring function  Topic is solved

28 Sep 2021, 10:59

u create a BoundFunction object, .Bind() whatever parameters u need accessible and pass it to the Hotstring() function

Code: Select all

Hotstring(":X:hi",Func("msg").Bind("Hello"))
msg(x){
    MsgBox,,Message, % x,2
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], ShatterCoder and 147 guests