FaridAgl Posted January 19, 2012 Posted January 19, 2012 (edited) I want to make a function that takes another function's name (and even parameters) as parameter and run it with AutoIt3ExecuteLine. Maybe something similar to this: _ExecuteFunc('_MoveMouse(10, 10)') Func _MoveMouse($X, $Y) MouseMove($X, $Y) EndFunc Func _ExecuteFunc($Func) Run(@AutoItExe & ' /AutoIt3ExecuteLine $Func') EndFunc Edited January 19, 2012 by D4RKON3 http://faridaghili.ir
guwguw Posted January 19, 2012 Posted January 19, 2012 (edited) I usually call functions directly (not with AutoITExecuteLine). I define the values and then pass them via a call like $runcommand = "C:ProgrammeAutoIt3orderwindow.exe" & " " & $tradeAccount & " " & $currentpair & " " & $action & " " & $orderTradeUnits & " " & $__CurrentPrice & " " & $setTP & " " & $TPvalue & " " & $setSL & " " & $SLvalue ConsoleWrite("- " & @ScriptLineNumber & " parameters:" & " $tradeAccount " & $tradeAccount & ", $currentpair:" & $currentpair & ", $action:" & $action & ", $orderTradeUnits:" & $orderTradeUnits & " $__CurrentPrice:" & $__CurrentPrice & " $setTP:" & $setTP & " $TPvalue:" & $TPvalue & " $setSL:" & $setSL & " $SLvalue:" & $SLvalue & @CRLF) Run($runcommand) Edited January 19, 2012 by guwguw
FaridAgl Posted January 19, 2012 Author Posted January 19, 2012 I want to use AutoIt3ExecuteLine to run functions as a seprated process. http://faridaghili.ir
ChrisL Posted January 19, 2012 Posted January 19, 2012 I want to make a function that takes another function's name (and even parameters) as parameter and run it with AutoIt3ExecuteLine. Maybe something similar to this: _ExecuteFunc('_MoveMouse(10, 10)') Func _MoveMouse($X, $Y) MouseMove($X, $Y) EndFunc Func _ExecuteFunc($Func) Run(@AutoItExe & ' /AutoIt3ExecuteLine $Func') EndFunc Here is an example using message boxes but you can change it to whatever you need. If $CMDLINE[0] > 0 then If $CMDLINE[1] = "_MyExternallyRanFunction()" then _MyExternallyRanFunction() Exit EndIf EndIf _RunExternal("_MyExternallyRanFunction()") MsgBox(0,"Msgbox1","I am running from the main script!" & @crlf & "My PID = " & @AutoItPID) Func _RunExternal($COMMAND) If @Compiled then Run('"' & @ScriptFullPath & '" ' & $COMMAND, @ScriptDir) Else Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" ' & $COMMAND,@ScriptDir) EndIf EndFunc Func _MyExternallyRanFunction() Msgbox(0,"Msgbox2","I am the message box running in an external process" & @crlf & "My PID = " & @AutoItPID) EndFunc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
FaridAgl Posted January 19, 2012 Author Posted January 19, 2012 Tricky, works fine. Thanks. http://faridaghili.ir
FaridAgl Posted January 20, 2012 Author Posted January 20, 2012 (edited) With the help of ChrisL i made this so far that is suitable for my usage.Just want to share, maybe someone find it useful._FuncAsProcess.au3If $CMDLINE[0] Then Call($CMDLINE[1]) Exit EndIf Func _FuncAsProcess($Function) If @Compiled Then Return Run('"' & @ScriptFullPath & '" ' & $Function, @ScriptDir) Else Return Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" ' & $Function, @ScriptDir) EndIf EndFunc_FuncAsProcess Example#NoTrayIcon #include <_FuncAsProcess.au3> GUICreate('_FuncAsProcess', 250, 100) $chkEnable = GUICtrlCreateCheckbox('Enable Loop', 10, 10) GUISetState() While True Switch GUIGetMsg() Case -3 Exit Case $chkEnable If GuiCtrlRead($chkEnable) = 1 Then $ProcessID = _FuncAsProcess('_StartLoop') Else ProcessClose($ProcessID) EndIf EndSwitch WEnd Func _StartLoop() $i = 1 While $i > 0 ToolTip($i) $i += 1 Sleep(10) WEnd EndFunc Edited January 20, 2012 by D4RKON3 sisko59 1 http://faridaghili.ir
ChrisL Posted January 21, 2012 Posted January 21, 2012 You can change this a little and also use parameters if you need to. expandcollapse popupIf $CMDLINE[0] > 0 then Switch $CMDLINE[0] Case 1 Call($CMDLINE[1]) Case 2 Call($CMDLINE[1],$CMDLINE[2]) Case 3 Call($CMDLINE[1],$CMDLINE[2],$CMDLINE[3]) Case 4 Call($CMDLINE[1],$CMDLINE[2],$CMDLINE[3],$CMDLINE[4]) Case 5 Call($CMDLINE[1],$CMDLINE[2],$CMDLINE[3],$CMDLINE[4],$CMDLINE[5]) Case Else ; EndSwitch Exit EndIf _RunExternal("_MyExternallyRanFunction") _RunExternal("_MyExternallyRanFunction",'"I have 1 param"') _RunExternal("_MyExternallyRanFunction",'"I have 2 params" "See this is my Second param"') _RunExternal("_MyExternallyRanFunction",'"I have 3 params" "This is my Second param" "And this is my Third param"') _RunExternal("_MyExternallyRanFunction",'"I have 4 params" "This is my Second param" "This is my Third param" "Look it''s my Fourth param"') MsgBox(0,"Msgbox1","I am running from the main script!" & @crlf & "My PID = " & @AutoItPID) Func _RunExternal($COMMAND,$Param = "") If @Compiled then Run('"' & @ScriptFullPath & '" ' & $COMMAND & " " & $Param, @ScriptDir) Else Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" ' & $COMMAND & " " & $Param,@ScriptDir) EndIf EndFunc Func _MyExternallyRanFunction($param1="",$param2="",$param3="",$param4="") Msgbox(0,"Msgbox2","I am the message box running in an external process" & @crlf & "My PID = " & @AutoItPID & @CRLF & $param1 & @CRLF & $param2 & @CRLF & $param3 & @CRLF & $param4) EndFunc sisko59 and FaridAgl 2 [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now