Page 1 of 1

Autohotket.dll with param Need help

Posted: 18 Jun 2017, 19:47
by masheen

Code: Select all

MsgBox 1

SCTIPT = "Msgbox test"

ahkdll := DllCall("LoadLibrary", "Str", dll:="Autohotkey.dll","Ptr")
DllCall(dll "\ahktextdll", "Str", "SCTIPT  -->  + ARGS <---???      ", "Str", "thread", "Cdecl Int")
While DllCall(dll "\ahkReady")
  Sleep 100
DllCall("FreeLibrary", "Ptr", ahkdll)

MsgBox 3
Can i run my script with parametrs (args) via autohotket.dll ?
like this AutoHotKey.exe / arg1

If u can give me small example

Re: Autohotket.dll with param Need help

Posted: 19 Jun 2017, 07:03
by HotKeyIt
Sure:

Code: Select all

MsgBox 1

SCRIPT = param=`%1`%`nMsgbox `% param

ahkdll := DllCall("LoadLibrary", "Str", dll:=A_AhkDir "\Autohotkey.dll","Ptr")
DllCall(dll "\ahktextdll", "Str", SCRIPT, "Str", "thread", "Str","Parameters","Cdecl Int")
While DllCall(dll "\ahkReady")
  Sleep 100
DllCall("FreeLibrary", "Ptr", ahkdll)

MsgBox 3

Re: Autohotket.dll with param Need help

Posted: 19 Jun 2017, 12:19
by masheen
HotKeyIt wrote:Sure:

Code: Select all

MsgBox 1

SCRIPT = param=`%1`%`nMsgbox `% param

ahkdll := DllCall("LoadLibrary", "Str", dll:=A_AhkDir "\Autohotkey.dll","Ptr")
DllCall(dll "\ahktextdll", "Str", SCRIPT, "Str", "thread", "Str","Parameters","Cdecl Int")
While DllCall(dll "\ahkReady")
  Sleep 100
DllCall("FreeLibrary", "Ptr", ahkdll)

MsgBox 3
My script will

Code: Select all


SCRIPT  ="(
if (%0%> 0) {
	Loop,%0%{ 
		param:=%A_Index%
		StringLeft, SwitchPointer, param, 1
		if (SwitchPointer="-" OR SwitchPointer=" / ") {
			StringMid, Switch, param, 2, StrLen(param)
		} 
	}
}

if param = 2
	MsgBox good
)"

param = 2
ExeScript = SCRIPT % param

ahkdll := DllCall("LoadLibrary", "Str", dll:=A_AhkDir "\Autohotkey.dll","Ptr")
DllCall(dll "\ahktextdll", "Str", ExeScript, "Str", "thread", "Str","Parameters","Cdecl Int")
While DllCall(dll "\ahkReady")
  Sleep 100
DllCall("FreeLibrary", "Ptr", ahkdll)
Right?

Re: Autohotket.dll with param Need help

Posted: 19 Jun 2017, 12:34
by HotKeyIt
Probably?

Code: Select all

ExeScript  =
(
paramcount = `%0`%
Loop `% paramcount{ 
	param:=`%A_Index`%
	StringLeft, SwitchPointer, param, 1
	if (SwitchPointer="-" OR SwitchPointer="/") {
		StringMid, Switch`%A_Index`%, param, 2,`% StrLen(param)-1
	} 
}

if paramcount = 2
	MsgBox `% "good``n" switch1 "``n" switch2
)

param := "-abc /cde"
ahkdll := DllCall("LoadLibrary", "Str", dll:=A_AhkDir "\Autohotkey.dll","Ptr")
DllCall(dll "\ahktextdll", "Str", ExeScript, "Str", "thread", "Str",param,"Cdecl Int")
While DllCall(dll "\ahkReady")
  Sleep 100
DllCall("FreeLibrary", "Ptr", ahkdll)

Re: Autohotket.dll with param Need help

Posted: 19 Jun 2017, 13:11
by masheen
HotKeyIt wrote:Probably?

Code: Select all

ExeScript  =
(
paramcount = `%0`%
Loop `% paramcount{ 
	param:=`%A_Index`%
	StringLeft, SwitchPointer, param, 1
	if (SwitchPointer="-" OR SwitchPointer="/") {
		StringMid, Switch`%A_Index`%, param, 2,`% StrLen(param)-1
	} 
}

if paramcount = 2
	MsgBox `% "good``n" switch1 "``n" switch2
)

param := "-abc /cde"
ahkdll := DllCall("LoadLibrary", "Str", dll:=A_AhkDir "\Autohotkey.dll","Ptr")
DllCall(dll "\ahktextdll", "Str", ExeScript, "Str", "thread", "Str",param,"Cdecl Int")
While DllCall(dll "\ahkReady")
  Sleep 100
DllCall("FreeLibrary", "Ptr", ahkdll)

this try it now