Jump to content

Execute External code with current variables.


Recommended Posts

The Question.

I have the need to execute external autoit code in a file that a user can define but it would need to know the variables currently being used in the main program.

Why?

Cause the program im making has the need to be able to have plugins and i have kind of figured out how to run simple code with no loops but that's not enough will i have to do some more into it code or is there a simpler way?

Another idea.

I could essentially read the file and start using execute on lines if it doesn't contain "do,while,if" or if it does then loop or do an if command and wait for "until,wend,else,elseif,endif" but the question is, is there a better way?

Edited by MerkurAlex

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Link to comment
Share on other sites

The Question.

I have the need to execute external autoit code in a file that a user can define but it would need to know the variables currently being used in the main program.

Why?

Cause the program im making has the need to be able to have plugins and i have kind of figured out how to run simple code with no loops but that's not enough will i have to do some more into it code or is there a simpler way?

Another idea.

I could essentially read the file and start using execute on lines if it doesn't contain "do,while,if" or if it does then loop or do an if command and wait for "until,wend,else,elseif,endif" but the question is, is there a better way?

Execute? #Include?

Edited by KentonBomb
Link to comment
Share on other sites

Execute? #Include?

No my program will already be compiled removing the usability to re-include a file cause i would have to recompile the idea is to have people be able to write plugins that i will call in my already compiled program.

If this is not the answer you were looking for maybe you mean the execute function?

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Link to comment
Share on other sites

No my program will already be compiled removing the usability to re-include a file cause i would have to recompile the idea is to have people be able to write plugins that i will call in my already compiled program.

If this is not the answer you were looking for maybe you mean the execute function?

...

Are you talking to yourself? You just answered your own question :)

Link to comment
Share on other sites

...

Are you talking to yourself? You just answered your own question :)

Wow no offense to you but you must have missed the fact that i mentioned i could in theory do this but how would it work with loops without modification the same for if statements i clearly mentioned in my first post i'm trying to figure out if there is an easier way to do this.

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Link to comment
Share on other sites

Scan a directory with plugins using _FileListToArray, and just dynamically Execute() for each file found.

Go try that yourself with a loop or if statement in one of the plugins see what happens I am not a moron I have tried everything I can think of except for programming specific checks and code executes for loops and if statements witch i will do if required I am simply asking "is there an easier way?"

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Link to comment
Share on other sites

Look at this thread. I posted an example there. And maybe this can be useful too.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Look at this thread. I posted an example there. And maybe this can be useful too.

Thanks for the refrences but as those will allow loops they will not share variables so as far as i can tell im just gonna write a plugin function that will run the execute function on each line and do special code for loops and if's.

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Link to comment
Share on other sites

Thanks for the refrences but as those will allow loops they will not share variables so as far as i can tell im just gonna write a plugin function that will run the execute function on each line and do special code for loops and if's.

Or you could do what I suggested in the first place, just replacing Execute with Autoit's /Autoti3ExecuteScript (Which works compiled, even without Autoit installed.)

#Include <File.au3>
#Include <Array.au3>
Global $sPluginsDir = @ScriptDir & "\Plugins"
$azFiles = _FileListToArray($sPluginsDir)
;~ If Not IsArray($azFiles) Or Not FileExists($sPluginsDir) Then
;~  MsgBox(0, "Error", "No plugin files found")
;~ EndIf
For $i = 1 to $azFiles[0]
    Run(@AutoItExe & '  /Autoit3ExecuteScript "' & $sPluginsDir & "\" & $azFiles[$i] & '"')
Next

EDIT: Sharing variables could be done by ConsoleWrite'ing and Reading by the other script. Or it could be done by TCP (Transferring data to the localhost via an unused port)

Edited by KentonBomb
Link to comment
Share on other sites

Or you could do what I suggested in the first place, just replacing Execute with Autoit's /Autoti3ExecuteScript (Which works compiled, even without Autoit installed.)

#Include <File.au3>
#Include <Array.au3>
Global $sPluginsDir = @ScriptDir & "\Plugins"
$azFiles = _FileListToArray($sPluginsDir)
;~ If Not IsArray($azFiles) Or Not FileExists($sPluginsDir) Then
;~  MsgBox(0, "Error", "No plugin files found")
;~ EndIf
For $i = 1 to $azFiles[0]
    Run(@AutoItExe & '  /Autoit3ExecuteScript "' & $sPluginsDir & "\" & $azFiles[$i] & '"')
Next

EDIT: Sharing variables could be done by ConsoleWrite'ing and Reading by the other script. Or it could be done by TCP (Transferring data to the localhost via an unused port)

Or i could say i already knew that i could do this but it wouldn't be the ideal way all that code is very simple to me the idea of this question was a simpler way that may essentially be simpler to most people but for what im doing it is not so thanks for trying to help both of you but as i said im going to write a plugin function.

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Link to comment
Share on other sites

  • 1 month later...

MerkurAlex,

I am trying to do the exact same thing as you in my current software. #include, Execute(), FileReadLine() and so on all have a critical limitation that makes this task impossible with simple/short code.

I noticed this recently, since then I have started writting my own UDF which can read or load any data within an archive - including au3 script files - and acts just like the #include function - only it 1) won't try to #include the script file at compilation, hence allowing to "include [variable]" and 2) has 100% working functionality just like the #include function in regards to variables and hwnd's and such...

...basically it is an 'on-demand include', unlike the stock #include which directly compiles the included library before compilation [this will do it upon interpritation instead]

It will support data-files within UHA archives [like ZIP or RaR, but non-commercial and GREAT compression] and so you can compile your 'plugins' with a standard UHA archiver such as WinUHA, add a complex password to it, and my UDF will dynamically load data from within this file WITHOUT extracting to disk... anyway just keep an eye on the Example Scripts forum and it should come up soon ;)

Peace

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...