junkew Posted May 24, 2019 Share Posted May 24, 2019 start with describing the problem instead of describing solutions. It seems like you want some kind of plugin logic in a precompiled exe. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Busti Posted May 24, 2019 Author Share Posted May 24, 2019 (edited) 43 minutes ago, junkew said: start with describing the problem instead of describing solutions. It seems like you want some kind of plugin logic in a precompiled exe. Local $l = @ScriptDir & "\tmp_call.au3", $r, $e, $a Dim $CallBack = DllCallbackRegister("_CallMeFunction", "int", "int;int;int;bool") ; i want the address of the autoit function ConsoleWrite( "!$CallBack: "& $CallBack & @CRLF ) $a = DllCallbackGetPtr($CallBack) ConsoleWrite( "!DllCallbackGetPtr: "& $a & @CRLF ) ; i got the address of the autoit function ; here should be a part which "extract" runnable autoit code from the memory / i would also map the code into the memory/ if possible - but i want to avoid creating a function like: #cs $test_string = 'Func _CallMeFunction( $a=1, $b=2, $c=3, $externalCall=False )' & @CRLF & _ 'If ($externalCall = True) Then' & @CRLF & _ 'MsgBox(0, "external", "call - running in its own script " & $a & $b & $c )' & @CRLF & _ 'ElseIf ($externalCall = False) Then' & @CRLF & _ 'MsgBox(0, "internal", "call - running in the main script " & $a & $b & $c )' & @CRLF & _ 'EndIf' & @CRLF & _ 'Return 1' & @CRLF & _ 'EndFunc' & @CRLF & _ '_CallMeFunction()' and preferable be able to just to something like this : #ce $r = _ExtractAutoItCodeFromMemory( $a, '_CallMeFunction', $lenght ) FileWrite( $l , $r ) $e = Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & $l & '"' ) ConsoleWrite( "!Run: "& $e & @CRLF ) MsgBox(0, $e, $a ) Exit Func _CallMeFunction( $a=1, $b=2, $c=3, $externalCall=True ) If $externalCall = True Then MsgBox(0, "external", "call - running in its own script " & $a & $b & $c ) ElseIf $externalCall = False Then MsgBox(0, "internal", "call - running in the main script " & $a & $b & $c ) EndIf Return 1 EndFunc I tried to describe the problem with this. I want programm A Programm A has a lot of functionality, some of the functionality actually need quite some time to complete and meanwhile programm A is unusable. But Programm A has do be interactable all the time - because it some sort of template editor/manager, when i press F2 it sends a template with ctrl+v or f3 another one or f4 another one. Also is has to be able to load a website and extract its data and display the data for me <- while it is doing this, I'm unable to use the programm Also it has to navigate on the website (like for example) in a new tab WHILE its extracting data from another tab and has to do some tasks there AND while it is doing that i need still be able to press F2,F3,F4 OR use the entire GUI. The problem i have right now is, i have tool A (hotkeys) tool B (extracting) tool C (doing functionality on a website) tool D,E,F etc. - actually its really a lot of functionality and its REALY uncomfortable to start 15 exe files each time i boot the pc or if one is crashing restart it. AND its also realy uncomfortable to create the script in an "COPROCESS" unit like : $test_string = 'Func _CallMeFunction( $a=1, $b=2, $c=3, $externalCall=False )' & @CRLF & _ 'If ($externalCall = True) Then' & @CRLF & _ 'MsgBox(0, "external", "call - running in its own script " & $a & $b & $c )' & @CRLF & _ 'ElseIf ($externalCall = False) Then' & @CRLF & _ 'MsgBox(0, "internal", "call - running in the main script " & $a & $b & $c )' & @CRLF & _ 'EndIf' & @CRLF & _ 'Return 1' & @CRLF & _ 'EndFunc' & @CRLF & _ '_CallMeFunction()' Because i MAY have to align the code quickly and/ or change a lot of lines and test them,. This is also in no way comfortable. So what I'm trying to do - I want to create one tool which merges ALL the functionality into itself and then i want a function like: _getFuncToFileAndRun( @autoitexe, $funcname, $nParam, $paramdelim='|') Then this function should extract the current and actuall function in my code with every code change and write it into TEMP_AU3.au3 and start it with /autoit3executescript The difference between all coprocess i know so far - is the calling of the function! I do not want to hardcore the function into an function call - i want the function to extract the requested function out of the programm itself dynamically and then use it to run the function in a newly created .au3 script. I would also be down to decompile the script on the fly, parse the source - get the function and delete the decompiled source - but i dont even know if this is possible I would also accept the #save_source parameter for this to work - this is no question of having open/visible source as i want to use this in my company for work efficiency. I don't even want fully functional code, just a small push in the right direction :(... (I also have some sort of garbage collector in mind which watches the actuall processes and cleans up the temp files.) actually while writing this, i realize i could just let the compiled exe file in the source directory and then wildly call the available includes. - but honestly this would be the last option i would like to choose, as it feels dirty even thinking in this direction. Edited May 24, 2019 by Busti My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
BrewManNH Posted May 24, 2019 Share Posted May 24, 2019 You can't create a self-updating script while it is running, you'd have to stop the script, and then restart it with the new code. You can't do this on an executable, it could only work as a script. You COULD put your code in a separate file, create an A3X file, restart your script that includes the a3x file and it will read the new code in that file. But you'd have to restart the script to do it, and it could be done using an exe and not just a script. Another conundrum you're going to run into is what kind of changes are you making to the updated function and will the old code that calls it still run as expected. I can only see a disaster in the making if the new code fundamentally alters the script functionality and you have no way to program that into the main program. I personally think it's a terrible idea, and bound to cause more problems than you think you're solving with this attempt. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Busti Posted May 24, 2019 Author Share Posted May 24, 2019 2 hours ago, BrewManNH said: That's getting dangerously close to decompiling the script. The reason you can't call a function from memory in another script to yours is that the function has to exist in the first script or it won't be recognized, you can't create phantom functions in a script by pulling them in from elsewhere. The calling script has to know that the function exists, and has to know where in the script this function is, at runtime, so if it's not there when the script starts, the interpreter doesn't know about it. decompiling my own script on the runtime would be an solution too which i would accept if there is no other solution. i would also work with the #save_source parameter if theres no other way to accomplish this .... and thank you for the explanation. but just another question, if i copy 1:1 the memory from the beginning to the function to the end of the function, then why couldn't i call the function ? cause i give the programm the information what to do and as i know which function it is, why shouldnt i been able to pass the correct call with the correct (new) address to the newly created temporary script? My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
Busti Posted May 24, 2019 Author Share Posted May 24, 2019 4 minutes ago, BrewManNH said: You can't create a self-updating script while it is running, you'd have to stop the script, and then restart it with the new code. You can't do this on an executable, it could only work as a script. You COULD put your code in a separate file, create an A3X file, restart your script that includes the a3x file and it will read the new code in that file. But you'd have to restart the script to do it, and it could be done using an exe and not just a script. Another conundrum you're going to run into is what kind of changes are you making to the updated function and will the old code that calls it still run as expected. I can only see a disaster in the making if the new code fundamentally alters the script functionality and you have no way to program that into the main program. I personally think it's a terrible idea, and bound to cause more problems than you think you're solving with this attempt. The updated function should not be changed in the runtime! i only want to edit the main tool and all of its functionality while it is not running. But i want to edit the functions in the text editor as real functions and not in a string variable which i pass to the programm My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
BrewManNH Posted May 24, 2019 Share Posted May 24, 2019 You just aren't reading or comprehending what is told to you. I'm out of this stupid conversation, you will never accept the FACT that this can't be done in AutoIt and will never be able to be done. Earthshine 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Earthshine Posted May 25, 2019 Share Posted May 25, 2019 (edited) As mentioned numerous times above this isn’t possible so you should just drop it and move on. Plus there is no good reason to do this anyway Edited May 25, 2019 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
junkew Posted May 25, 2019 Share Posted May 25, 2019 So make one exe with all functionality and based on parameter it can start itself and call the function you indicate by parameter. You are having focus to much on your solution instead of detailing requirements. This way its hard to give you a good direction on a solution. Same exe starting many times from itself calling another function shouldnt be that difficult. Earthshine and Busti 2 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Busti Posted May 28, 2019 Author Share Posted May 28, 2019 On 5/25/2019 at 4:13 PM, junkew said: So make one exe with all functionality and based on parameter it can start itself and call the function you indicate by parameter. You are having focus to much on your solution instead of detailing requirements. This way its hard to give you a good direction on a solution. Same exe starting many times from itself calling another function shouldnt be that difficult. That sounds kinda good, thank you. Didnt think about making the same exe "multiusable" with parameters. Great Idea. My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity Link to comment Share on other sites More sharing options...
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