ptrex Posted November 7, 2005 Share Posted November 7, 2005 (edited) Dynamics Functions This is an example of a dynamic function. You can use any AutoIT, Math, Date&Time, String, Variables, Macros, etc, or any combination of it.Making it possible to change functions interactively with changing the hardcoded data.And pass that result on to another function if needed.expandcollapse popup; ; PTREX dd 06/11/05 ; Dynamics Functions ; You can use any AutoIT, Math, Date&Time, String, Variables, Macros, etc, or any combination of it. ; Making it possible to change functions interactively with changing the hardcoded data. ; #include <GUIConstants.au3> #include <Date.au3> #include <String.au3> #include <Math.au3> #NoTrayIcon Dim $Var = 52; Just a number to demonstrate that Vars are precessed correctly. ;Generated with Form Designer preview $Form1 = GUICreate("Dynamic functions", 622, 441, 192, 113) $Edit1 = GUICtrlCreateEdit("", 48, 40, 553, 217, -1, $WS_EX_CLIENTEDGE) GUICtrlSetData($Edit1, "@ComputerName &chr(32) &stringRight(@OSVersion,2) &chr(32) &_Now() &chr(32)& $Var &chr(32) & sqrt(2) &chr(32) &_Calc()/2") $Label1 = GUICtrlCreateLabel("", 48, 288, 430, 25, $SS_SUNKEN) $Button1 = GUICtrlCreateButton("Execute", 500, 288, 89, 25) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 _Dynamic_Functions() _Calc() EndSelect WEnd Exit Func _Dynamic_Functions() $a=GUICtrlRead($Edit1) $v=Execute($a) If @error=1 Then Msgbox(0,"Error","There is a syntax Error, Please correct.") Else GUICtrlSetData($Label1,$v) EndIf EndFunc Func _Calc() $var=$var+1 EndFuncThanks to Valik to put me on the right track. Edited September 14, 2012 by 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...
ptrex Posted November 7, 2005 Author Share Posted November 7, 2005 There seems to be 1 limitation. Calling a the _Calc (User Defined functions) return a 0 instead of 53. This means that only External UDF's can be used, or Internal Variables. This might be by design of the Excecute() function. Maybe the developers can explain the behaviour ? 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...
w0uter Posted November 7, 2005 Share Posted November 7, 2005 (edited) its designd so that we cant "exploit" it. to say it short: IMO its useless. Edited November 7, 2005 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Klaatu Posted November 7, 2005 Share Posted November 7, 2005 Yes, basically it's a gun with a trigger lock. My Projects:DebugIt - Debug your AutoIt scripts with DebugIt! Link to comment Share on other sites More sharing options...
ptrex Posted November 8, 2005 Author Share Posted November 8, 2005 Thanks for the feedback. Can you give me an example when it is exploited or dangerous to use an Internal defined function. Just for my understanding. 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...
w0uter Posted November 8, 2005 Share Posted November 8, 2005 when you use an encrypted filedelete string. (not that you can encrypt the dos command DEL or something ) atleast that was the example given to us. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
ptrex Posted November 8, 2005 Author Share Posted November 8, 2005 OK clear. 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...
Oldschool Posted February 17, 2008 Share Posted February 17, 2008 (edited) Hey Ptrex, Have you ever been able to get a dynamic function to return something? ;testingDynFuncs #Include <File.au3> #Include <Array.au3> Global $DynamicFuncs If Not _FileReadToArray(@ScriptDir & "\testing.au3", $DynamicFuncs) Then MsgBox(4096,"Error", " Error reading the formula ==>> error:" & @error) Exit EndIf ;_ArrayDisplay($DynamicFuncs) Local $start Local $end For $i = 1 To $DynamicFuncs[0] If StringInStr($DynamicFuncs[$i], "Func _CatchAReturn") Then $start = $i+1 If StringInStr($DynamicFuncs[$i], "EndFunc ;<===_CatchAReturn") Then $end = $i-1 Next MsgBox(0, "",_CatchAReturn("25")) Func _CatchAReturn($number) For $j = $start To $end Execute($DynamicFuncs[$j]) Next EndFunc ;<===_CatchAReturnoÝ÷ Ù8b²+0«b·lx®zËb®Ý«¢+ÙÕ¹} Ñ¡IÑÕɸ ÀÌØí¹ÕµÈ¤(5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¹ÕµÈ¬Ô¤(5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¹ÕµÈ¬Ð¤)¹Õ¹ì±Ðìôôõ} Ñ¡IÑÕɸoÝ÷ Ù8^iº/{ +ËaÇhzÉ赫¢+ÙÕ¹} Ñ¡IÑÕɸ ÀÌØí¹ÕµÈ¤(%ÀÌØí¹ÕµÈ±ÐìÌÀQ¡¸IÑÕɸÀÌØí¹ÕµÈ¬ôÔ(%ÀÌØí¹ÕµÈÐìÌÀQ¡¸IÑÕɸÀÌØí¹ÕµÈ´ôÔ)¹Õ¹ì±Ðìôôõ} Ñ¡IÑÕɸ Any ideas? EDIT: In other words I'm trying to execute an IF statement dynamically... Edited February 17, 2008 by Oldschool Link to comment Share on other sites More sharing options...
Oldschool Posted February 17, 2008 Share Posted February 17, 2008 Or here is another example: #Include <File.au3> #Include <Array.au3> Global $DynamicFuncs Global $FuncString If Not _FileReadToArray(@ScriptDir & "\testing.au3", $DynamicFuncs) Then MsgBox(4096,"Error", " Error reading the formula ==>> error:" & @error) Exit EndIf ;_ArrayDisplay($DynamicFuncs) Local $start Local $end For $i = 1 To $DynamicFuncs[0] If StringInStr($DynamicFuncs[$i], "Func _CatchAReturn") Then $start = $i+1 If StringInStr($DynamicFuncs[$i], "EndFunc ;<===_CatchAReturn") Then $end = $i-1 Next MsgBox(0, "",_CatchAReturn("25")) Func _CatchAReturn($n) Local $number = $n For $j = $start To $end $FuncString = $FuncString & $DynamicFuncs[$j] Next MsgBox(0, "", $FuncString) Execute($FuncString) Return $number EndFunc ;<===_CatchAReturnoÝ÷ Ø Ý¶zËb h¢K%G+ºÚ"µÍ[ÈÐØ]ÚT] ÌÍÛ[XBUÚ[HBY ÌÍÛ[X ÈÌ[ ÌÍÛ[X ÏH BHY ÌÍÛ[X ÝÈÌ[ ÌÍÛ[XOH BH^]ÛÜUÑ[[[ÈÉÏOOWÐØ]ÚT] There is no error when the script is executed, but the $number returned does not change... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 17, 2008 Moderators Share Posted February 17, 2008 (edited) This is simply a support question, there was no need to bring up a 2+ year old topic. Edit: Even I was confused on what you are asking. Edit2: Now I don't even know if I was confused $nTest = 4 _ByRefFunc($nTest) MsgBox(0, 0, $nTest) Func _ByRefFunc(ByRef $nNum) If $nNum <= 3 Then $nNum += 2 Else $nNum -= 2 EndIf Return EndFuncIs what I was assuming you were trying to do. Edited February 17, 2008 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 More sharing options...
James Posted February 17, 2008 Share Posted February 17, 2008 There was a syntax error? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
ptrex Posted February 17, 2008 Author Share Posted February 17, 2008 @All What can I add more ?! 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...
James Posted February 17, 2008 Share Posted February 17, 2008 A nice new GUI would be good Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Oldschool Posted February 18, 2008 Share Posted February 18, 2008 This is simply a support question, there was no need to bring up a 2+ year old topic. Edit: Even I was confused on what you are asking. Edit2: Now I don't even know if I was confused Is what I was assuming you were trying to do. Guy, there is as much logic in my example as there is in a "Hello World!" script. In other words it's simply a proof of concept... What's not to understand? [testing] 0=MsgBox(0, "", "Hello World!") $var = IniRead(@ScriptDir & "\test.ini", "testing", "0", "") Test() Func Test() Execute($var) EndFunc Link to comment Share on other sites More sharing options...
BrettF Posted February 18, 2008 Share Posted February 18, 2008 (edited) $return = Execute ("IsNumber ('abc')") MsgBox (0, "", $return) Will fail, whereas, $return = Execute ("IsNumber (10)") MsgBox (0, "", $return) works... Edited February 18, 2008 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now