there are some versione out there. maybe they are basically the same inside. i think they write to disk and not only work from the memory - right?
AHK-Studio is using on, i using one.
Examples:
FileWriteAndRun(sayH
^- preparser: in_commandLine_send_modified_clipboard.ahk
Code: Select all
FileWriteAndRun(sayHelloCode, sayHelloFunctionInc){
DetectHiddenWindows,On
SetTitleMatchMode,2
winTC := sayHelloFunctionInc . " ahk_class AutoHotkey"
if(winExist(winTC)){
WinClose,% winTC
WinWaitClose,% winTC,,1
}
if(winexist(winTC)){
ToolTip,DONT WANT RUN '%winTC%'. its already exist. `n (line:%A_LineNumber%) `n 18-02-15_13-00bbb
WinKill,% winTC
tooltip, % "Wait" A_LineNumber " " RegExReplace(A_LineFile,".*\\")
WinWaitClose,% winTC,,2
tooltip,
return false
}
isFileExist := false
FileWrite(sayHelloCode, sayHelloFunctionInc)
Loop,200 ;
{
if(GetKeyState("Ctrl", "P"))
KeyWait Control ; Wartet darauf, dass sowohl STRG als auch ALT losgelassen wird.
if(FileExist(sayHelloFunctionInc)){
isFileExist := true
break
}
Sleep,20
}
if(FileExist(sayHelloFunctionInc)){
try{
run, % sayHelloFunctionInc
; MsgBox, '%sayHelloFunctionInc%' = sayHelloFunctionInc `n (line:%A_LineNumber%) `n
return isFileExist
}
catch e
{
sleep,1800 ; <== maybe a good idea 19-03-20_08-20
}
}
}
FileWrite(sayHelloCode, sayHelloFunctionInc){
tempFileAddress := A_ScriptDir "\" A_TickCount ".temp." A_ThisFunc ".txt"
FileAppend, % sayHelloCode, % tempFileAddress
FileCopy,% tempFileAddress, % sayHelloFunctionInc, 1
sleepMilli := 1
while(A_Index < 100){
if(FileExist(tempFileAddress)){
; msgbox,% A_Index * sleepMilli ; ==> 19-02-19_17-22 interesting it shows ist takes only 0 millisecond. so already done
break
}
Sleep,% sleepMilli
}
FileDelete,% tempFileAddress
return 1
}
DynaRunFROMAhkSudio
^- preparser: in_commandLine_send_modified_clipboard.ahk
Code: Select all
DynaRunFROMAhkSudio(Script,Wait:=true,name:="Untitled"){
static exec,started,filename
if(!IsObject(v.Running))
v.Running:=[]
filename:=name,MainWin.Size(),exec.Terminate()
if(Script~="i)m(.*)\{"=0)
Script.="`n" "m(x*){`nfor a,b in x`nlist.=b Chr(10)`nMsgBox,,AHK Studio,% list`n}"
if(Script~="i)t(.*)\{"=0)
Script.="`n" "t(x*){`nfor a,b in x`nlist.=b Chr(10)`nToolTip,% list`n}"
msgBox, 19-01-16_19-59 19-01-16_19-59 19-01-16_19-59 19-01-16_19-59 19-01-16_19-59
shell:=ComObjCreate("WScript.Shell"),exec:=shell.Exec("AutoHotkey.exe /ErrorStdOut *"),exec.StdIn.Write(Script),exec.StdIn.Close(),started:=A_Now
v.Running[Name]:=exec
SetTimer,CheckForError,120
return
CheckForError:
Process,Exist,% exec.ProcessID
if(!ErrorLevel){
if(text:=exec.StdERR.ReadAll()){
if(!v.debug.sc)
MainWin.DebugWindow()
tooltip,% A_ThisFunc ":DynaRun: `nScript Exited, ExitCode: " exec.ExitCode "`n" text
}else
tooltip,% A_ThisFunc ":DynaRun: Script Exited, ExitCode: "
SetTimer,CheckForError,Off
return 1
}
; SetStatus(filename " running. Run-Time: " A_Now-started " Seconds",3)
return
}
DynaRun(TempScript, pipename
^- preparser: in_commandLine_send_modified_clipboard.ahk
Code: Select all
;/¯¯¯¯ DynaRun ¯¯ 181029190515 ¯¯ 29.10.2018 19:05:15 ¯¯\
DynaRun(TempScript, pipename=""){
setTitleMatchMode, 2
if(winExist("fn_functions_global_" A_ThisFunc)){
return false
}
TempScriptPre := "" . "FileEncoding, UTF-8 `n"
if(!InStr(TempScript,"aScriptDir :=" ))
TempScriptPre .= "aScriptDir := """ A_ScriptDir """ `n"
TempScript := TempScriptPre TempScript "`n"
static _:="uint",@:="Ptr"
try ; i dont want disturbing error messages
{
If pipename =
name := "AHK" A_TickCount "ln" A_LineNumber "fn_functions_global_" A_ThisFunc
Else
name := pipename
__PIPE_GA_ := DllCall("CreateNamedPipe","str","\\.\pipe\" name,_,2,_,0,_,255,_,0,_,0,@,0,@,0)
__PIPE_ := DllCall("CreateNamedPipe","str","\\.\pipe\" name,_,2,_,0,_,255,_,0,_,0,@,0,@,0)
if (__PIPE_=-1 or __PIPE_GA_=-1)
Return 0
try{
fileAdress = %A_AhkPath% "\\.\pipe\%name%"
if(0)
while(!FileExist(fileAdress)){
Sleep,50
if(A_Index > 20)
return 0
}
Run, %fileAdress%,,UseErrorLevel HIDE, PID
} catch e{
;throw Exception("Exception:`n" e.What "`n" e.Message "`n" e.File "@" e.Line, -1)
tip:="Exception:`n" e.What "`n" e.Message "`n" e.File "@" e.Line
tooltip, % tip
TempScript .= "`n#" "Include " A_ScriptDir "\inc_ahk\functions_global.inc.ahk"
FileAppend, `% TempScript, `% name
}
DllCall("ConnectNamedPipe",@,__PIPE_GA_,@,0)
DllCall("CloseHandle",@,__PIPE_GA_)
DllCall("ConnectNamedPipe",@,__PIPE_,@,0)
script := (A_IsUnicode ? chr(0xfeff) : (chr(239) . chr(187) . chr(191))) TempScript
; clipboard := script
if !DllCall("WriteFile",@,__PIPE_,"str",script,_,(StrLen(script)+1)*(A_IsUnicode ? 2 : 1),_ "*",0,@,0)
Return A_LastError,DllCall("CloseHandle",@,__PIPE_)
DllCall("CloseHandle",@,__PIPE_)
}
catch e ; Handles the first error/exception raised by the block above.
{
tip := "Exception in DynaRun:`n" e.What "`n" e.Message "`n" e.File "@" e.Line
lll( A_ThisFunc ":" A_LineNumber , A_LineFile ,tip)
tooltip, `% tip
FileAppend, `% TempScript, `% name
}
SetTitleMatchMode,1
if(1 && WinExist(substr(name,1,-5))) ; helps debugging
FileAppend, `% TempScript, `% name
while(1 && name && WinExist(substr(name,1,-5)) && A_Index < 9)
WinClose,
; clipboard := TempScript
Return PID
}