Jump to content

Trying to add extensions to my script. Aka: Dynamic Menu Items. Is there anything that can do it?


Recommended Posts

Hey, I'm trying to add 'extensions' to my script. I have a GUI Menu with buttons and a current core coding to it, but wondering if it was possible to allow people to download an extension for the program. They would download a file, it would add it to the program folder or something.

Then my script would check the folder for the extension files, if found, it would add the program code to the list (I was thinking adding more buttons to click on in my GUI Menu".

Is this possible? Thanks alot.

ps: I read about something called a3x, but I'm not sure what that does. Is th

Link to comment
Share on other sites

Right now I think the best way is to include a3x files..,

I'm trying to dynamically find the extensions and then include them, but Autoit won't let me compile it.

$sFilter = "*.a3x"
$ExtList=_FileListToArray("C:\Users\CrewXp\Documents\Programming\autoit\myKit\Extensions", $sFilter)
For $i = 1 to $ExtList[0] Step 1
$extension="C:\Users\CrewXp\Documents\Programming\autoit\myKit\Extensions"&$ExtList[$i]
;Msgbox(0,"",$extension)
#Include $extension
    Next

I'm probably doing something stupid, but yeah.

I'm getting...

==> Cannot parse #include.:
Edited by CrewXp
Link to comment
Share on other sites

Hmm.. a great idea.

i have no idea whether or not the .a3x file is what are you actually after.. but as for the addition of an extension.. perhaps an ini file instead?

might be a little quicker to parse an ini file than it is to filter an entire directory.. and it also lets users have an extension sitting in the folder but not enabled, this way if it malfunctions they can just comment it in the ini file and restart the app, instead of deleting the extension.

Link to comment
Share on other sites

yeah, that'd probably be the easiest way to do it. It's how I did simpler things int he past. But I want to learn more about a3x files.

And I also need to have the source closed because it'll contain login info to some of my servers.

Link to comment
Share on other sites

#include cannot be dynamic. The compiler does not run your script when it compiles it, otherwise how would a script like the following compile?

$input = InputBox('Enter Include File', 'Path to include')
#include $input

a3x files act just like compiled scripts except they can't run themselves, so they can't be included.

Also,

And I also need to have the source closed because it'll contain login info to some of my servers.

Not a good idea. At all. Right now there's no way to keep the source for your AutoIt scripts completely closed, just look around on the forum and you'll see a few people talk about how easy it is to decompile, or otherwise read the source to any compiled script. It is not that secure, as mentioned in the help file, so I wouldn't be putting crucial, private, information in any AutoIt script right now, compiled, a3x'd, or otherwise.
Link to comment
Share on other sites

Not a good idea. At all. Right now there's no way to keep the source for your AutoIt scripts completely closed, just look around on the forum and you'll see a few people talk about how easy it is to decompile, or otherwise read the source to any compiled script. It is not that secure, as mentioned in the help file, so I wouldn't be putting crucial, private, information in any AutoIt script right now, compiled, a3x'd, or otherwise.

Yeah, Well I know that. It's just being used in a controlled place. Aka: People I know. They aren't really computer-literate people, so I doubt they'll know I used autoit or even know what that is, and actually try to decompile it. so that's why I'm making this program, to simplicate things for them.

Any ideas on this though?

Link to comment
Share on other sites

okay, so I'm guessing a3x is not the way to go.

Right now I'm thinking the only possible way to do it the way I would like to is to include aut2Exe somehow in my program. And then it could recompile the program on-the-fly with the new features...

But is there any way to run Aut2Exe via a command-line?

Ah!! if anyone can think of another way to do this, please let me know.

Thanks alot.

Link to comment
Share on other sites

  • Moderators

okay, so I'm guessing a3x is not the way to go.

Right now I'm thinking the only possible way to do it the way I would like to is to include aut2Exe somehow in my program. And then it could recompile the program on-the-fly with the new features...

But is there any way to run Aut2Exe via a command-line?

Ah!! if anyone can think of another way to do this, please let me know.

Thanks alot.

Why not just use the advice given, and keep an updated list in a file or ini? I mean, it would be much easier to encrypt the data in those files, then decrypt before reading (or after) then to have an exe keep re-writing itself, and having to include something to do so.

The other side to your question is that files can be ran from within a simple Autoit executable without the need to send AutoIt along with it, by using /AutoIt3ExecuteLine or /AutoIt3ExecuteScript if those files are in regular autoit syntax/and text format.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Why not just use the advice given, and keep an updated list in a file or ini? I mean, it would be much easier to encrypt the data in those files, then decrypt before reading (or after) then to have an exe keep re-writing itself, and having to include something to do so.

Awesome smokes. Yeah, I never put in the fact that a regular file (probably best way to do it) could be encrypted. But this now leaves me to 2 questions..

1.) If I can't include a compiled autoit script, is there any way to still add autoit code to the program..outside it? I know I have to use a file, but hwo can autoit execute a function inside the file?

