ptrex Posted January 15, 2007 Share Posted January 15, 2007 Hy guys, I am working on getting some UDF's translating to COM objects : AU3 to COM using WSCEverything is working realy great. But the only thing I need to accomplish is calling a single funtion from outside a compiled EXE or a AU3 script.I have been testing the C:\Progra~1\AutoIt3\AutoIt3.exe /AutoIt3ExecuteScript and /AutoIt3ExecuteLine,in combination with the functions CALL() and EXECUTE().But no success.Can this be achieved and if so how. Or is there an other way of doing this.This is the only thing that keeps me from making everything complete and ready to roll.Thanksregards,ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
jpm Posted January 15, 2007 Share Posted January 15, 2007 Hy guys, I am working on getting some UDF's translating to COM objects : AU3 to COM using WSCEverything is working realy great. But the only thing I need to accomplish is calling a single funtion from outside a compiled EXE or a AU3 script.I have been testing the C:\Progra~1\AutoIt3\AutoIt3.exe /AutoIt3ExecuteScript and /AutoIt3ExecuteLine,in combination with the functions CALL() and EXECUTE().But no success.Can this be achieved and if so how. Or is there an other way of doing this.This is the only thing that keeps me from making everything complete and ready to roll.Thanksregards,ptrexI am not sure to understand what's you get wrong.Post example of waht you try to do.Using those /Autoit3... will not insure you get back a variable return by the function, you just get the return value from AutoIt3.exe Link to comment Share on other sites More sharing options...
ptrex Posted January 15, 2007 Author Share Posted January 15, 2007 @JpmIf you follow the instruction here Test scriptYou will see what I mean.I am converting a UDF function to a COM object. This COM object passed Variable values to a AU3 script. This AU3 script then returns the values to the COM object as callback values.Everything works as expected, the only drawback is that I can only trigger a AU3 script as a whole, which means that it runs all the Functions included in the AU3 or EXE (if compiled).I need to find a way to trigger only 1 Function in the AU3 or EXE, instead of running everything.Thanks Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
jpm Posted January 15, 2007 Share Posted January 15, 2007 If the number of function to be called is well defined and their parameter you can use Call and inside the function a big swith according to the functions to be call. EXECUTE will not work as Com are forbidden as stated in the doc to avoid easy malware script development. if you go with and spwan AutoiT3.exe you need a client/server communication to send parameter and get back the returns values. I am not sure that's answer your question. That's all I have in mind for now Link to comment Share on other sites More sharing options...
ptrex Posted January 15, 2007 Author Share Posted January 15, 2007 @Jpm when I run this "C:\Progra~1\AutoIt3\Finance.exe /AutoIt3ExecuteLine "Call("_PV", 1000,3,24)" To call a function in an compiled EXE with parameters, nothing happens. Can you give me an example on how to ? Thanks ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Valik Posted January 15, 2007 Share Posted January 15, 2007 You can't do anything of the sort. What JP said is you need to write the script like normal except the only thing the script does when you run it is take it's command line parameters and Call() a function. For a simple example: Main() Func Main() If $CmdLine[0] Then Call($CmdLine[1]) EndIf EndFunc Func Test1() MsgBox(0, "", "You called Test1()") EndFunc Func Test2() MsgBox(0, "", "You called Test2()") EndFunc Compile that script and then invoke it as "Script.exe Test1" or "Script.exe Test2". The embedded script is not looked at when you use /AutoIt3ExecuteScript or /AutoIt3ExecuteLine. It makes no sense to look at the embedded script, either, since the idea of both of those features is to provide the runtime engine with a new script to use in place of the embedded script. Link to comment Share on other sites More sharing options...
ptrex Posted January 15, 2007 Author Share Posted January 15, 2007 @Valik Thanks for clarifying. It' s a pitty, because there is lot's of potential going down the drain this way !! So I have to be more creative now to find an alternative solution, for the COM objects to call AU3 Functions. One way to do it probably is to sent along with the COM properties and extra property as an identifier for which function to call. It's all messy this way but that's the only way I can see it happening for the time being. Any other creative thougts are welcome. regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
jpm Posted January 15, 2007 Share Posted January 15, 2007 @Jpmwhen I run this "C:\Progra~1\AutoIt3\Finance.exe /AutoIt3ExecuteLine "Call("_PV", 1000,3,24)"To call a function in an compiled EXE with parameters, nothing happens.Can you give me an example on how to ?ThanksptrexThat could not work as the function _PV cannot part of the scriptline. Remember you are trying to execute a single script line. Link to comment Share on other sites More sharing options...
Valik Posted January 15, 2007 Share Posted January 15, 2007 ptrex, you wouldn't want the embedded script accessible when using /AutoIt3ExecuteScript. JP already covered why it doesn't work with /AutoIt3ExecuteLine. Now imagine if the embedded script was accessible when using /AutoIt3ExecuteScript, you'd almost always get "function already defined" errors because the embedded script would have library functions and so would the script you're trying to run. For any non-trivial script, these would clash and the script wouldn't work. The functionality you're looking for would be better suited as an extension to the a3x format. It would be pretty neat if a3x files were like AutoIt-DLLs in that they have an export table and AutoIt can call exported functions. Then what you want would be possible. However, there are currently no plans to do this. Link to comment Share on other sites More sharing options...
ptrex Posted January 15, 2007 Author Share Posted January 15, 2007 @Valik/Jpm Thanks both for the feedback !! I will let you all know the workaround after I tested it. Keep watching the COM without the DLL thread. See you all around. Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
sohfeyr Posted January 20, 2007 Share Posted January 20, 2007 The functionality you're looking for would be better suited as an extension to the a3x format. It would be pretty neat if a3x files were like AutoIt-DLLs in that they have an export table and AutoIt can call exported functions. Then what you want would be possible. However, there are currently no plans to do this.Valik, could you please describe the obstacles involved? It's a design consideration that puzzles me anew every time I do something in AutoIt, and I'd love to hear your take on it from a technical perspective. Being nowhere near your level of expertise, I can't pretend to be able to do anything with the information except learn - but I like to think that's a noble enough goal? At the same time, I realize this may come close to some of your "top-secret" code (like how you get around restricted memory, the compiler of course, and possibly even the DLLCall secrets) so if there are security issues involved... well, I'll be disappointed, but I'll understand. Probably the most profound thing I've learned from these forums is how many people are out there wanting to use good ideas for bad purposes. Mine:Time Functions - Manipulate the system clock! | WinControlList (WinGetClassList++) | .Net Setup Wrapper, Detect or install .Net | Writing and using a VB .NET COM object in AutoItNot mine, but highly recommended:AutoItTreeViewExtension plugin | Menu code | Callback helper dll | Auto3Lib - Control the uncontrollable | Creating COM objects in AutoIt | Using .Net framework classes in AutoIt Link to comment Share on other sites More sharing options...
Valik Posted January 20, 2007 Share Posted January 20, 2007 Obstacles involved with what? Making a3x behave sort of like DLLs? Link to comment Share on other sites More sharing options...
sohfeyr Posted January 21, 2007 Share Posted January 21, 2007 Obstacles involved with what? Making a3x behave sort of like DLLs?Short answer: YesLong answer: Yes, please Uninformed alternative track that might have a similar effect, or at least lead to some interesting ideas: Another possibily that occurred to me was a UDF solution similar to what Outshynd and WSCPorts are doing here, except instead of targeting an external process the program would target itself using @AutoItPID or AutoItWinSetTitle() and WinGetHandle(). The code in your EXE could have directives to inject the A3x into the tokenized code portion of that same executable while it is running. (Think "The Blob".) Of course, I probably just demonstrated an enormous lack of comprehension about what exactly it is they are doing, how DLLs work, how compiled AU3 scripts are represented in memory, what exactly the AutoIt compiler does, the relationship between the AutoIt.lib and the rest of the file... Mine:Time Functions - Manipulate the system clock! | WinControlList (WinGetClassList++) | .Net Setup Wrapper, Detect or install .Net | Writing and using a VB .NET COM object in AutoItNot mine, but highly recommended:AutoItTreeViewExtension plugin | Menu code | Callback helper dll | Auto3Lib - Control the uncontrollable | Creating COM objects in AutoIt | Using .Net framework classes in AutoIt Link to comment Share on other sites More sharing options...
Valik Posted January 21, 2007 Share Posted January 21, 2007 There aren't really any difficult obstacles. It's just a matter of doing it. It's not trivial work, it would take some time to implement, but as far as I can see, there aren't any technical obstacles. It should be no more work than creating a well-described file format to hold an export table and the AutoIt script. The compiler would need modified some to create the export table and the run-time engine would need to know how to parse the exports to find the functions. But it's all just a matter of somebody doing it as opposed to any real obstacle. Link to comment Share on other sites More sharing options...
sohfeyr Posted January 21, 2007 Share Posted January 21, 2007 There aren't really any difficult obstacles. It's just a matter of doing it. It's not trivial work, it would take some time to implement, but as far as I can see, there aren't any technical obstacles. It should be no more work than creating a well-described file format to hold an export table and the AutoIt script. The compiler would need modified some to create the export table and the run-time engine would need to know how to parse the exports to find the functions. But it's all just a matter of somebody doing it as opposed to any real obstacle.Thanks, it's nice to know what is involved... even without obstacles, I wouldn't expect it to be "trivial" work. I also appreciate that you don't like to make changes to the code except as bug fixes, and the compiler and runtime engine sound like dangerous places to operate - stuff breaks, after all. Is there any chance of that other idea working, or being modified in some way to work - sort of an in-memory variation of #include? Mine:Time Functions - Manipulate the system clock! | WinControlList (WinGetClassList++) | .Net Setup Wrapper, Detect or install .Net | Writing and using a VB .NET COM object in AutoItNot mine, but highly recommended:AutoItTreeViewExtension plugin | Menu code | Callback helper dll | Auto3Lib - Control the uncontrollable | Creating COM objects in AutoIt | Using .Net framework classes in AutoIt Link to comment Share on other sites More sharing options...
Valik Posted January 21, 2007 Share Posted January 21, 2007 It's not really practical. There's no safe way to handle symbol clashes which would be very likely with such a method. It would be an easier scenario to handle in an export-style situation. Link to comment Share on other sites More sharing options...
sohfeyr Posted January 22, 2007 Share Posted January 22, 2007 It's not really practical. There's no safe way to handle symbol clashes which would be very likely with such a method. It would be an easier scenario to handle in an export-style situation.That's certainly true. Guess we have to wait for a developer to get interested enough and find time to do it, after all. I do have another idea for how to expose the functionality of one script to another so that it acts like a library. Do you know of a way to have two scripts interacting with the same COM object at the same time? I've been pondering using ptrex's method of setting up a Windows Scripting Component and GUISetState() with a hidden window. The various functions in that library could get invoked using ObjEvent... except I can't figure out how to share a reference to such an object from another script to fire said events. What is the nature of the value returned by ObjCreate(), and is there any possible way to do what I'm talking about with the current build of AutoIt?(Yes I know this isn't the help forum, but as long as we're talking implementation maybe one or the other of us can come up with a way that is pragmatically similar to what has been previously discussed here. If you think it's too far off-topic I'll happily repost elsewhere.) Mine:Time Functions - Manipulate the system clock! | WinControlList (WinGetClassList++) | .Net Setup Wrapper, Detect or install .Net | Writing and using a VB .NET COM object in AutoItNot mine, but highly recommended:AutoItTreeViewExtension plugin | Menu code | Callback helper dll | Auto3Lib - Control the uncontrollable | Creating COM objects in AutoIt | Using .Net framework classes in AutoIt Link to comment Share on other sites More sharing options...
Valik Posted January 22, 2007 Share Posted January 22, 2007 That has nothing to do with AutoIt. Whether or not two references resolve to the same COM object is an implementation detail of the COM object itself. Link to comment Share on other sites More sharing options...
sohfeyr Posted January 22, 2007 Share Posted January 22, 2007 (edited) That has nothing to do with AutoIt. Whether or not two references resolve to the same COM object is an implementation detail of the COM object itself.Thanks! now I know on which side of the implementation to focus the research. It may not be as clean as having exported functions, but being able to wrap a script in a COM object could be very powerful, and for many purposes just as good. Edited January 22, 2007 by sohfeyr Mine:Time Functions - Manipulate the system clock! | WinControlList (WinGetClassList++) | .Net Setup Wrapper, Detect or install .Net | Writing and using a VB .NET COM object in AutoItNot mine, but highly recommended:AutoItTreeViewExtension plugin | Menu code | Callback helper dll | Auto3Lib - Control the uncontrollable | Creating COM objects in AutoIt | Using .Net framework classes in AutoIt Link to comment Share on other sites More sharing options...
ptrex Posted January 22, 2007 Author Share Posted January 22, 2007 @sohfeyrGlad to see that you didn't give up yet !!I do have another idea for how to expose the functionality of one script to another so that it acts like a libraryIf you got something going, keep us up to date.My method is stuck using the wrapper function as shown is my post 55 of Creating COM objects without a need of DLL'sWhich works, the COM object sends that data between the 2 scripts. It might not look practicle, but at the end it does what it needs to do.Regardsptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Recommended Posts