-
Posts
3,079 -
Joined
-
Last visited
-
Days Won
52
Everything posted by Subz
-
You could just use String functions example: Global $g_iLinks, $g_aLinks[] = ["https://www.example.org/list/item.9308/","https://www.example.org/list/item.9309","https://www.example.org/list/item.9310","https://www.example.org/list/item.9311","https://www.example.org/list/item.9312"] For $i = 0 To UBound($g_aLinks) - 1 $g_iLinks = StringRight($g_aLinks[$i], 1) = "/" ? -2 : -1 ConsoleWrite(StringTrimLeft($g_aLinks[$i], StringInStr($g_aLinks[$i], "/", 0, $g_iLinks)) & @CRLF) Next
-
How can I mount and unmount iso files?
Subz replied to Draygoes's topic in AutoIt General Help and Support
You can use PowerShell commands: Mount-DiskImage (Storage) | Microsoft Docs Dismount-DiskImage (Storage) | Microsoft Docs -
A few different ways: #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls") Global $oWorkbook2 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel2.xls") ;~ Option 1 - Using ActiveSheet Local $oRange1 = $oWorkbook1.ActiveSheet.Columns("A") Local $oRange2 = $oWorkbook2.ActiveSheet.Columns("C") _Excel_RangeCopyPaste($oWorkbook1.ActiveSheet, $oRange1, $oRange2) ;~ Option 2 - Using Worksheet index Local $oRange1 = $oWorkbook1.Worksheets(1).Columns("A") Local $oRange2 = $oWorkbook2.Worksheets(1).Columns("C") _Excel_RangeCopyPaste($oWorkbook1.Worksheets(1), $oRange1, $oRange2) ;~ Option 3 - Using Worksheet name Local $oRange1 = $oWorkbook1.Worksheets("Sheet1").Columns("A") Local $oRange2 = $oWorkbook2.Worksheets("Sheet1").Columns("C") _Excel_RangeCopyPaste($oWorkbook1.Worksheets(1), $oRange1, $oRange2)
-
Please post the entire script along with the gui, similar to the script I posted above.
-
Are your dates in english? are they also in the format :month day i.e. January 9 or another format?
-
Basic example, using Melba23 Date_Time_Convert UDF #include <Array.au3> #include <Date.au3> #include <DTC.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> Local $sDates = "July 3" & @CRLF & _ "July 7" & @CRLF & _ "July 5 - January 9th *" & @CRLF & _ "July 2 - 4" & @CRLF & _ "July 20 - August 16" & @CRLF & _ "July 5 - 9" & @CRLF & _ "July 4 - May 30" & @CRLF & _ "July 6 - 12" & @CRLF & _ "July 5 - 8" & @CRLF & _ "July 6 - 14" & @CRLF & _ "July 20 - September 16**" & @CRLF & _ "July 6 - 12" Local $aDates = StringRegExp($sDates, "(?:.*-\s)([A-Za-z]*\s[0-9]*)", 3) _ArrayColInsert($aDates, 1) For $i = 0 To UBound($aDates) - 1 $aDates[$i][1] = _Date_Time_Convert($aDates[$i][0] & " " & @YEAR, "MMMM d yyyy", "yyyy/MM/dd") Next GUICreate("Date Add", 220, 90) Local $sNewDate Local $idDates = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData($idDates, _ArrayToString($aDates, "|", -1, -1, "|", 0, 0), $aDates[0][0]) Local $idDays = GUICtrlCreateInput("4", 10, 35, 200, 20) Local $idNewDate = GUICtrlCreateInput("", 10, 60, 200, 20) GUISetState() _AddDays() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idDates _AddDays() EndSwitch WEnd Func _AddDays() Local $sNewDate = _DateAdd("D", GUICtrlRead($idDays), $aDates[_GUICtrlComboBox_GetCurSel($idDates)][1]) If Not @error Then GUICtrlSetData($idNewDate, _Date_Time_Convert($sNewDate, "yyyy/MM/dd", "MMMM d")) EndIf EndFunc
-
Convert the date into YYYY/MM/DD and then use _DateAdd
-
This worked for me. #include <Array.au3> Local $sString = "July 3" & @CRLF & _ "July 7" & @CRLF & _ "July 5 - 9 *" & @CRLF & _ "July 2 - 4" & @CRLF & _ "July 20 - August 16" & @CRLF & _ "July 5 - 9" & @CRLF & _ "July 4 - 6" & @CRLF & _ "July 6 - 12" & @CRLF & _ "July 5 - 8" & @CRLF & _ "July 6 - 14" & @CRLF & _ "July 20 - September 16**" & @CRLF & _ "July 6 - 12" Local $aString = StringRegExp($sString, "(?:.*-\s)([A-Za-z]*\s[0-9]*)", 3) _ArrayDisplay($aString)
-
how to put wmi information in an edit or richedit?
Subz replied to TesterMachine's topic in AutoIt GUI Help and Support
For GuiCtrlCreateEdit, you'd use GUICtrlSetData. -
how to put wmi information in an edit or richedit?
Subz replied to TesterMachine's topic in AutoIt GUI Help and Support
Try: _GUICtrlRichEdit_AppendText($edt, $Output) -
how to put wmi information in an edit or richedit?
Subz replied to TesterMachine's topic in AutoIt GUI Help and Support
Can you please post your code? -
The _Array functions do not work in these cases.
Subz replied to Mateocedillo's topic in AutoIt General Help and Support
As long as the file names are always numbers (or starting with a number) you could use something similar to the following: #include <Array.au3> #include <File.au3> Local $sFileDir = @ScriptDir & "\Dataset text" Local $sSavePath = $sFileDir & "\mylist.txt" Local $aFileList = _FileListToArrayRec($sFileDir & "\wavs", "*.wav", 1, 0, 2) If @error Then Exit MsgBox(4096, "Error", "No files found.") _SortList($aFileList) Local $hSavePath = FileOpen($sSavePath, 2) FileWrite($hSavePath, "wavs/" & _ArrayToString($aFileList, "|" & @CRLF & "wavs/", 1, -1, "|" & @CRLF & "wavs/", 0, 0) & "|" & @CRLF) FileClose($hSavePath) ShellExecute($sSavePath) Func _SortList(ByRef $_aSortList) _ArrayColInsert($_aSortList, 1) For $i = 1 To $_aSortList[0][0] $_aSortList[$i][1] = Number(StringReplace($_aSortList[$i][0], ".wav", "")) Next _ArraySort($_aSortList, 0, 1, 0, 1) EndFunc -
The _Array functions do not work in these cases.
Subz replied to Mateocedillo's topic in AutoIt General Help and Support
Works fine for me, although there were a number of other syntax errors, why not just use _FileListToArrayRec()? #include <Array.au3> #include <File.au3> Local $sFileDir = @ScriptDir & "\Dataset text" Local $sSavePath = $sFileDir & "\mylist.txt" Local $aFileList = _FileListToArrayRec($sFileDir & "\wavs", "*.wav", 1) If @error Then Exit MsgBox(4096, "Error", "No files found.") Local $hSavePath = FileOpen($sSavePath, 2) FileWrite($hSavePath, "wavs/" & _ArrayToString($aFileList, "|" & @CRLF & "wavs/", 1, -1, @CRLF) & "|" & @CRLF) FileClose($hSavePath) -
In your query you can use the following to only show enabled accounts: (!userAccountControl:1.2.840.113556.1.4.803:=2) You can use the whenCreated to get the account creation time, you can use StringFormat or as in the example below, use Melba23 Date_Time_Convert udf (see code below for download url) to convert the whenCreated into a readable format that can be used with _DateDiff to determine the date difference. #include <AD.au3> ;~ Download Melba23 Date_Time_Convert <DTC.au3> UDF from https://www.autoitscript.com/forum/topic/154684-date_time_convert-bugfix-version-27-may-15/ #include <DTC.au3> #include <File.au3> _GetUsers() Func _GetUsers() ; Open Connection to the Active Directory. _AD_Open() If @error Then Exit MsgBox(16, "Active Directory Error", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) ; Search all of AD for contractors and exclude _DT accounts. $aUserObjects = _AD_GetObjectsInOU("", "(&(objectcategory=person)(objectclass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2)(!(sAMAccountName=*_dt)(|(title=*contractor*)(title=*consultant*)(description=*contractor*)(description=*consultant*))))", 2, "sAMAccountName,accountExpires,whenCreated") ;~ Insert another column for date difference _ArrayColInsert($aUserObjects, 3) ;~ To delete an array item (removing accounts that are less than 90 days), you need to reverse the loop For $i = UBound($aUserObjects) - 1 To 1 Step - 1 ;~ Convert accountExpires to readable date/time If IsObj($aUserObjects[$i][1]) Then $aUserObjects[$i][1] = _GetADDateTime($aUserObjects[$i][1], 1) If $aUserObjects[$i][2] <> "" Then ;~ Convert whenCreated to readable date/time (required for _DateDiff function $aUserObjects[$i][2] = _Date_Time_Convert($aUserObjects[$i][2], "yyyyMMddHHmmss", "yyyy/MM/dd HH:mm:ss") ;~ Get date difference in days between whenCreated and accountExpires If $aUserObjects[$i][1] <> "n/a" Then $aUserObjects[$i][3] = _DateDiff("D", $aUserObjects[$i][2], $aUserObjects[$i][1]) ;~ If the date difference is less than 90 days then remove from the array If $aUserObjects[$i][3] < 90 Then _ArrayDelete($aUserObjects, $i) EndIf EndIf Next _ArrayDisplay($aUserObjects) _AD_Close() EndFunc ;==>_GetUsers Func _GetADDateTime($_oADObject, $_iFlag = 0) Local $sAD_DTStruct, $sTemp3 If $_iFlag = 1 Then If $_oADObject.LowPart = -1 Then Return 0 If $_oADObject.LowPart > 0 And $_oADObject.HighPart > 0 Then $sAD_DTStruct = DllStructCreate("dword low;dword high") DllStructSetData($sAD_DTStruct, "Low", $_oADObject.LowPart) DllStructSetData($sAD_DTStruct, "High", $_oADObject.HighPart) $sAD_Temp = _Date_Time_FileTimeToSystemTime(DllStructGetPtr($sAD_DTStruct)) $sTemp3 = _Date_Time_SystemTimeToTzSpecificLocalTime(DllStructGetPtr($sAD_Temp)) Return _Date_Time_SystemTimeToDateTimeStr($sTemp3, 1) EndIf EndIf ; Convert IADsLargeInteger parts to 100ns count $iLowPart = $_oADObject.LowPart $iHighPart = $_oADObject.HighPart If $iLowPart < 0 Then $iHighPart += 1; Compensate for IADsLargeInteger interface error $iDateParts= $iHighPart * 2 ^ 32 $iDateParts+= $iLowPart ; Check if user ever logged in If $iDateParts= 0 Then Return "n/a" Else ; Convert 100ns count to integer seconds $iSeconds = Floor($iDateParts/ 10000000) ; Convert seconds since 12:00AM January 01, 1601 to date string $sDateTime = _DateAdd("S", $iSeconds, "1601/01/01 00:00:00") ; Display result Return $sDateTime EndIf EndFunc
-
As I mentioned in a previous post your only displaying the last entry because _ArrayDisplay($aExpires) is outside of the loop. While this is true, if your first query returns 200 contractors samAccount names, you're then making 200 additional queries to get the account expiry date within the loop, meaning it's going to take several minutes to complete. By only using the single query and then converting it to a date as per my original post, it only takes several seconds to complete.
-
Believe Water meant you to use: For $i = 1 To UBound($aUserObjects) - 1 Still not sure why you don't just use as per my first post and then convert it into a readable date. $aUserObjects = _AD_GetObjectsInOU("", "(&(objectcategory=person)(objectclass=user) (!(sAMAccountName=*_dt)(|(title=*contractor*) (title=*consultant*)(description=*contractor*) (description=*consultant*))))", 2, "sAMAccountName,accountExpires")
-
You would need to use _ArrayDisplay($aExpires) within the loop to show each contractor, however what happens when you use my original code? The _GetADDateTime() function is a lot faster than using _AD_GetObjectProperties as you're querying each user. However you don't mind waiting for the results just use something like: $aUserObjects = _AD_GetObjectsInOU("", "(&(objectcategory=person)(objectclass=user) (!(sAMAccountName=*_dt)(|(title=*contractor*) (title=*consultant*)(description=*contractor*) (description=*consultant*))))", 2, "sAMAccountName") _ArrayColInsert($aUserObjects, 1) For $i = 0 To UBound($aUserObjects) - 1 $aExpires = _AD_GetObjectProperties($aUserObjects[$i][0], "accountExpires", True, True) If Not @error Then $aUserObjects[$i][1] = $aExpires[1][1] Next _ArrayDisplay($aUserObjects)
-
Can you try one of the contractor accounts samAccountNames in place of @Username? Also just noticed that your third parameter was blank, try using: _AD_GetObjectProperties(@UserName, "accountExpires", True, True) Although the first code I posted returns the information alot faster.
-
If the following doesn't return accountExpiry info, then maybe you don't have the permissions to read that attribute? #include <AD.au3> _AD_Open() If @error Then Exit MsgBox(16, "Active Directory Error", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) Local $aProperties = _AD_GetObjectProperties(@UserName) _ArrayDisplay($aProperties, "Active Directory Functions - Example 1 - Properties for user '" & @UserName & "'") _AD_Close()
-
Did you use my script above? The accountExpires returns an object which will not be displayed within the array, which is why I loop through the results and convert the object into a readable date/time.
-
Also unsure why your script hangs we have several thousand users and usually takes several seconds to display the full list of users, although I always use filtered list e.g.: _AD_GetObjectsInOU("", "(&(objectcategory=person)(objectclass=user)(sAMAccountName=*))", 2, "sAMAccountName,accountexpires")
-
This is normally what I use to get account expiry date: #include <AD.au3> _GetUsers() Func _GetUsers() _AD_Open() If @error Then Exit MsgBox(16, "Active Directory Error", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) ; Search all of AD for contractors and exclude _DT accounts. $aUserObjects = _AD_GetObjectsInOU("", "(&(objectcategory=person)(objectclass=user) (!(sAMAccountName=*_dt)(|(title=*contractor*) (title=*consultant*)(description=*contractor*) (description=*consultant*))))", 2, "sAMAccountName,accountExpires") For $i = 0 To UBound($aUserObjects) - 1 If IsObj($aUserObjects[$i][1]) Then $aUserObjects[$i][1] = _GetADDateTime($aUserObjects[$i][1], 1) Next _ArrayDisplay($aUserObjects) _AD_Close() EndFunc ;==>_GetUsers Func _GetADDateTime($_oADObject, $_iFlag = 0) Local $sAD_DTStruct, $sTemp3 If $_iFlag = 1 Then If $_oADObject.LowPart = -1 Then Return 0 If $_oADObject.LowPart > 0 And $_oADObject.HighPart > 0 Then $sAD_DTStruct = DllStructCreate("dword low;dword high") DllStructSetData($sAD_DTStruct, "Low", $_oADObject.LowPart) DllStructSetData($sAD_DTStruct, "High", $_oADObject.HighPart) $sAD_Temp = _Date_Time_FileTimeToSystemTime(DllStructGetPtr($sAD_DTStruct)) $sTemp3 = _Date_Time_SystemTimeToTzSpecificLocalTime(DllStructGetPtr($sAD_Temp)) Return _Date_Time_SystemTimeToDateTimeStr($sTemp3, 1) EndIf EndIf ; Convert IADsLargeInteger parts to 100ns count $iLowPart = $_oADObject.LowPart $iHighPart = $_oADObject.HighPart If $iLowPart < 0 Then $iHighPart += 1; Compensate for IADsLargeInteger interface error $iDateParts= $iHighPart * 2 ^ 32 $iDateParts+= $iLowPart ; Check if user ever logged in If $iDateParts= 0 Then Return "n/a" Else ; Convert 100ns count to integer seconds $iSeconds = Floor($iDateParts/ 10000000) ; Convert seconds since 12:00AM January 01, 1601 to date string $sDateTime = _DateAdd("S", $iSeconds, "1601/01/01 00:00:00") ; Display result Return $sDateTime EndIf EndFunc
-
Does using the file type help (see last post)? You could also use _FileListToArray within _GetShortcutPos() to find all files with $sShortcutName & ".*" to get a list of files with same name, without changing the registry: Local $aShortcuts = _FileListToArrayRec(@DesktopCommonDir, $sShortcutName & ".*", 1, 0, 0)
-
GuiFileList not showing Set Data
Subz replied to BatMan22's topic in AutoIt General Help and Support
It would make things easier if you posted runnable code for example, does the following work for you? #include <Array.au3> #include <GUIConstantsEx.au3> #include <ListBoxConstants.au3> #include <WindowsConstants.au3> Example() Func Example() ;~ Example Data Local $aExample[400] For $i = 0 To 399 $aExample[$i] = "Example " & $i Next ;~ List Gui Example GUICreate("List Example", 320, 220) Local $idList = GUICtrlCreateList("", 10, 10, 300, 200, BitOR($LBS_EXTENDEDSEL, $WS_VSCROLL)) GUICtrlSetLimit($idList, 200) GUICtrlSetData($idList, "First|" & _ArrayToString($aExample)) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc -
There are four columns in the list view you can use: Name: Shortcuts do not show the extension, other file types do for example filename.txt or filename.msi File Size: example 1.31 KB File Type: example Shortcut, TXT file, File Folder etc... Created Date: xx/xx/xxxx x:xx AM/PM The following would show you the file type of each desktop item: Func _GetShortcutPos($_sShortcutName = "") Local $sShortcutName Local $bShortcut = $_sShortcutName = "" ? False : True ;~ Desktop handle Local $hDesktopListview = ControlGetHandle("[CLASS:Progman]", "", "[CLASS:SysListView32;INSTANCE:1]") If @error Then Return SetError(1, 0) ;~ Desktop shortcut count Local $iShortcutCount = _GUICtrlListView_GetItemCount($hDesktopListview) If $iShortcutCount > 0 Then Local $aShortcutPos[$iShortcutCount][4] For $i = 0 To UBound($aShortcutPos, 1) - 1 If $bShortcut Then Dim $aShortcutPos[0][4] $sShortcutName = _GUICtrlListView_GetItemText($hDesktopListview, $i) If $sShortcutName = $_sShortcutName Then Dim $aShortcutPos[1][4] ;~ Desktop item name $aShortcutPos[0][0] = $sShortcutName ;~ Desktop item x position $aShortcutPos[0][1] = _GUICtrlListView_GetItemPositionX($hDesktopListview, $i) ;~ Desktop item y position $aShortcutPos[0][2] = _GUICtrlListView_GetItemPositionY($hDesktopListview, $i) ;~ Desktop item file type $aShortcutPos[0][3] = _GUICtrlListView_GetItemText($hDesktopListview, $i, 2) Return SetError((UBound($aShortcutPos) > 0 ? 0 : 1), 0, $aShortcutPos) EndIf Else $aShortcutPos[$i][0] = _GUICtrlListView_GetItemText($hDesktopListview, $i) $aShortcutPos[$i][1] = _GUICtrlListView_GetItemPositionX($hDesktopListview, $i) $aShortcutPos[$i][2] = _GUICtrlListView_GetItemPositionY($hDesktopListview, $i) $aShortcutPos[$i][3] = _GUICtrlListView_GetItemText($hDesktopListview, $i, 2) EndIf Next Else Return SetError(1, 0) EndIf Return SetError((UBound($aShortcutPos) > 0 ? 0 : 1), 0, $aShortcutPos) EndFunc