2.) Can you provide an example or a link to something that might help me in the right direction of decrypting the file inside the script?

-Thanks again.

Link to comment
Share on other sites

  • Moderators

Awesome smokes. Yeah, I never put in the fact that a regular file (probably best way to do it) could be encrypted. But this now leaves me to 2 questions..

1.) If I can't include a compiled autoit script, is there any way to still add autoit code to the program..outside it? I know I have to use a file, but hwo can autoit execute a function inside the file?

2.) Can you provide an example or a link to something that might help me in the right direction of decrypting the file inside the script?

-Thanks again.

Sure:
;Example - Writing a file because yours doesn't exist yet
$sTextWrite = 'While 1' & @CRLF & _
    "If MsgBox(36, 'Quit?', 'Would you like to quit?') = 6 Then Exit" & @CRLF & _
    'WEnd'
If Not FileExists(@ScriptDir & '\ExampleAU3Execute.txt') Then 
    FileClose(FileOpen(@ScriptDir & '\ExampleAU3Execute.txt', 2))
    FileWrite(@ScriptDir & '\ExampleAU3Execute.txt', $sTextWrite)
EndIf
;Done with Pre-Pend, this would normally be a FileInstall() more than likely, or you could create it dynamically from within your script itself.

;Example of how your script would do it.

While 1
    If MsgBox(36, 'Run', 'Would you like to run the text file?') = 6 Then
        Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptDir & '\ExampleAU3Execute.txt"');Running External Text File
    Else
        Exit
    EndIf
WEnd

Edit:

Forgot to close the file.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Or if you'd like the original file to be encrypted... but obviously it can't be ran encrypted... you could try this (keep in mind, you had better hope it doesn't take much memory)

;Example - Writing a file because yours doesn't exist yet
$sTextWrite = 'While 1' & @CRLF & _
    "If MsgBox(36, 'Quit?', 'Would you like to quit?') = 6 Then Exit" & @CRLF & _
    'WEnd'
If Not FileExists(@ScriptDir & '\ExampleAU3Execute2.txt') Then 
    FileClose(FileOpen(@ScriptDir & '\ExampleAU3Execute2.txt', 2))
    FileWrite(@ScriptDir & '\ExampleAU3Execute2.txt', _RC4EncDec($sTextWrite, 'password'))
EndIf
;Done with Pre-Pend

;Example of how your script would do it.

While 1
    If MsgBox(36, 'Run', 'Would you like to run the text file?') = 6 Then
        Local $aTempFile = @TempDir & '\encrypted.txt'
        FileClose(FileOpen($aTempFile, 2))
        FileWrite($aTempFile, _RC4EncDec(FileRead(@ScriptDir & '\ExampleAU3Execute2.txt'), 'password'))
        Local $iPID = Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $aTempFile & '"');Running External Text File
        ProcessWait($iPID)
        Sleep(500)
        FileDelete($aTempFile)
    Else
        Exit
    EndIf
WEnd

Func _RC4EncDec($sData, $sKey)
    If $sData = '' Or $sKey = '' Then Return ''
    Local $aState[256], $nKeyLength = StringLen($sKey), $nDataLength = StringLen($sData)
    Local $sMid, $iIndex, $xCC = 0, $yCC = 0, $sResult = '', $sSwap
    For $iCC = 0 To 255
        $aState[$iCC] = $iCC
    Next
    For $iCC = 0 To 255
        $sMid = StringMid($sKey, Mod($iCC, $nKeyLength) + 1, 1)
        $iIndex = Mod(Asc($sMid) + $aState[$iCC] + $iIndex, 256)
        $sSwap = $aState[$iCC]
        $aState[$iCC] = $aState[$iIndex]
        $aState[$iIndex] = $sSwap
    Next
    For $iCC = 1 To $nDataLength
        $xCC = Mod($xCC + 1, 256)
        $yCC = Mod($aState[$xCC] + $yCC, 256)
        $sSwap = $aState[$xCC]
        $aState[$xCC] = $aState[$yCC]
        $aState[$yCC] = $sSwap
        $iIndex = Mod($aState[$xCC] + $aState[$yCC], 256)
        $sMid = BitXOR(Asc(StringMid($sData, $iCC, 1)), $aState[$iIndex])
        $sResult &= Chr($sMid)
    Next
    Return SetError(@error, @extended, $sResult)
EndFunc

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...