Leaderboard
Popular Content
Showing content with the highest reputation on 01/15/2023 in all areas
-
I have hosted 4 open source AutoIt projects in GitHub: Stash Helper: The biggest one. DeoVR remote: Early attempt. MMD3 Helper : A pet project for a favorite program. Spam Call Filter : I didn't want to do it, but the daily calls from telemarketing spammers forced me to.3 points
-
AutoIt UDF Working with files and folders
noellarkin and one other reacted to Trong for a topic
UDF Working with files and folders: Global $iTEST_PATH = @WindowsDir & "\TESTdir\", $iTEST_FILENAME = "testFILE.txt" DirCreate($iTEST_PATH) FileWriteLine($iTEST_PATH & $iTEST_FILENAME, @ScriptFullPath) ConsoleWrite(">_TakeOwnership: " & _TakeOwnership($iTEST_PATH) & @CRLF) ConsoleWrite(">_Directory_Is_Accessible: " & _Directory_Is_Accessible($iTEST_PATH) & @CRLF) ConsoleWrite(">_File_Is_Accessible: " & _File_Is_Accessible($iTEST_PATH & $iTEST_FILENAME) & @CRLF) ConsoleWrite("> Path Split: " & _PathGet_Part($iTEST_PATH & $iTEST_FILENAME, 6) & @CRLF) ConsoleWrite("> Remove IT: " & _DelIt($iTEST_PATH) & @CRLF) Func _IsFile($sPath) If (Not FileExists($sPath)) Then Return SetError(-1, 0, 0) If StringInStr(FileGetAttrib($sPath), 'D') <> 0 Then Return SetError(0, 0, 0) Else Return SetError(0, 0, 1) EndIf EndFunc ;==>_IsFile Func _DelIt($sPath, $Fc = 1) If (Not FileExists($sPath)) Then Return SetError(-1, 0, 1) If _IsFile($sPath) Then Return SetError(0, 0, _DelFile($sPath, $Fc)) Else Return SetError(0, 0, _RemoveDir($sPath, $Fc)) EndIf EndFunc ;==>_DelIt Func _DelFile($sPath, $Fc = 1) If (Not _IsFile($sPath)) Then Return SetError(-1, 0, 0) Else ConsoleWrite("> DelFile: " & $sPath & @CRLF) FileSetAttrib($sPath, "-RSH") FileDelete($sPath) If $Fc Then If FileExists($sPath) Then _TakeOwnership($sPath, "Everyone", $Fc) If FileExists($sPath) Then FileDelete($sPath) If FileExists($sPath) Then RunWait(@ComSpec & ' /c Del /f /q "' & $sPath & '"', '', @SW_HIDE) EndIf If FileExists($sPath) Then Return SetError(1, 0, 0) Return SetError(0, 0, 1) EndIf EndFunc ;==>_DelFile Func _RemoveDir($sPath, $Fc = 1) If _IsFile($sPath) Then Return SetError(-1, 0, 0) Else ConsoleWrite("> _RemoveDir: " & $sPath & @CRLF) DirRemove($sPath, $Fc) If FileExists($sPath) Then _TakeOwnership($sPath, "Everyone", $Fc) DirRemove($sPath, $Fc) If FileExists($sPath) Then RunWait(@ComSpec & ' /c rmdir "' & $sPath & '" /s /q ', '', @SW_HIDE) If FileExists($sPath) Then Return SetError(1, 0, 0) Return SetError(0, 0, 1) EndIf EndFunc ;==>_RemoveDir Func _Directory_Is_Accessible($sPath, $iTouch = 0) If Not FileExists($sPath) Then DirCreate($sPath) If Not StringInStr(FileGetAttrib($sPath), "D", 2) Then Return SetError(1, 0, 0) Local $iEnum = 0, $maxEnum = 9999, $iRandom = Random(88888888, 99999999, 1) If $iTouch Then _TakeOwnership($sPath, "Everyone", 1) While FileExists($sPath & "\_IsWritable-" & $iEnum & "-" & $iRandom) $iEnum += 1 If ($iEnum > $maxEnum) Then Return SetError(2, 0, 0) WEnd Local $iSuccess = DirCreate($sPath & "\_IsWritable-" & $iEnum & "-" & $iRandom) Switch $iSuccess Case 1 $iTouch = DirRemove($sPath & "\_IsWritable-" & $iEnum & "-" & $iRandom, 1) Return SetError($iTouch < 1, 0, $iTouch) Case Else Return SetError(3, 0, 0) EndSwitch EndFunc ;==>_Directory_Is_Accessible Func _File_Is_Accessible($sFile, $iTouch = 0) If ((Not FileExists("\\?\" & $sFile)) Or StringInStr(FileGetAttrib("\\?\" & $sFile), "D", 2)) Then Return SetError(1, 0, 0) Local $oFileAttrib = FileGetAttrib("\\?\" & $sFile) If $iTouch Then FileSetAttrib("\\?\" & $sFile, "-RHS") _TakeOwnership($sFile, "Everyone", 1) EndIf If StringInStr(FileGetAttrib("\\?\" & $sFile), "R", 2) Then Return 3 Local $hFile = __WinAPI_CreateFileEx("\\?\" & $sFile, 3, 0x80000000 + 0x40000000, 0x00000001 + 0x00000002 + 0x00000004, 0x02000000) Local $iReturn = $hFile __WinAPI_CloseHandle($hFile) If ($iReturn = 0) Then Return 2 Return 1 EndFunc ;==>_File_Is_Accessible Func _TakeOwnership($sFile, $iUserName = "Everyone", $sRecurse = 1) If ($iUserName = Default) Or (StringStripWS($iUserName, 8) = '') Then $iUserName = "Everyone" If ($sRecurse = Default) Or ($sRecurse = True) Or ($sRecurse > 0) Then $sRecurse = 1 Else $sRecurse = 0 EndIf Local $osNotIsEnglish = True Switch @OSLang Case "0009", "0409", "0809", "0C09", "1009", "1409", "1809", "1C09", "2009", "2409", "2809", "2C09", "3009", "3409", "3C09", "4009", "4409", "4809", "4C09" $osNotIsEnglish = False Case "3809", "5009", "5409", "5809", "5C09", "6009", "6409" $osNotIsEnglish = False EndSwitch If StringInStr($iUserName, ' ') Then $iUserName = '"' & $iUserName & '"' If ($sRecurse = Default) Then $sRecurse = 1 If Not FileExists($sFile) Then Return SetError(1, 0, $sFile) If StringInStr(FileGetAttrib($sFile), 'D') <> 0 Then If $sRecurse Then RunWait(@ComSpec & ' /c takeown /f "' & $sFile & '" /R /D Y', '', @SW_HIDE) If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /T /C /G Administrators:F', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /T /C /G Users:F', '', @SW_HIDE) RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /T /C /G ' & $iUserName & ':F', '', @SW_HIDE) If $osNotIsEnglish Then If ($iUserName = "Everyone") Then $iUserName = '*S-1-1-0' If ($iUserName = '"' & 'Authenticated Users' & '"') Then $iUserName = '*S-1-5-11' EndIf If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Administrators:F /T /C /Q', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Users:F /T /C /Q', '', @SW_HIDE) RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant ' & $iUserName & ':F /T /C /Q', '', @SW_HIDE) Return SetError(0, 0, FileSetAttrib($sFile, "-RHS", 1)) Else RunWait(@ComSpec & ' /c takeown /f "' & $sFile & '" ', '', @SW_HIDE) If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G Administrators:F', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G Users:F', '', @SW_HIDE) RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G ' & $iUserName & ':F', '', @SW_HIDE) If $osNotIsEnglish Then If ($iUserName = "Everyone") Then $iUserName = '*S-1-1-0' If ($iUserName = '"' & 'Authenticated Users' & '"') Then $iUserName = '*S-1-5-11' EndIf If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Administrators:F /C /Q', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Users:F /C /Q', '', @SW_HIDE) RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant ' & $iUserName & ':F /C /Q', '', @SW_HIDE) Return SetError(0, 0, FileSetAttrib($sFile, "-RHS", 0)) EndIf Else RunWait(@ComSpec & ' /c takeown /f "' & $sFile & '"', '', @SW_HIDE) If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G Administrators:F', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G Users:F', '', @SW_HIDE) RunWait(@ComSpec & ' /c Echo y|Cacls "' & $sFile & '" /C /G ' & $iUserName & ':F', '', @SW_HIDE) If $osNotIsEnglish Then If ($iUserName = "Everyone") Then $iUserName = '*S-1-1-0' If ($iUserName = '"' & 'Authenticated Users' & '"') Then $iUserName = '*S-1-5-11' EndIf If $iUserName <> 'Administrators' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Administrators:F /Q', '', @SW_HIDE) If $iUserName <> 'Users' Then RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant Users:F /Q', '', @SW_HIDE) RunWait(@ComSpec & ' /c iCacls "' & $sFile & '" /grant ' & $iUserName & ':F /Q', '', @SW_HIDE) Return SetError(0, 0, FileSetAttrib($sFile, "-RHS")) EndIf Return $sFile EndFunc ;==>_TakeOwnership ; * -----:| Func _PathGet_Part($sFilePath, $returnPart = 0) ConsoleWrite(";~ + [" & $returnPart & "] PATH IN : " & $sFilePath & @CRLF) $sFilePath = _PathFix($sFilePath) Local $sDrive, $sParentDir, $sCurrentDir, $sFileNameNoExt, $sExtension, $sFileName, $sPathParentDir, $sPathCurrentDir, $sPathFileNameNoExt Local $aPathSplit = _SplitPath($sFilePath, $sDrive, $sParentDir, $sCurrentDir, $sFileNameNoExt, $sExtension, $sFileName, $sPathParentDir, $sPathCurrentDir, $sPathFileNameNoExt) ;Local $sCurrentDirPath= $sDrive&$sCurrentDir;StringRegExpReplace($aPathSplit, '\\[^\\]*$', '') ;Local $sCurrentDirName =StringRegExpReplace(_PathRemoveBackslash($sCurrentDirPath), '.*\\', '') ConsoleWrite(";~ - [1] Drive: " & $sDrive & @CRLF) ConsoleWrite(";~ - [2] ParentDir: " & $sParentDir & @CRLF) ConsoleWrite(";~ - [3] CurrentDir: " & $sCurrentDir & @CRLF) ConsoleWrite(";~ - [4] FileName NoExt: " & $sFileNameNoExt & @CRLF) ConsoleWrite(";~ - [5] Extension: " & $sExtension & @CRLF) ConsoleWrite(";~ - [6] FileName: " & $sFileName & @CRLF) ConsoleWrite(";~ - [7] PathParentDir: " & $sPathParentDir & @CRLF) ConsoleWrite(";~ - [8] PathCurrentDir: " & $sPathCurrentDir & @CRLF) ConsoleWrite(";~ - [9] PathFileName NoExt: " & $sPathFileNameNoExt & @CRLF) If (StringStripWS($sFileName, 8) == '') Then ConsoleWrite(";~ ! This path does not contain filenames and extensions!" & @CRLF) Switch $returnPart Case 1 ConsoleWrite(";~ - [1] Drive: " & $sDrive & @CRLF) Return $sDrive Case 2 ConsoleWrite(";~ - [2] ParentDir: " & $sParentDir & @CRLF) Return $sParentDir Case 3 ConsoleWrite(";~ - [3] CurrentDir: " & $sCurrentDir & @CRLF) Return $sCurrentDir Case 4 ConsoleWrite(";~ - [4] FileName NoExt: " & $sFileNameNoExt & @CRLF) Return $sFileNameNoExt Case 5 ConsoleWrite(";~ - [5] Extension: " & $sExtension & @CRLF) Return $sExtension Case 6 ConsoleWrite(";~ - [6] FileName: " & $sFileNameNoExt & $sExtension & @CRLF) Return $sFileName Case 7 ConsoleWrite(";~ - [7] PathParentDir: " & $sDrive & $sParentDir & @CRLF) Return $sPathParentDir Case 8 ConsoleWrite(";~ - [8] PathCurrentDir: " & $sDrive & $sParentDir & $sCurrentDir & @CRLF) Return $sPathCurrentDir Case 9 ConsoleWrite(";~ - [9] PathFileName NoExt: " & $sDrive & $sParentDir & $sCurrentDir & $sFileNameNoExt & @CRLF) Return $sPathFileNameNoExt Case Else ConsoleWrite("! [" & $returnPart & "] PATH OUT : " & $sFilePath & @CRLF) Return $sFilePath EndSwitch EndFunc ;==>_PathGet_Part ; * -----:| Func _SplitPath($sFilePath, ByRef $sDrive, ByRef $sParentDir, ByRef $sCurrentDir, ByRef $sFileNameNoExt, ByRef $sExtension, ByRef $sFileName, ByRef $sPathParentDir, ByRef $sPathCurrentDir, ByRef $sPathFileNameNoExt) ;ConsoleWrite(@CRLF & ";~ + PATH IN : " & $sFilePath & @CRLF) $sFilePath = _PathFix($sFilePath) _PathSplit_Ex($sFilePath, $sDrive, $sParentDir, $sCurrentDir, $sFileNameNoExt, $sExtension) ;Local $sCurrentDirPath= $sDrive&$sCurrentDir;StringRegExpReplace($aPathSplit, '\\[^\\]*$', '') ;Local $sCurrentDirName =StringRegExpReplace(_PathRemoveBackslash($sCurrentDirPath), '.*\\', '') $sFileName = $sFileNameNoExt & $sExtension $sPathParentDir = $sDrive & $sParentDir $sPathCurrentDir = $sDrive & $sParentDir & $sCurrentDir $sPathFileNameNoExt = $sDrive & $sParentDir & $sCurrentDir & $sFileNameNoExt Local $aSplitPath[10] = [$sDrive, $sParentDir, $sCurrentDir, $sFileNameNoExt, $sExtension, $sFileName, $sPathParentDir, $sPathCurrentDir, $sPathFileNameNoExt] Return $aSplitPath EndFunc ;==>_SplitPath ; * -----:| Func _PathSplit_Ex($sFilePath, ByRef $sDrive, ByRef $sParentDir, ByRef $sCurrentDir, ByRef $sFileNameNoExt, ByRef $sExtension) $sFilePath = _PathFix($sFilePath) $sFilePath = StringRegExp($sFilePath & " ", "^((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*?[\/\\]+)?([^\/\\]*[\/\\])?[\/\\]*((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", 1) $sDrive = (StringStripWS($sFilePath[1], 8) == "") ? "" : $sFilePath[1] $sFilePath[2] = StringRegExpReplace($sFilePath[2], "[\/\\]+\h*", "\" & StringLeft($sFilePath[2], 1)) $sParentDir = (StringStripWS($sFilePath[2], 8) == "") ? "" : $sFilePath[2] $sCurrentDir = (StringStripWS($sFilePath[3], 8) == "") ? "" : $sFilePath[3] $sFileNameNoExt = (StringStripWS($sFilePath[4], 8) == "") ? "" : $sFilePath[4] $sExtension = (StringStripWS($sFilePath[5], 8) == "") ? "" : StringStripWS($sFilePath[5], 3) Return $sFilePath EndFunc ;==>_PathSplit_Ex ; * -----:| Func _PathFix($sFilePath) $sFilePath = StringStripWS($sFilePath, 3) $sFilePath = StringReplace($sFilePath, "/", "\") While StringInStr($sFilePath, " \") $sFilePath = StringReplace($sFilePath, " /", "\") WEnd While StringInStr($sFilePath, "\ ") $sFilePath = StringReplace($sFilePath, "/ ", "\") WEnd If (FileExists($sFilePath) And StringInStr(FileGetAttrib($sFilePath), 'D')) Then $sFilePath = _PathRemove_Backslash($sFilePath) & "\" EndIf Return $sFilePath EndFunc ;==>_PathFix ; * -----:| Func _PathRemove_Backslash($sPath) If StringRight($sPath, 1) == '\' Then ;$sPath = StringRegExpReplace($sPath, "\\$", "") ;$sPath = StringRegExpReplace($sPath, "(.*)(\\)\z", "$1") $sPath = StringTrimRight($sPath, 1) EndIf Return $sPath EndFunc ;==>_PathRemove_Backslash ; * -----:| Func __WinAPI_GetLastError(Const $_iCallerError = @error, Const $_iCallerExtended = @extended) Local $aCall = DllCall("kernel32.dll", "dword", "GetLastError") Return SetError($_iCallerError, $_iCallerExtended, $aCall[0]) EndFunc ;==>__WinAPI_GetLastError Func __WinAPI_CreateFileEx($sFilePath, $iCreation, $iAccess = 0, $iShare = 0, $iFlagsAndAttributes = 0, $tSecurity = 0, $hTemplate = 0) Local $aCall = DllCall('kernel32.dll', 'handle', 'CreateFileW', 'wstr', $sFilePath, 'dword', $iAccess, 'dword', $iShare, 'struct*', $tSecurity, 'dword', $iCreation, 'dword', $iFlagsAndAttributes, 'handle', $hTemplate) If @error Then Return SetError(@error, @extended, 0) If $aCall[0] = Ptr(-1) Then Return SetError(10, __WinAPI_GetLastError(), 0) Return $aCall[0] EndFunc ;==>__WinAPI_CreateFileEx Func __WinAPI_CloseHandle($hObject) Local $aCall = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hObject) If @error Then Return SetError(@error, @extended, False) Return $aCall[0] EndFunc ;==>__WinAPI_CloseHandle ; * -----:|2 points -
Stringleft and Array
pixelsearch and one other reacted to Musashi for a topic
Or : #include <array.au3> Local $aArray = [111111111, 2222222222, 3333333333] _ArrayDisplay($aArray) For $i = 0 To UBound ($aArray) -1 Step 1 $aArray[$i] = StringLeft($aArray[$i] , 3) Next _ArrayDisplay($aArray)2 points -
Stringleft and Array
ahmeddzcom and one other reacted to Danp2 for a topic
Take a look at the _ArrayTrim function.2 points -
Seems to me that you are getting zero file from FileListToArray. I could be wrong though since I do not have your computer. But overall, you need to learn how to debug your own scripts. Put some ConsoleWrite and _ArrayDisplay after key statements to follow the path of your script and understand why it does not work as expected.2 points
-
Control Viewer - AutoIt Window Info Tool
mythicalzxc reacted to Yashied for a topic
LAST VERSION - 1.1 18-May-12 Control Viewer (CV) is a replacement of AutoIt Window Info with a number of advantages. I tried to stick to the interface of the last, so you almost do not have to be retrained. During testing, I never managed to find any controls that could not be identified by CV (on the contrary, shows a lot of hidden controls, especially for the system windows). The all program settings are stored in the following registry key: HKEY_CURRENT_USERSoftwareY'sControl Viewer The main differences CV from AWI Shows the complete list of all existing controls for the window that are interested (visible, hidden and deleted controls are displayed with different colors that can be changed to any other).Dynamically changing information during search for the windows and their controls.Ability to quickly switch between controls in the list.Ability to show/hide any controls from the list (useful for the overlaping controls).Information for the Style and ExStyle parameters shown in the form of hexadecimal valuesββ, and as its flags.Added the PID and Path parameters in the Window tab and ability to quickly open a folder that containing the process file.Added the coordinate system relative to the selected control.Shows a color of the selected pixel in RGB and BGR formats.Shows an example fill of the selected color.Ability to select the text encoding (affects the Text parameter in the Control tab).The complete change the appearance of pop-up frame for the selected controls.Simple and convenient tool to get a screenshot of the part screen of interest for publication on the forum (Capture tab).Create a report in the clipboard or a text file for subsequent publication on the forum.Search all running AutoIt scripts and their windows in the system (AutoIt tab).User-friendly interface. Used shortcuts Ctrl+Alt+T - Enable/Disable "Always On Top" mode (also available from the menu). Ctrl+Alt+H - Enable/Disable highlight selected controls (also available from the menu). Ctrl+A - Select all text (works in any input field). Ctrl - Hold down when moving the mouse to scroll the screenshot (Capture tab). Shift - Hold down when stretching/compression of the contour frame for an equilateral resizing screenshots (Capture tab). DoubleClick (on the screenshot) - Save the image to a file (Capture tab). DoubleClick (on any list item) - Open a folder with the file of the process or AutoIt script (AutoIt tab). Del (on any list item) - Close process (AutoIt tab). F5 - Updating the list (AutoIt tab). If anyone have any questions or comments about CV, please post it in this thread. I will be glad to any feedback and suggestions. Files to download Binary (x86 and x64) Redirection to CV_bin.zip, 1.14 MB CV_bin.html Source Redirection to CV_source.zip, 691 KB CV_source.html1 point -
Stringleft and Array
ahmeddzcom reacted to OJBakker for a topic
You are right. _ArrayTrim() won't work. You want as parameter: Number of characters to remove. _ArrayTrim() wants as parameter: Number of characters to trim.1 point -
Stringleft and Array
ahmeddzcom reacted to SOLVE-SMART for a topic
I am a bit confused @ahmeddzcom, because the solution should be @Danp2s post in my opinion. Of course at the end it's up to you what you prefer (and also sorry to @Musashi - nothing personaly π). But for other people it would be more helpful to know about what is already provided by AutoIt (Danp2 post) and this should be the solution. Best regards Sven1 point -
Stringleft and Array
ahmeddzcom reacted to SOLVE-SMART for a topic
Hi @ahmeddzcom, like @Musashi already posted (only few minutes before I could write this here down π π #include-once #include <Array.au3> Local $aArray = [1111111111, 2222222222, 3333333333] _ArrayDisplay($aArray, 'Before') Local Const $aNewArray = _StringLeftIn1dArray($aArray, 3) _ArrayDisplay($aNewArray, 'After') Func _StringLeftIn1dArray($aArray, $iCount) For $i = 0 To Ubound($aArray) - 1 Step 1 $aArray[$i] = StringLeft($aArray[$i], $iCount) Next Return $aArray EndFunc [...] anyways, I guess the suggestion of @Danp2 might be the best - it's already provided by AutoIt, so no need for a custom function. Best regards Sven1 point -
AutoIt UDF Working with files and folders
noellarkin reacted to SOLVE-SMART for a topic
Thanks @VIP for your work π . A few more words to your UDF would be nice π . I mean of course we can/could walk through the UDF functions and have a look, but a bit more advertisment for your work would probably help you to get more attention about it. I will have a deeper look later on. Your ConsoleWrite() output is good for the first understanding, but a bit more and you will probably get more of "props to you". Best regards Sven1 point -
Mail2File GUI to save clipboard data as file
ioa747 reacted to SOLVE-SMART for a topic
Hi @ioa747, I still didn't try your program yet, but thank you for the video which is pretty easy to understand π π . Feedback after a tryout follows. Best regards Sven1 point -
Mail2File GUI to save clipboard data as file
SOLVE-SMART reacted to ioa747 for a topic
since I'm not that good at words . I made for you1 point