Leaderboard
Popular Content
Showing content with the highest reputation on 03/13/2019 in all areas
-
I create purebasic language functions similar to autolt I let the members of the furom improve the concept with a beginning of idea I included some functions it works very well for the moment I let you modify and give your ideas thank add in your purebasic source code (IncludeFile "AutoitCoding.PB") and program as on autolt it remains full of function to program the concept is to improve the languages remain similar AutoIt Code : 415 kb with UPX Interpreted Language $Time=TimerInit() MsgBox (16,"Autoit",StringIsDigit ("123a")) MsgBox (16,"Autoit",StringIsDigit ("123")) $VarBin=StringToBinary("Hello") MsgBox (64,"Autoit",@Hour) MsgBox (64,"Autoit",@TempDir) MsgBox (64,"Autoit",$VarBin) MsgBox (64,"Autoit",BinaryToString($VarBin)) MsgBox (0,"Autoit",StringLen ("bonjour")) MsgBox (1,"Autoit",@DesktopCommonDir) MsgBox (2,"Autoit",@ProgramFilesDir) Sleep (1000) MsgBox (3,"Autoit",FileGetSize("test.pb")) MsgBox (4,"Autoit",Random (1,10,1)) $Variable=FileGetSize("test.pb") MsgBox (0,"Autoit",$Variable) ;InetGet ("https://jardinage.lemonde.fr/images/dossiers/2018-07/language-chat-170054.jpg","image.jpg") MsgBox (0,"Autoit",StringReplace ("Hella","a","o")) MsgBox (0,"Autoit",StringTrimLeft ("Hello",1)) MsgBox (0,"Autoit",StringTrimRight("Hello",1)) If FileExists ("test.pb") Then MsgBox(0,"Title","the file exist") Else MsgBox(0,"Title","the file does not exist") EndIf MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,1)) MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,1)) MsgBox(0,"Autoit",FileGetVersion("UPX.exe")) MsgBox(0,"Autoit",TimerDiff($Time)) If IsAdmin() Then MsgBox(0,"Autoit", "IsAdmin You are administrator !.") Else MsgBox(0,"Autoit", "IsAdmin You are not administrator !.") EndIf MsgBox(0,"Autoit",String (10)) MsgBox(0,"Autoit",Ping ("google.fr")) ;################## StringSplit $Split = StringSplit("ABC*DEFG*JKL","*") MsgBox(0,"Autoit",$Split[1]) MsgBox(0,"Autoit",$Split[2]) MsgBox(0,"Autoit",$Split[3]) ;################## StringSplit IniWrite("setup3.ini", "General", "Title", "AutoIt") $inivar= IniRead("setup3.ini", "General", "Title",Default) MsgBox (0,"Autoit",$inivar) PureBasic Code : Executable Size : 12 kb with UPX Real Compiler ( Your source code is secure ) IncludeFile "AutoitCoding.PB" ;MsgBox (16,"Autoit",StringIsDigit ("123a")) ;StringIs.PB be sure to activate it in AutoitCoding.PB this increases the size of the executable ;MsgBox (16,"Autoit",StringIsDigit ("123")) ;StringIs.PB be sure to activate it in AutoitCoding.PB this increases the size of the executable ;InetGet ("https://jardinage.lemonde.fr/images/dossiers/2018-07/language-chat-170054.jpg","image.jpg") ; InetFonctions be sure to activate it in AutoitCoding.PB this increases the size of the executable ;##################Mouse Dim xy (1) MouseGetPos (xy()) Debug "Pos : X : "+xy(0)+" Y : "+xy(1) Debug WinGetHandle ("Notepad") ;################## ProcessList Dim ProcessName.s(1) ; Create array Dim PID.s(1) ; Create array ProcessList (ProcessName (),PID ()) MsgBox(0,"Autoit","ProcessName: "+ProcessName(10)+" YourPID: "+PID (10)) ;################## ProcessList For i = 0 To ArraySize (ProcessName ()) Debug ProcessName (i)+" PID : "+ PID (i) Next MsgBox (0,"Autoit",ProcessorArch ()) Time$=TimerInit() VarBin$=StringToBinary("Hello") MsgBox (0,"Autoit",ComSpec ()) MsgBox (64,"Autoit",GetCPUName ()) MsgBox (64,"Autoit",CpuSerialNumber ()) MsgBox (64,"Autoit",AutoItVersion ()) MsgBox (64,"Autoit","Hello"+CRLF ()+"Hello") MsgBox (64,"Autoit",Hours ()) MsgBox (64,"Autoit",TempDir ()) MsgBox (64,"Autoit",VarBin$) MsgBox (64,"Autoit",BinaryToString(VarBin$)) MsgBox (48,"Autoit",StringLenS ("bonjour")) MsgBox (1,"Autoit",DesktopCommonDir ()) MsgBox (2,"Autoit",ProgramFilesDir ()) Sleep (1000) MsgBox (3,"Autoit",FileGetSize("test.pb")) MsgBox (4,"Autoit",Randoms (1,10)) Variable$=FileGetSize("test.pb") MsgBox (0,"Autoit",Variable$) MsgBox (0,"Autoit",StringReplace ("Hella","a","o")) MsgBox (0,"Autoit",StringTrimLeft ("Hello",1)) MsgBox (0,"Autoit",StringTrimRight("Hello",1)) If FileExists ("test.pb") MsgBox(0,"Autoit","the file exist") Else MsgBox(0,"Autoit","the file does not exist") EndIf MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,"%mm/%dd/%yyyy %hh:%ii:%ss")) MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,"%hh:%ii:%ss")) MsgBox(0,"Autoit",FileGetVersion("UPX.exe",#FV_FileVersion)) MsgBox(0,"Autoit",TimerDiff(Time$)) If IsAdmin() MsgBox(0,"Autoit", "IsAdmin You are administrator !.") Else MsgBox(0,"Autoit", "IsAdmin You are not administrator !.") EndIf MsgBox(0,"Autoit",String(10)) MsgBox(0,"Autoit",Ping ("google.fr")) iLife = 42 If IsNumber(iLife) MsgBox(0, "", "Is Number") Else MsgBox(0, "", "Is not Number") EndIf ;################## StringSplit Dim Split.s(1) ; Create array StringSplit (split(), "ABC*DEFG*JKL", "*") MsgBox(0,"Autoit",Split(0)) MsgBox(0,"Autoit",Split(1)) MsgBox(0,"Autoit",Split(2)) ;################## StringSplit IniWrite("setup3.ini", "General", "Title", "AutoIt") inivar$= IniRead("setup3.ini", "General", "Title") MsgBox (0,"Autoit",inivar$) ;Bonus Function MsgBox(0,"Autoit",HostNameToIp ("google.fr")) there is a slight difference but nothing important I am counting on you to improve the project and add functions ! ( Disadvantage purebasic is paying you can not have all ) Functions compatible : Msgbox Sleep FileGetSize ClipPut ClipGet Randoms DirCopy DirCreate DirRemove StringReplace StringLen Add Fonctions : (11/03/2019) StringTrimLeft StringTrimRight FileCopy FileMove StringUpper StringLower Add Fonctions : (12/03/2019) StringIsFloat StringIsAlpha StringIsDigit StringReverse BinaryToString StringToBinary FileExists Msgbox ADD : MB_ICONERROR = 16 MB_ICONQUESTION = 32 MB_ICONWARNING = 48 MB_ICONINFORMATION=64 You can control the size of the executable Division of executable size by 10 ( 119 kb to 12 kb) ( I separated the functions in several file activated if necessary ) ;IncludeFile "FonctionsIncludes\StringIs.PB" I separated the functions into several activated files If necessary remove ;IncludeFile "FonctionsIncludes\InetFonctions.PB" ; I separated the functions into several activated files If necessary remove Add Functions: (20/03/2019) String IsAdmin TimerDiff (thank @JiBe) TimerInit (thank @JiBe) Ping FileGetVersion add : #FV_FileVersion #FV_FileDescription #FV_LegalCopyright #FV_InternalName #FV_OriginalFilename #FV_ProductName #FV_ProductVersion #FV_CompanyName #FV_LegalTrademarks #FV_SpecialBuild #FV_PrivateBuild #FV_Comments #FV_Language FileGetTime Flag : 0 Last modified (default) 1 Created 2 Last accessed Msgbox ADD : MB_DEFBUTTON2 = 256 Flag MB_DEFBUTTON3 = 512 Flag MB_DEFBUTTON4 = 768 Flag MB_SYSTEMMODAL = 4096 Flag MB_TASKMODAL = 8192 Flag MB_DEFAULT_DESKTOP_ONLY = 131072 Flag MB_RIGHT = 524288 Flag MB_RTLREADING = 1048576 Flag MB_SETFOREGROUND = 65536 Flag MB_TOPMOST = 262144 Flag MB_SERVICE_NOTIFICATION = 2097152 Flag Bonus Functions : HostNameToIp Add Functions: (22/03/2019) ----------------------- ADD Macros : (thank @AZJIO) DesktopCommonDir () MyDocumentsDir () ProgramFilesDir () ScriptFullPath () ScriptName () ScriptDir () ----------------------- OSVersions () Add Functions: (26/03/2019) ----------------------- ADD Macros : TempDir () Hours () Min () Sec () MDAY () MON () Years () LF () CR () CRLF () ----------------------- Functions: Floor Ceiling Stringlen ( Update :Return Number) StringlenS (Temporary function asks for reflection) Add Functions: 06/04/2019 Macro : AutoItVersion () ; it's for fun haha SystemDir () UserProfileDir () AppDataDir () ComSpec () ; Bug fixed UserName () LogonServer () HomeShare () HomeDrive () HomePath () HomeDrive () LocalAppDataDir () UserProfilDir () Bonus Macro : ProcessorsThreadNumber () Functions : Change of procedure in macro (optimization) Optimization of msgbox Fix a constant messagebox Beep StringSplit ( thank @AZJIO ) FileGetAttrib Bonus features : CpuSerialNumber() GetCPUName() Add Functions: 16/04/2019 Optimization UserName () Optimization CpuName () change of the name of the function GetCpuName () ProcessList () : Return PID Return ProcessName ProcessClose (); PID or ProcessName IniWrite () IniRead () Macro : ProcessorArch () DesktopHeights () DesktopWidths () DesktopRefresh () DesktopDepths () AutoItX64 () Add Functions: 19/04/2019 Functions: ( THANK @AZJIO ) IniDelete () DriveGetType() DriveGetLabel() DriveGetSerial() DriveSpaceFree() DriveSpaceTotal() DriveGetFileSystem() Add Functions: 30/04/2019 Minor bug fixes : DriveGetLabel() fixed function thank AZJIO DriveGetFileSystem() fixed function thank AZJIO ADD Functions : BlockInput () thank AZJIO FileGetShortName() FileGetLongName() MouseGetPos () WinGetHandle () Sqrt () Add Functions: 23/05/2019 ProcessExists () ClosePID () IniReadSectionNames() WinWait ();2 in 1 finds the same handle with a title or a partial text WinExists ();2 in 1 finds the same handle with a title or a partial text WinWaitClose ();2 in 1 finds the same handle with a title or a partial text WinWaitActive ();2 in 1 finds the same handle with a title or a partial text WinGetProcess ();2 in 1 finds the same handle with a title or a partial text HandleToHex ();x86 management Imitate autoit HexToHandle () ADD Macro : ScriptDir () Complete rewrite of functions with optimization : ProcessList () ProcessClose () WinGetHandle () Delete function : CountProcess () FileGetSize () ;Old function All the old function are put in the OldFonctions.pb file Add Fonctions : (18/07/2019) WinMinimizeAll() Winkill ();title or a partial text SearchHandle ();Bonus function to simplify your life look for the handle of a window with a title or a text patiel WinSetStade ();title or a partial text or Handle #SW_HIDE = 0 #SW_SHOW = 5 #SW_MINIMIZE = 6 #SW_MAXIMIZE = 3 #SW_RESTORE = 9 #SW_DISABLE = 4 #SW_ENABLE = 1 WinActive () Title or Handle WinList (); With the zero flag you can see the invisible windows and the flag 1 for visible windows more simplify than the original Default option : VisibleWindow = 1 WinSetTitle () Title or Handle Update : WinExists () Handle Management WinGetProcess () Handle Management Add Fonctions : (09/04/2020) IsHWnd (Return 0 or 1) PixelGetColor (x,y) WinSetTrans ;title or a partial text 0 To 255 Optimization of the msgbox function smaller and faster code (old msgbox function put in oldfunction.pb) Msgbox Fix minors bug MouseMoveSpeed Function under construction MouseClick Function under construction HibernateAllowed() Suspend() ShutdownPrivilege() Shutdown (Flag) #SD_LOGOFF=0 #SD_SHUTDOWN=1 #SD_REBOOT=2 #SD_FORCE=4 #SD_POWERDOWN=8 #SD_FORCEHUNG=16 #SD_STANDBY=32 #SD_HIBERNATE=64 ProcessSetPriority (Process.s, priority) #PROCESS_LOW =0 #PROCESS_BELOWNORMAL =1 #PROCESS_NORMAL =2 #PROCESS_ABOVENORMAL =3 #PROCESS_HIGH =4 #PROCESS_REALTIME =5 EnvSet () EnvGet () FileRecycleEmpty() add file in GuiExampleAutoitCoding (Hybrid Code) example method for window GuiExampleAutoitCoding (Hybrid Code) update files start of code to convert autoit to pb in construction Add Fonctions : (01/12/2022) #PB_OS_Windows_11 code upgrade OSVersion() WinActivate(hWnd) adding a new function thank @AZJIO #MB_SERVICE_NOTIFICATION1 I changed the name not compatible with purebasic 6 I added a 1 (msgbox) DriveGetLabel bugfix for version 6 of purebasic DriveGetFileSystem bugfix for version 6 of purebasic ProcessorArch () optimization of the function and addition of flag for Purebasic 6 ARM64 ARM ProcessorArch () the old function is moved to the file Old Functions.pb ProcessorArch () bug fixed stack has been corrupted ProcessorArch () add to file Example.pb InitNetwork remove Deprecated function HostNameToIp optimization of the function and addition of flag 0 HostNameToIp the old function is moved to the file Old Functions.pb Ping () optimization of the function and addition of flag and timeout Ping () fix minor bug flag 0 return ping flag 1 return PingStatus also returns errors 1 = Host disconnected 2 = Host unreachable 3 = Wrong destination 4 = Other errors flag 2 return DataSize timeout = 4000 like the original the setting support written web address and ip address (www.google.com or 127.0.0.1) Ping () the old function is moved to the file Old Functions.pb remove ExampleGui I moved the files in the same folder it is more manageable Add Fonctions : (05/09/2024) New Functions Added: DllOpen Implemented a new function DllCall Implemented a new function DllClose Implemented a new function iniWrite: Implemented a new function for writing to INI files. iniRead: Introduced a revised version of the basic function for reading INI files. CpuIdentifier() Combine some values to create a pseudo-unique identifier Function Rewrite: iniDelete: Updated the iniDelete function to enhance management of sections and keys. Ping improve performance Compatibility improved PureBasic 6.11 LTS Legacy Code Management: Moved obsolete functions to Oldfunctions.pb to streamline current codebase. Moved Macro Username to Oldfunctions.pb Moved Macro Blockinput to Oldfunctions.pb Bug fix : (05/09/2024) Bug fix : corrected IniRead procedure to return string instead of numeric value UPX official website to compress the executable : https://upx.github.io/ PureAutoitInclude.7z1 point
-
This is a modification of a script that was originally posted back in 2006, that was itself a modification of a script in the same thread, which was a modification of another script linked in that thread. All credits remain in the header as to who contributed to this. The only credit I take in this script is modifying parts of it to: 1.make it a bit faster, by removing a ReDim that was inside a loop 2.add support for OSs other than XP because of the number of file properties returned 3.add support for the future if the number of file properties returned changes again with future versions of Windows Please take note, this script will only work if you know the name of the property you're trying to retrieve. These properties are dependent upon the OS version, the OS language, and the file's properties. This function does not take any of these things into account, if you want to use this and make it OS neutral, you'll have to do that in your script, because it doesn't get done in here. Fortunately, if you access this function and leave the parameter $FGP_Property blank, it will return an array of all the properties that Windows knows about, and in the language that Windows is running in. Windows XP only returns 38 properties, Windows 7 returns 288, Windows 8 returns 290. The same properties can have different names depending on which OS you're using this with. Update Sept. 6, 2017 Changed the code slightly to make sure the return includes all properties, the last update cut off some of the properties at the end, and increased the $iPropertyCount to 500 (from 300) because of Windows 10 file property count increase. Update: Jun-25-2013 I have tweaked this function again, a small update. Added a new parameter to the function, $iPropertyCount, with a default setting of 300. This parameter was previously hard coded inside the function, now you are able to adjust it to the setting you desire/require. This value is used to determine how many file properties will be searched for the value passed in $FGP_PROPERTY, or the maximum amount of properties that will be returned in the array if $FGP_PROPERTY is a blank string. The $FGP_PROPERTY parameter will now accept the Default keyword in place of a blank string, which tells the function to return an array of all known properties, up to the setting of $iPropertyCount. Update: Feb-11-2013 I have updated this function again. Now it has a single point of return, except for error exceptions, instead of multiple places that it returned from previously. I've renamed the variables used so that they'll be less chance of a name collision with someone's script. Fixed a small bug that added a blank line to the end of the array returned when getting all properties. Changed the return value on an error from 0 to an empty string. NOTE: This is a repost of a thread I had already posted last year. I went looking for it today to update the code in it, and found that it had disappeared. New code #include <File.au3> ; only used for the example script, not needed for the UDF #include <Array.au3> ; only used for the example script, not needed for the UDF #include <Constants.au3> ; only used for the MsgBox, not needed for the UDF $sFolder = FileSelectFolder("Select a folder to scan", "") $sFolder &= "" $aFiles = _FileListToArray($sFolder, "*.exe") For $I = 1 To $aFiles[0] $aDetails = _FileGetProperty($sFolder & "\" & $aFiles[$I]) ; Returns an array with all properties of the file _ArrayDisplay($aDetails) Next Global $sDetails = _FileGetProperty($sFolder & "\" & $aFiles[$aFiles[0]], "date modified") MsgBox($MB_SYSTEMMODAL, "Date Modified", $sDetails) ;=============================================================================== ; Function Name.....: _FileGetProperty ; Description.......: Returns a property or all properties for a file. ; Version...........: 1.0.2 ; Change Date.......: 05-16-2012 ; AutoIt Version....: 3.2.12.1+ ; Parameter(s)......: $FGP_Path - String containing the file path to return the property from. ; $FGP_PROPERTY - [optional] String containing the name of the property to return. (default = "") ; $iPropertyCount - [optional] The number of properties to search through for $FGP_PROPERTY, or the number of items ; returned in the array if $FGP_PROPERTY is blank. (default = 300) ; Requirements(s)...: None ; Return Value(s)...: Success: Returns a string containing the property value. ; If $FGP_PROPERTY is blank, a two-dimensional array is returned: ; $av_array[0][0] = Number of properties. ; $av_array[1][0] = 1st property name. ; $as_array[1][1] = 1st property value. ; $av_array[n][0] = nth property name. ; $as_array[n][1] = nth property value. ; Failure: Returns an empty string and sets @error to: ; 1 = The folder $FGP_Path does not exist. ; 2 = The property $FGP_PROPERTY does not exist or the array could not be created. ; 3 = Unable to create the "Shell.Application" object $objShell. ; Author(s).........: - Simucal <Simucal@gmail.com> ; - Modified by: Sean Hart <autoit@hartmail.ca> ; - Modified by: teh_hahn <sPiTsHiT@gmx.de> ; - Modified by: BrewManNH ; URL...............: http://www.autoitscript.com/forum/topic/34732-udf-getfileproperty/page__view__findpost__p__557571 ; Note(s)...........: Modified the script that teh_hahn posted at the above link to include the properties that ; Vista and Win 7 include that Windows XP doesn't. Also removed the ReDims for the $av_ret array and ; replaced it with a single ReDim after it has found all the properties, this should speed things up. ; I further updated the code so there's a single point of return except for any errors encountered. ; $iPropertyCount is now a function parameter instead of being hardcoded in the function itself. ;=============================================================================== Func _FileGetProperty($FGP_Path, $FGP_PROPERTY = "", $iPropertyCount = 500) If $FGP_PROPERTY = Default Then $FGP_PROPERTY = "" $FGP_Path = StringRegExpReplace($FGP_Path, '["'']', "") ; strip the quotes, if any from the incoming string If Not FileExists($FGP_Path) Then Return SetError(1, 0, "") ; path not found Local Const $objShell = ObjCreate("Shell.Application") If @error Then Return SetError(3, 0, "") Local Const $FGP_File = StringTrimLeft($FGP_Path, StringInStr($FGP_Path, "\", 0, -1)) Local Const $FGP_Dir = StringTrimRight($FGP_Path, StringLen($FGP_File) + 1) Local Const $objFolder = $objShell.NameSpace($FGP_Dir) Local Const $objFolderItem = $objFolder.Parsename($FGP_File) Local $Return = "", $iError = 0 If $FGP_PROPERTY Then For $I = 0 To $iPropertyCount If $objFolder.GetDetailsOf($objFolder.Items, $I) = $FGP_PROPERTY Then $Return = $objFolder.GetDetailsOf($objFolderItem, $I) EndIf Next If $Return = "" Then $iError = 2 EndIf Else Local $av_ret[$iPropertyCount + 1][2] = [[0]] For $I = 1 To $iPropertyCount If $objFolder.GetDetailsOf($objFolder.Items, $I) Then $av_ret[$I][0] = $objFolder.GetDetailsOf($objFolder.Items, $I - 1) $av_ret[$I][1] = $objFolder.GetDetailsOf($objFolderItem, $I - 1) ;~ $av_ret[0][0] += 1 $av_ret[0][0] = $I EndIf Next ReDim $av_ret[$av_ret[0][0] + 1][2] If Not $av_ret[1][0] Then $iError = 2 $av_ret = $Return Else $Return = $av_ret EndIf EndIf Return SetError($iError, 0, $Return) EndFunc ;==>_FileGetProperty Warning, old code below.1 point
-
Forum Rules You can read about forum rules here. Announcements and site news Additional information about forum you can read here. Forum etiquette Here you can read about a proper forum etiquette.1 point
-
...when you use a loop like this: Do Sleep(10) $sStdOut &= StdoutRead($iPID) Until @error MsgBox(0, 'System says:', $sStdOut) the Until @error part works like this : the @arror occurs when you try to read with StdoutRead() from a process that is no more running. So if the error occurs it means that the process has finished and you have no more data to read. The whole otput is already in the $sStdOut variable. This kind of way to read from StdOut stream is good only when you run a command that will return a single output and then it will end. In this context the @error will mark the end of the job. But, if you have to interact with a running process, that is, get part of the output, send something with StdInWrite and so on, then checking @error is not ok, because @error doesn't means "I have finished to send my output", but it means "the process is no more running". You say: "but the second is just blank..." is because in the second reading loop, the plink.exe is no more running.1 point
-
Usually its better to use software deployment using SCCM although it maybe overkill for your organisation. In which case I would recommend PDQ Deploy - https://www.pdq.com/pdq-deploy/ we use both SCCM and PDQ Deploy for third-party patching and forcing installations like anti-virus etc... as the machines come online. Just my 2cents.1 point
-
Optimizing reading data from Excel
FrancescoDiMuro reacted to TheDcoder for a topic
I discovered another way to hugely cut up the speed... by using the inbuilt AutoIt transpose function! Just set $bForceFunc parameter to true and enjoy the gains #include <Array.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> Global $iTotalTime = 0 Test() Func Test() Local $oExcel = _Excel_Open() Local $oBook = _Excel_BookAttach("Test.xlsx", "FileName", $oExcel) Local $sSheet = "Sheet1" If @error Then Return MsgBox($MB_ICONERROR, "Excel Failed", "Failed to attach to Excel") Local $iNum Time() Local $aData = _Excel_RangeRead($oBook, $sSheet, "A1:B6", 1, True) Time() _ArrayDisplay($aData) For $iRow = 0 To 5 Time() Local $iNum = Number($aData[$iRow][0]) If $iNum = 1 Then ConsoleWrite("Row " & $iRow + 1 & " is 1 and value of column B is " & $aData[$iRow][0]) Else ConsoleWrite("Row " & $iRow + 1 & " is not 1") EndIf ConsoleWrite(". Reading took: ") Time() Next ConsoleWrite("The whole operation took " & $iTotalTime & " milliseconds." & @CRLF) EndFunc Func Time() Local Static $hTimer Local Static $bRunning = False If $bRunning Then Local $iTime = Round(TimerDiff($hTimer), 2) $iTotalTime += $iTime ConsoleWrite($iTime & @CRLF) Else $hTimer = TimerInit() EndIf $bRunning = Not $bRunning EndFunc 24.44 Row 1 is 1 and value of column B is 1. Reading took: 0.04 Row 2 is not 1. Reading took: 0.01 Row 3 is 1 and value of column B is 1. Reading took: 0.01 Row 4 is 1 and value of column B is 1. Reading took: 0.02 Row 5 is not 1. Reading took: 0.01 Row 6 is 1 and value of column B is 1. Reading took: 0.01 The whole operation took 24.54 milliseconds. From 1500 ms to 120 ms, and finally to 25 ms, that is an astonishing 60x improvement in total The excel function for transposing must really suck... or it accounts for a lot of things that our array transpose function cannot. Either way, I am happy with the outcome.1 point -
This has come up before in the support thread. AFAIK, while you can do this with Firefox, this isn't possible with Chrome.1 point
-
AutoIt - using 7z cmd adds parent folder to archive
lukedeloosh reacted to Subz for a topic
Try: The reason yours fails is that your running two separate cmd processes, you need to combine them like below (untested): Global $sCompressPath = "c:\directory\subdirectory\path_to_files" Global $sZipPath = "c:\path_to_archive" Global $sZipName = "archive_name.zip" $CmdChange = RunWait(@ComSpec & " /c cd " & $sCompressPath & "&&7z a " & $sZipPath & "\" & $sZipName & " .\* -r", "", @SW_HIDE)1 point -
Rename file array?
mrjonz1 reacted to FrancescoDiMuro for a topic
0 = False, so it need to set 1 as the $bReturnPath parameter1 point -
Use 0 in your FileListToArray so it returns the full path to the file as the FileMove needs the path, not just the filename. $aFileList = _FileListToArray($path, "*.exe - Shortcut.lnk", 0) hmm... looking further it appears you should just need to put $path & before the From and To in the filemove1 point
-
I have modified my original script to read all the data once instead of one by one for every cell... and boy are the speed gains huge! #include <Array.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> Global $iTotalTime = 0 Test() Func Test() Local $oExcel = _Excel_Open() Local $oBook = _Excel_BookAttach("Test.xlsx", "FileName", $oExcel) Local $sSheet = "Sheet1" If @error Then Return MsgBox($MB_ICONERROR, "Excel Failed", "Failed to attach to Excel") Local $iNum Time() Local $aData = _Excel_RangeRead($oBook, $sSheet, "A1:B6") Time() _ArrayDisplay($aData) For $iRow = 0 To 5 Time() Local $iNum = Number($aData[$iRow][0]) If $iNum = 1 Then ConsoleWrite("Row " & $iRow + 1 & " is 1 and value of column B is " & $aData[$iRow][0]) Else ConsoleWrite("Row " & $iRow + 1 & " is not 1") EndIf ConsoleWrite(". Reading took: ") Time() Next ConsoleWrite("The whole operation took " & $iTotalTime & " milliseconds." & @CRLF) EndFunc Func Time() Local Static $hTimer Local Static $bRunning = False If $bRunning Then Local $iTime = Round(TimerDiff($hTimer), 2) $iTotalTime += $iTime ConsoleWrite($iTime & @CRLF) Else $hTimer = TimerInit() EndIf $bRunning = Not $bRunning EndFunc 120.15 Row 1 is 1 and value of column B is 1. Reading took: 0.07 Row 2 is not 1. Reading took: 0.02 Row 3 is 1 and value of column B is 1. Reading took: 0.02 Row 4 is 1 and value of column B is 1. Reading took: 0.02 Row 5 is not 1. Reading took: 0.01 Row 6 is 1 and value of column B is 1. Reading took: 0.02 The whole operation took 120.31 milliseconds. From ~1500 ms to ~120 ms, that is a huge 12.5x improvement in speed And even most of that is the first initial call to Angered, definitely going to try this method of caching in my project... I actually feel a bit dumb not having tried this before asking1 point
-
Rename file array?
mrjonz1 reacted to FrancescoDiMuro for a topic
Hi @mrjonz1, and welcome to the AutoIt forums Trimming a string like this one: c:\Users\rjohns02\Desktop\temp\somefile.exe with the statement above, would return something like this: c:\Users\rjohns02\Deskto Could you please replace the MsgBox with a ConsoleWrite(), so you can paste the Console output here?1 point -
@ShrutiW If you are looking for a debugger tool for your script, then there is no official tool available. The way most people debug their script is to try to find the affected area and pin point the bug by manually adding in code to assist in diagnostics (ConsoleWrite to print the value of some variables to verify that they indeed have the expected value). That being said, there are some debugging tools available but they are a bit old and dated (haven't seen any which have been updated in the recent years), they basically work by cloning your script and adding some custom code to emulate breakpoints and update the value of variables. Natively the AutoIt interperter does not have any support for debugging as far as I am aware.1 point
-
Those are "only" available in the Full SciTE4AutoIt3 version! Jos1 point
-
1 point
-
Well, I did something similar: Func _SetOrientation($iOrientation = $PDF_ORIENTATION_PORTRAIT) $_Orientation = $iOrientation If ($_Orientation = $PDF_ORIENTATION_LANDSCAPE) Then ;Quick fix by Martin Wildam as otherwise orientation change looks like having no effect Local $bku = $_PageWidth $_PageWidth = $_PageHeight $_PageHeight = $bku EndIf EndFunc ;==>_SetOrientation By setting orientation the currently set paper size is switched in Width and Height. It looks like that in PDF you need to set orientation plus correct page size to have the desired effekt. As a programmer I was expecting that when I set paper size to A4 and then set orientation to landscape that should be sufficient. So therefore I changed it this way.1 point