Sign in to follow this  
Followers 0
UnKnOwned

Storing Autoit code inside a variable.

8 posts in this topic

This may seem a rather silly question, and am not quite sure what to even ask, but can you store Autoit it code inside a variable and execute it later?

Something like

$val = msgbox(0, '', 'Hello')

$val ------ execute it here or something...

Is there a way to do this?

Thank you in advance.

Share this post


Link to post
Share on other sites



Execute will get you any expression's value, for assigning any value to a variable use Assign, Execute won't work there.

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It's not better tu use a Func?

Func Msg()
msgbox(0, '', 'Hello')
EndFunc
; Blabla
Msg() ; --> Start hello MsgBox
Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Share this post


Link to post
Share on other sites

This example stores an Autoit MsgBox command code inside a variable and executes it later.

Local $Ret, $aMsgRetVal[8] = [8, "OK", "CANCEL", "ABORT", "RETRY", "IGNORE", "YES", "NO"]

Local $val = "MsgBox(2, 'MsgBox inside variable', 'Hello')"

$Ret = Execute($val)

MsgBox(0, "Execute($val) returned", $Ret & " is returned for " & $aMsgRetVal[$Ret] & ".")

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

$val = "MsgBox(0, '', 'Hello')"
Run(@AutoItExe & ' /AutoIt3ExecuteLine "' & $val & '"')

The above seems to work similar to Execute() however with a multi line expression the same problem still ensues when trying to run

6D7367626F7828302C2027272C202748656C6C6F27290D0A6D7367626F7828302C2027272C2027576F726C642729

Which is =to

msgbox(0, '', 'Hello')
msgbox(0, '', 'World')

Executing in this manner never works as the expression is trying to be passed as a whole instead of through a loop.?. We then end up with the following error.

post-79464-0-15322600-1367169768_thumb.p

The binary string is retrieved from the registry converted back to a string & then needs to be executed as is without the need of a temp file dump. Unless there is a way to /Auto3ExecuteScript file or whatever it is without a file but rather a variable perhaps? I guess if it is needed to create a temp file then oh well but this defeats the whole purpose.

My apologies had to edit as this topic is in reference to another question I had asked. Hopefully this will help to better understand what is I am looking to do.

Edited by UnKnOwned

Share this post


Link to post
Share on other sites

About the error, you need to pay close attention to the quotes.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
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
Sign in to follow this  
Followers 0