Jump to content

Read User Scripts


drizzlx
 Share

Recommended Posts

Let's say i'm making an uninstall program (example). I want to allow the user to create their own script in a .txt and let the program execute it for them. How is this possible? Will variables (commands) be pre-defined within the code? Any examples on this?

Link to comment
Share on other sites

I'm a little confused by what exactly you are trying to ask. What do you mean by "variables (commands)"? Variables and command are not the same thing. And how does this relate to an uninstall program?

I *think* you are asking if your AutoIt script (script1) can run another AutoIt script (script2) which is contained within a text file. Probably the easiest way to achieve this would be to have script1 run the Aut2Exe program on script2, and then run the newly generated executable.

But if the user is going to go to all the trouble of writing an AutoIt script, why do they need your script to run it for them when they could just do it themselves?

Edited by sdraw107
Link to comment
Share on other sites

I think you will be looking in the Help File for >> INI Management & creating some simple Syntax :) I would also look at EnvSet() / EnvGet() if you want to set Environment Variables in the INI File e.g. C:\Program File\%PROGRAMNAME%\TheEXE.exe >> EnvSet("ProgramName", "My Program")

INI File - They create an INI File like this..

ProgramName=My Program ; Environment Variable
FileDelete1=C:\Program File\%ProgramName%\TheEXE.exe
FileDelete1=C:\Program File\%ProgramName%\Settings.cfg
RegDelete1=HKLM\....

And you then using the INI Management tools (INIRead() / INISectionRead()) to loop through the INI Deleting, Moving or whatever you want to do! Good Luck.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Moderators

You can use any AutoIt executable you have, and use the \AutoIt3ExecuteScript command line.

This way I can let the user write their script ( in AutoIt of course ), and do something like:

Global $gs_textfile = "UsersInputAu3Code.txt"
Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $gs_textfile & '"')

More info can be found in your help file:

Contents -> AutoIt -> Using AutoIt -> Command Line Parameters ( On Page: AutoIt specific command Line Switches )

Edit:

Guess I could simplify it a bit:

Global $gs_textfile = "UsersInputAu3Code.txt"
_RunAu3($gs_textfile)


; Run au3 file simple udfs
Func _RunAu3($s_au3file, $s_workingdir = "", $i_showflag = @SW_SHOW, $i_optflag = 0)
    Local $s_runparam = '"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $s_au3file & '"'
    Return Run($s_runparam, $s_workingdir, $i_showflag, $i_optflag)
EndFunc

Func _RunWaitAu3($s_au3file, $s_workingdir = "", $i_showflag = @SW_SHOW, $i_optflag = 0)
    Local $s_runparam = '"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $s_au3file & '"'
    Local $i_exitcode = RunWait($s_runparam, $s_workingdir, $i_showflag, $i_optflag)
    If @error Then Return SetError(@error, 0, 0)
    Return $i_exitcode
EndFunc
Edited by SmOke_N
Fixed execution string

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

I couldn't think of any good program examples. I'll try explaining again. I want to make a program that will execute a macro written in a .txt file. The macro will not be in autoit language. I would like to create functions within my program that the user can use to make a macro and save it to a .txt file and execute that .txt file using my program.

To sum it all up, my program will allow a user to create user-friendly instructions for my program to execute.

Sorry for the confusion.

Thanks!

Edited by drizzlx
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...