AZJIO Posted February 6, 2012 Posted February 6, 2012 guinness This example does not have a problem with the encoding when outputting the result with the Russian letters StdoutRead #include <Array.au3> #include <Constants.au3> $sPath = @ScriptDir $sFileMask = '*.*' $sOut = '' If Not StringInStr(FileGetAttrib($sPath), "D") Then Exit $sOut = StringToBinary('0' & @CRLF, 2) $sPath = StringRegExpReplace($sPath, '+$', '') $iPID = Run(@ComSpec & ' /U /C DIR "' & $sPath & '' & $sFileMask & '" /B /S /A-D', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sOut &= StdoutRead($iPID, False, True) If @error Then ExitLoop Wend $aOut = StringRegExp(BinaryToString($sOut, 2), '[^rn]+', 3) If @error Or UBound($aOut) < 2 Then Exit $aOut[0] = UBound($aOut)-1 _ArrayDisplay($aOut, 'all files') My other projects or all
guinness Posted February 6, 2012 Author Posted February 6, 2012 Thanks, I did wonder if I should use the /U option so I'll think about it as I don't want to make the example too complex. 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
AZJIO Posted February 6, 2012 Posted February 6, 2012 (edited) You can leave StdioClose and StdoutRead with different types of Add a comment that StdioClose ($ iPID) you can comment if you want to get the result TrayCreateItem Must demonstrate the "Radio" Edited February 6, 2012 by AZJIO My other projects or all
guinness Posted February 6, 2012 Author Posted February 6, 2012 You can leave StdioClose and StdoutRead with different types ofAdd a comment that StdioClose ($ iPID) you can comment if you want to get the resultOK, will do.TrayCreateItemMust demonstrate the "Radio"OK. 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
AZJIO Posted February 6, 2012 Posted February 6, 2012 (edited) guinness In Dim.au3 can add examples to declare arrays with different dimensions ; Example 4 #include <array.au3> Global $Array[2] = ['element1', 'element2'] _ArrayDisplay( $Array, "Array 1" ) Dim $Array[8] = [0] _ArrayDisplay( $Array, "Array 2" ) Dim $Array[3][2] = [[1,2],[3,4],[5,6]] ; 3 rows, 2 columns _ArrayDisplay( $Array, "Array 3" ) Dim $Array[2][3] = [[1,2,3],[3,4,6]] ; 2 rows, 3 columns _ArrayDisplay( $Array, "Array 4" ) Edited February 7, 2012 by AZJIO My other projects or all
guinness Posted February 7, 2012 Author Posted February 7, 2012 guinness In Dim.au3 can add examples to declare arrays with different dimensions ; Example 4 #include <array.au3> Global $Array[2] = ['element1', 'element2'] _ArrayDisplay( $Array, "Array 1" ) Dim $Array[8] = [0] _ArrayDisplay( $Array, "Array 2" ) Dim $Array[3][2] = [[1,2],[3,4],[5,6]] ; 3 rows, 2 columns _ArrayDisplay( $Array, "Array 3" ) Dim $Array[2][3] = [[1,2,3],[3,4,6]] ; 2 rows, 3 columns _ArrayDisplay( $Array, "Array 4" ) I was always under the impression using Dim was bad coding practice. 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
water Posted February 7, 2012 Posted February 7, 2012 I was always under the impression using Dim was bad coding practice.I've got the same impression because the help file states:"You should use Local or Global, instead of Dim, to explicitly state which scope is desired for a variable/constant/array."I think it's good coding practice to specify the scope. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Â
Moderators Melba23 Posted February 7, 2012 Moderators Posted February 7, 2012 guinness, It is - you should always make the scope explicit rather than rely on AutoIt's interpretation. And it is not just me that says this - anyone want an argument now? M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Â
BrewManNH Posted February 7, 2012 Posted February 7, 2012 In this example, the Dim is being declared as Global because it's not inside a function. It doesn't matter if you use Dim or Global, or even Local in the example, the results are always the same, the array is redeclared with different dimensions and the array contents are lost. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator
Valik Posted February 7, 2012 Posted February 7, 2012 The only time it's okay to use it is to declare an existing variable with a new size. Otherwise it's not the best choice to use. That example is okay-ish because it's re-using a global variable explicitly declared. But... it's using a global variable. Also, I'm not sure changing dimensions is the best thing to demonstrate. You really should only ever need to go from a non-array to an array (of arbitrary size and dimensions). If you are changing the number of dimensions (going from 1D to 2D) on an existing array then you are writing bad code. I do not think we should demonstrate writing bad code just because it's possible to write it.
guinness Posted February 7, 2012 Author Posted February 7, 2012 Thanks all. In light of the recent comments I'll leave it as it is. 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
AZJIO Posted February 7, 2012 Posted February 7, 2012 (edited) guinnessNow for me it not a problem, but I remember what problems and questions arose and as long it was impossible to place correctly square brackets, commas and indexes that it worked without errors.MouseClick("left", 0, 500, 2)screenshotExit ; Attention, check that a click will be safe MouseClick("left", 0, 500, 2)DirCopy (DirMove, FileCopy, etc.)DirCopy(@MyDocumentsDir, "C:BackupsMyDocs", 1)I have a folder " My Documents" several tens of gigabytesExit ; Attention, it only for an example. DirCopy(@MyDocumentsDir, "C:BackupsMyDocs", 1)Protection against the fool. Protection against the autopilotGUICtrlRecvMsgLocal $a = GUICtrlRecvMsg($nEdit, $EM_GETSEL) If @error Then ContinueLoop ; add this lineGUICtrlSetFontGUICtrlCreateLabel("bold", 10, 80) GUICtrlSetFont(-1, 9, 700, 0, $font) GUICtrlCreateLabel("large", 10, 100, 110, 30) GUICtrlSetFont(-1, 16, 400, 0, $font)DriveSetLabelDriveSetLabel(@HomeDrive & "", "New_Label") DriveSetLabel("X:", "New_Label") ; - so it's bestOnAutoItExitRegisterIn the description of the function "OnAutoItExitRegister" you can do the warning: you cannot assign the same function for the two events "$GUI_EVENT_CLOSE" and "OnAutoItExitRegister". This will force the function will be processed twice.#include <GUIConstantsEx.au3> Global $iC=0 Opt("GUIOnEventMode", 1) GUICreate('My Program', 250, 260) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState () OnAutoItExitRegister("_Exit") While 1 Sleep(1000) WEnd Func _Exit() $iC+=1 MsgBox(0, '', $iC) Exit EndFuncGUISetHelpGUISetHelp('hh.exe "'&@ProgramFilesDir&'AutoIt3AutoIt3.chm::/html/functions/GUISetHelp.htm"')#include; Create a file with this content Script.au3: ; ==> Beginning of the file Script.au3 #include "Time.au3" MsgBox(4096,"", "Example") #include "Time.au3" ; ==> this end of the file Script.au3 Exit ; Create a file with this content Time.au3: ; ==> Beginning of the file Time.au3 MsgBox(4096,"", "The time is " & @HOUR & ":" & @MIN & ":" & @SEC) ; ==> this end of the file Time.au3 ; And put it in the folder "AutoIt3Include" or in the script directory ; Run Script.au3 and see 3 dialog box messages ; One with the current time, one with the text 'Example ', and the last with the current time. ; The contents of the file Time.au3 will be inserted in the file Script.au3 in the specified position Edited February 8, 2012 by AZJIO My other projects or all
matwachich Posted February 8, 2012 Posted February 8, 2012 Juste noticed something in the help fileIn the page: Standard Windows FontsThe OS Names in the table are not visible until you select them.
guinness Posted February 8, 2012 Author Posted February 8, 2012 Thanks, this has been fixed in the latest beta Help file. 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
guinness Posted February 8, 2012 Author Posted February 8, 2012 AZJIO, Thanks I'll have a look at your suggestions on the weekend. 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
AZJIO Posted February 9, 2012 Posted February 9, 2012 (edited) guinness Send Example() Func Example() ; Simulate the key combination Win + R to open the Run dialogue window. Send("#r") ; Wait 10 seconds for the Run dialogue window to appear. $hWnd=WinWait("Run", "", 10) If Not $hWnd Then Exit Sleep(100) ; Simulate entering notepad.exe and pressing the 'ENTER' key. Send("notepad.exe{Enter}") ; Wait 10 seconds for the Notepad window to appear. Local $hWnd = WinWait("[CLASS:Notepad]", "", 10) If Not $hWnd Then Exit ; Simulate entering the following string and pressing the 'F5' key to input the date and time into edit control of Notepad. Send("Today's time/date is {F5}") Sleep(1500) ; Close the Notepad window using the handle returned by WinWait. WinClose($hWnd) ; Now a screen will pop up and ask to save the changes, the classname of the window is called ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file" WinWaitActive("[CLASS:#32770]") Sleep(500) Send("{TAB}{ENTER}") EndFunc ;==>Example SoundSetWaveVolume SoundSetWaveVolume(50) ; Set Volume SoundPlay(@WindowsDir & "mediatada.wav",1) SoundSetWaveVolume(10) SoundPlay(@WindowsDir & "mediatada.wav",1) Shutdown Exit ; Attention, it only for an example. Shutdown(6) ; Force a reboot RunWait Example() Func Example() ; Run Notepad and wait for the Notepad process to close. Local $iReturn = RunWait("notepad.exe") ; Display the return code of the Notepad process. MsgBox(4096, "", "The return code from Notepad was: " & $iReturn) EndFunc ;==>Example Exit ; File Compression "file.dll" to the archive "file.dl_" RunWait('makecab.exe "'&@ScriptDir&'file.dll"', '', @SW_HIDE) RunWait('makecab.exe /D Compress=ON /D CompressionMemory=21 /D CompressionType=LZX /D CompressionLevel=7 "'&@ScriptDir&'file.txt"', '', @SW_HIDE) ; File Compression "Boot.ini" to the archive "Archive.7z" with password "My Password" RunWait(@ProgramFilesDir &'7-Zip7z.exe a "'&@HomeDrive&'Archive.7z" -p"My Password" -mhe -mx9 "'&@HomeDrive&'Boot.ini"', '', @SW_HIDE) ; NTFS-compression (to use a folder /s:path) RunWait('compact.exe /c /i "'&@MyDocumentsDir&'Readme.txt"', '', @SW_HIDE) ; NTFS-decompression RunWait('compact.exe /u /i "'&@MyDocumentsDir&'Readme.txt"', '', @SW_HIDE) ; Creates a bootable ISO-file RunWait(@ScriptDir &'cdimage.exe -l"GrubCD" -g -h -c -j1 -m -b"'&@ScriptDir&'grubldr.bin" "'&@ScriptDir&'sourse" "'&@ScriptDir&'grub_cd.iso"', '', @SW_HIDE) ; Creates a bootable ISO-file RunWait(@ScriptDir &'mkisofs.exe -duplicates-once -volid "GrubCD" -iso-level 4 -b grldr.bin -no-emul-boot -boot-load-seg 0x1000 -hide boot.catalog -hide grldr.bin -o "'&@ScriptDir&'grub_cd.iso" "'&@ScriptDir&'sourse"', '', @SW_HIDE) ; Mount ISO-file RunWait('imdisk.exe -a -t file -o ro -m #: -f "'&@ScriptDir&'grub_cd.iso"', '', @SW_HIDE) ; Mount IMG-file RunWait(@ComSpec & ' /C vdk.exe open 0 '&@ScriptDir&'Boot.img /p:0 /l:Y: | find /v "http:" | find /v "version" | find /v "Failed"', '', @SW_HIDE) ; Emulation boot HDD (Fixed, Removable) RunWait(@ScriptDir&'qemu.exe -L . -m 512 -hda ".PhysicalDrive0" -boot c') ; Disable the device (network card) RunWait(@ScriptDir&'devcon disable @PCIVEN_10EC&DEV_8168*', '', @SW_HIDE) ; Enable the device (network card) RunWait(@ScriptDir&'devcon enable @PCIVEN_10EC&DEV_8168*', '', @SW_HIDE) ; Output to a file RunWait(@ComSpec & ' /c reg.exe -h>"'&@ScriptDir&'text.txt"', '', @SW_HIDE) Edited February 9, 2012 by AZJIO My other projects or all
Valik Posted February 9, 2012 Posted February 9, 2012 The Shutdown() example is stupid. The example for RunWait() is beyond ludicrously stupid. The point isn't to teach every single possible thing they can do with a function. It's to give a basic usage demonstration.
AZJIO Posted February 9, 2012 Posted February 9, 2012 An example is to show all the properties of functions, and still be concise. 1. RunWait does not show the startup parameters 2. Very frequent error-if the key contains the path, it should be quoted 3. Example with @ComSpec and @SW_HIDE My other projects or all
Valik Posted February 9, 2012 Posted February 9, 2012 An example is to show all the properties of functions, and still be concise.I'm completely blown away by that sentence. People accuse me of having an ego yet you try to tell me what an example is supposed to do? Me? The person who's been working on AutoIt since 2004? Me, the current project leader? Just... wow. Anyway.No, the examples are not meant to show all properties of functions. That's information overload. Showing every possible permutation on how to invoke a function does more harm than good. If a user doesn't know how to correctly use a function (a reasonable assumption if they are looking at the example) then how are they going to know which of the many examples is the one they need? Furthermore, how are they ever going to learn how to read and interpret the documentation and apply that in the language if they have their hand held through everything? It's far more productive to teach users the basics so get a good foundation and begin to recognizing the patterns on their own. From there they should be able to use the function in other ways without seeing additional examples. Otherwise they are not ready to use the function in other ways because they still lack basic knowledge.I haven't even touched on the actual calls you're making in the examples. Calls to devcon? In @ScriptDir? That's not going to work, of course, which means you've provided a broken example. Or it won't work because the device ID is different for the user's NIC. Or it will work and disable the user's NIC. What the fuck!? The last one dumps the help text for Registry Editor to a file in @ScriptDir. By default @ScriptDir will be something like "C:\Program Files (x86)\AutoIt3\Examples\" which is protected so you're really sending the output to the Virtual Store.A million Picards in a million parallel universes just Double-Picard-Facepalmed at the examples you provide. GEOSoft 1
Recommended Posts