Leaderboard
Popular Content
Showing content with the highest reputation on 04/14/2017 in all areas
-
I can confirm that this is the case as I've been to one last year.2 points
-
BinaryToAu3Kompressor v1.0.5.4 It's now possible to see the best compression ratio using LZMA, LZNT and Base64 compressions with differents combinations. Nothing too complicate, you drag'n drop a file on the picture and script Test all compression types and return the ratios. ( Test duration depends of file size, slowest compression is LZNT, but all decompressions are fast ) Free to you after, to choose the compression(s) you want... Yes, LZMA needs a dll ( embedded & compressed in script ) but brings a powerfull compression. It opens scite with your file compressed to an au3 script with or without decompression function as you want. Hold Left Shift key when clicking button for just copy script to clipboard. Use the 3 compressions at a time works but doesn't give a good ratio, that's why i don't display it. Usefull for little files you want include in your scripts ! No externals files needed, they are already in script. Previous downloads : 1103 Source and Executable BinaryToAu3Kompressor will be added to the next version of >SciTEHopper Thanks to Ward for his >Base64.au3 and LZMA.au3, and trancexx for his >LZNT functions and his >Base64Decode function.1 point
-
Actually, it's working exactly as designed. You may see that error one or more times because the website hasn't fully loaded. Take a look at the While loop and that's were the _IEGetObjById call is located.1 point
-
This seems to work -- #include <IE.au3> $oIE = _IECreate('http://www.supremenewyork.com/shop/all/accessories') _IELinkClickByText($oIE,'Supreme®/Hanes® Boxer Briefs (4 Pack)') ; Wait until form is present While NOT IsObj(_IEGetObjById ($oIE, "cart-addf")) Sleep(500) WEnd $oForm = _IEFormGetCollection($oIE, 0) $oSelect = _IEFormElementGetObjByName($oForm, 'size') _IEFormElementOptionSelect($oSelect, 41617) P.S. Not sure why you took this to PM unless you're sensitive about your briefs. :-P1 point
-
#include <array.au3> local $aArray[0][2] local $oQuery = ["Static Text 1" , "Data 1" , "Static Text 2" , "Data 2" , "Static Text 3" , "Data 3" ,"Static Text 4" , "Data 4"] $flag = "" $i = 0 For $oElement In $oQuery If $flag = 0 Then _ArrayAdd($aArray , $oQuery[$i] , 0) $flag = 1 $i+=1 Else $aArray[ubound($aArray) - 1][1]=$oQuery[$i] $flag = 0 $i+=1 EndIf Next _ArrayDisplay($aArray) I ask because it seems you could do it in the loop, if the return is any kind of reliable format. I don't have a nice object example but the above array example should accurately reflect the thought1 point
-
#include-once #include <Array.au3> Local $string = "Column A|Column B" & @CRLF & _ "Static Text 1|Data 1" & @CRLF & _ "Static Text 2|Data 2" & @CRLF & _ "Static Text 3|Data 3" & @CRLF & _ "Static Text 4|Data 4" Local $arr[1][2] _ArrayAdd($arr, $string, 0, "|", @CRLF) _ArrayDelete($arr, 0) _ArrayDisplay($arr)1 point
-
Skysnake, Perhaps the Modal MsgBox Styles tutorial in the Wiki would help? M231 point
-
Value Meaning MB_APPLMODAL 0x00000000L The user must respond to the message box before continuing work in the window identified by the hWnd parameter. However, the user can move to the windows of other threads and work in those windows. Depending on the hierarchy of windows in the application, the user may be able to move to other windows within the thread. All child windows of the parent of the message box are automatically disabled, but pop-up windows are not. MB_APPLMODAL is the default if neither MB_SYSTEMMODAL nor MB_TASKMODAL is specified. MB_SYSTEMMODAL 0x00001000L Same as MB_APPLMODAL except that the message box has the WS_EX_TOPMOST style. Use system-modal message boxes to notify the user of serious, potentially damaging errors that require immediate attention (for example, running out of memory). This flag has no effect on the user's ability to interact with windows other than those associated with hWnd. MB_TASKMODAL 0x00002000L Same as MB_APPLMODAL except that all the top-level windows belonging to the current thread are disabled if the hWnd parameter is NULL. Use this flag when the calling application or library does not have a window handle available but still needs to prevent input to other windows in the calling thread without suspending other threads.1 point
-
I had a PM with czardas the day he posted this as I had more-or-less the same assumption. While the code executes, there are some "issues" with it. How about the 2nd part: how would you make it more efficient (clear and concise)?1 point
-
This example adds a timeout parameter and two extra command lines to the existing _ArrayDisplay() function. After the timeout has elapsed _ArrayDisplayEx() will be automatically closed. #include <Array.au3> Local $a = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 0], [11, 12, 13, 14, 15]] _ArrayDisplayEx($a, Default, Default, Default, Default, Default, Default, Default, Default, 2) ; $iTimeOut - The amount of time for the array to be displayed is in secs, Func _ArrayDisplayEx(Const ByRef $aArray, $sTitle = Default, $sArrayRange = Default, $iFlags = Default, $vUser_Separator = Default, $sHeader = Default, $iMax_ColWidth = Default, $iAlt_Color = Default, $hUser_Function = Default, $iTimeOut = Default) If $iTimeOut <> Default Then Local $iTimmer = TimerInit() ; <<- 1 of 2 lines added for timeout. ; Default values If $sTitle = Default Then $sTitle = "ArrayDisplay" If $sArrayRange = Default Then $sArrayRange = "" If $iFlags = Default Then $iFlags = 0 If $vUser_Separator = Default Then $vUser_Separator = "" If $sHeader = Default Then $sHeader = "" If $iMax_ColWidth = Default Then $iMax_ColWidth = 350 If $iAlt_Color = Default Then $iAlt_Color = 0 If $hUser_Function = Default Then $hUser_Function = 0 ; Check for transpose, column align, verbosity and button and "Row" column visibility Local $iTranspose = BitAND($iFlags, 1) Local $iColAlign = BitAND($iFlags, 6) ; 0 = Left (default); 2 = Right; 4 = Center Local $iVerbose = BitAND($iFlags, 8) Local $iButtonMargin = ((BitAND($iFlags, 32)) ? (0) : ((BitAND($iFlags, 16)) ? (20) : (40))) ; Flag 32 = 0; flag 16 = 20; neither flag = 40 Local $iNoRow = BitAND($iFlags, 64) ; Check valid array Local $sMsg = "", $iRet = 1 If IsArray($aArray) Then ; Dimension checking Local $iDimension = UBound($aArray, $UBOUND_DIMENSIONS), $iRowCount = UBound($aArray, $UBOUND_ROWS), $iColCount = UBound($aArray, $UBOUND_COLUMNS) If $iDimension > 2 Then $sMsg = "Larger than 2D array passed to function" $iRet = 2 EndIf Else $sMsg = "No array variable passed to function" EndIf If $sMsg Then If $iVerbose And MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR + $MB_YESNO, _ "ArrayDisplay Error: " & $sTitle, $sMsg & @CRLF & @CRLF & "Exit the script?") = $IDYES Then Exit Else Return SetError($iRet, 0, "") EndIf EndIf ; Determine copy separator Local $iCW_ColWidth = Number($vUser_Separator) ; Separator handling Local $sAD_Separator = ChrW(0xFAB1) ; Set separator to use in this UDF and store existing one Local $sCurr_Separator = Opt("GUIDataSeparatorChar", $sAD_Separator) ; Set default user separator if required If $vUser_Separator = "" Then $vUser_Separator = $sCurr_Separator ; Declare variables Local $vTmp, $iRowLimit = 65525, $iColLimit = 250 ; Row = AutoIt 64k limit minus UDF controls; Column - arbitrary limit ; Set original dimensions for data display Local $iDataRow = $iRowCount Local $iDataCol = $iColCount ; Set display limits for dimensions - column value only set for 2D arrays Local $iItem_Start = 0, $iItem_End = $iRowCount - 1, $iSubItem_Start = 0, $iSubItem_End = (($iDimension = 2) ? ($iColCount - 1) : (0)) ; Flag to determine if range set Local $bRange_Flag = False, $avRangeSplit ; Check for range settings If $sArrayRange Then ; Split into separate dimension sections Local $aArray_Range = StringRegExp($sArrayRange & "||", "(?U)(.*)\|", 3) ; Dimension 1 If $aArray_Range[0] Then $avRangeSplit = StringSplit($aArray_Range[0], ":") If @error Then $iItem_End = Number($avRangeSplit[1]) Else $iItem_Start = Number($avRangeSplit[1]) $iItem_End = Number($avRangeSplit[2]) EndIf EndIf ; Check row bounds If $iItem_Start > $iItem_End Then $vTmp = $iItem_Start $iItem_Start = $iItem_End $iItem_End = $vTmp EndIf If $iItem_Start < 0 Then $iItem_Start = 0 If $iItem_End > $iRowCount - 1 Then $iItem_End = $iRowCount - 1 ; Check if range set If $iItem_Start <> 0 Or $iItem_End <> $iRowCount - 1 Then $bRange_Flag = True ; Dimension 2 If $iDimension = 2 And $aArray_Range[1] Then $avRangeSplit = StringSplit($aArray_Range[1], ":") If @error Then $iSubItem_End = Number($avRangeSplit[1]) Else $iSubItem_Start = Number($avRangeSplit[1]) $iSubItem_End = Number($avRangeSplit[2]) EndIf ; Check column bounds If $iSubItem_Start > $iSubItem_End Then $vTmp = $iSubItem_Start $iSubItem_Start = $iSubItem_End $iSubItem_End = $vTmp EndIf If $iSubItem_Start < 0 Then $iSubItem_Start = 0 If $iSubItem_End > $iColCount - 1 Then $iSubItem_End = $iColCount - 1 ; Check if range set If $iSubItem_Start <> 0 Or $iSubItem_End <> $iColCount - 1 Then $bRange_Flag = True EndIf EndIf ; Create data display Local $sDisplayData = "[" & $iDataRow ; Check if rows will be truncated Local $bTruncated = False If $iTranspose Then If $iItem_End - $iItem_Start > $iColLimit Then $bTruncated = True $iItem_End = $iItem_Start + $iColLimit - 1 EndIf Else If $iItem_End - $iItem_Start > $iRowLimit Then $bTruncated = True $iItem_End = $iItem_Start + $iRowLimit - 1 EndIf EndIf If $bTruncated Then $sDisplayData &= "*]" Else $sDisplayData &= "]" EndIf If $iDimension = 2 Then $sDisplayData &= " [" & $iDataCol If $iTranspose Then If $iSubItem_End - $iSubItem_Start > $iRowLimit Then $bTruncated = True $iSubItem_End = $iSubItem_Start + $iRowLimit - 1 EndIf Else If $iSubItem_End - $iSubItem_Start > $iColLimit Then $bTruncated = True $iSubItem_End = $iSubItem_Start + $iColLimit - 1 EndIf EndIf If $bTruncated Then $sDisplayData &= "*]" Else $sDisplayData &= "]" EndIf EndIf ; Create tooltip data Local $sTipData = "" If $bTruncated Then $sTipData &= "Truncated" If $bRange_Flag Then If $sTipData Then $sTipData &= " - " $sTipData &= "Range set" EndIf If $iTranspose Then If $sTipData Then $sTipData &= " - " $sTipData &= "Transposed" EndIf ; Split custom header on separator Local $asHeader = StringSplit($sHeader, $sCurr_Separator, $STR_NOCOUNT) ; No count element If UBound($asHeader) = 0 Then Local $asHeader[1] = [""] $sHeader = "Row" Local $iIndex = $iSubItem_Start If $iTranspose Then ; All default headers For $j = $iItem_Start To $iItem_End $sHeader &= $sAD_Separator & "Col " & $j Next Else ; Create custom header with available items If $asHeader[0] Then ; Set as many as available For $iIndex = $iSubItem_Start To $iSubItem_End ; Check custom header available If $iIndex >= UBound($asHeader) Then ExitLoop $sHeader &= $sAD_Separator & $asHeader[$iIndex] Next EndIf ; Add default headers to fill to end For $j = $iIndex To $iSubItem_End $sHeader &= $sAD_Separator & "Col " & $j Next EndIf ; Remove "Row" header if not needed If $iNoRow Then $sHeader = StringTrimLeft($sHeader, 4) ; Display splash dialog if required If $iVerbose And ($iItem_End - $iItem_Start + 1) * ($iSubItem_End - $iSubItem_Start + 1) > 10000 Then SplashTextOn("ArrayDisplay", "Preparing display" & @CRLF & @CRLF & "Please be patient", 300, 100) EndIf ; Convert array into ListViewItem compatible lines Local $iBuffer = 4094 ; Max characters a ListView will display (Windows limitation) If $iTranspose Then ; Swap dimensions $vTmp = $iItem_Start $iItem_Start = $iSubItem_Start $iSubItem_Start = $vTmp $vTmp = $iItem_End $iItem_End = $iSubItem_End $iSubItem_End = $vTmp EndIf Local $avArrayText[$iItem_End - $iItem_Start + 1] For $i = $iItem_Start To $iItem_End ; Add row number if required If Not $iNoRow Then $avArrayText[$i - $iItem_Start] = "[" & $i & "]" For $j = $iSubItem_Start To $iSubItem_End If $iDimension = 1 Then If $iTranspose Then Switch VarGetType($aArray[$j]) Case "Array" $vTmp = "{Array}" Case Else $vTmp = $aArray[$j] EndSwitch Else Switch VarGetType($aArray[$i]) Case "Array" $vTmp = "{Array}" Case Else $vTmp = $aArray[$i] EndSwitch EndIf Else If $iTranspose Then Switch VarGetType($aArray[$j][$i]) Case "Array" $vTmp = "{Array}" Case Else $vTmp = $aArray[$j][$i] EndSwitch Else Switch VarGetType($aArray[$i][$j]) Case "Array" $vTmp = "{Array}" Case Else $vTmp = $aArray[$i][$j] EndSwitch EndIf EndIf ; Truncate if required so ListView will display If StringLen($vTmp) > $iBuffer Then $vTmp = StringLeft($vTmp, $iBuffer) $avArrayText[$i - $iItem_Start] &= $sAD_Separator & $vTmp Next ; Remove leading delimiter if no "Row" column If $iNoRow Then $avArrayText[$i - $iItem_Start] = StringTrimLeft($avArrayText[$i - $iItem_Start], 1) Next ; GUI Constants Local Const $_ARRAYCONSTANT_GUI_DOCKBOTTOM = 64 Local Const $_ARRAYCONSTANT_GUI_DOCKBORDERS = 102 Local Const $_ARRAYCONSTANT_GUI_DOCKHEIGHT = 512 Local Const $_ARRAYCONSTANT_GUI_DOCKLEFT = 2 Local Const $_ARRAYCONSTANT_GUI_DOCKRIGHT = 4 Local Const $_ARRAYCONSTANT_GUI_DOCKHCENTER = 8 Local Const $_ARRAYCONSTANT_GUI_EVENT_CLOSE = -3 Local Const $_ARRAYCONSTANT_GUI_FOCUS = 256 Local Const $_ARRAYCONSTANT_GUI_BKCOLOR_LV_ALTERNATE = 0xFE000000 Local Const $_ARRAYCONSTANT_SS_CENTER = 0x1 Local Const $_ARRAYCONSTANT_SS_CENTERIMAGE = 0x0200 Local Const $_ARRAYCONSTANT_LVM_GETITEMCOUNT = (0x1000 + 4) Local Const $_ARRAYCONSTANT_LVM_GETITEMRECT = (0x1000 + 14) Local Const $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH = (0x1000 + 29) Local Const $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH = (0x1000 + 30) Local Const $_ARRAYCONSTANT_LVM_GETITEMSTATE = (0x1000 + 44) Local Const $_ARRAYCONSTANT_LVM_GETSELECTEDCOUNT = (0x1000 + 50) Local Const $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000 + 54) Local Const $_ARRAYCONSTANT_LVS_EX_GRIDLINES = 0x1 Local Const $_ARRAYCONSTANT_LVIS_SELECTED = 0x2 Local Const $_ARRAYCONSTANT_LVS_SHOWSELALWAYS = 0x8 Local Const $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT = 0x20 Local Const $_ARRAYCONSTANT_WS_EX_CLIENTEDGE = 0x0200 Local Const $_ARRAYCONSTANT_WS_MAXIMIZEBOX = 0x00010000 Local Const $_ARRAYCONSTANT_WS_MINIMIZEBOX = 0x00020000 Local Const $_ARRAYCONSTANT_WS_SIZEBOX = 0x00040000 Local Const $_ARRAYCONSTANT_WM_SETREDRAW = 11 Local Const $_ARRAYCONSTANT_LVSCW_AUTOSIZE = -1 ; Set coord mode 1 Local $iCoordMode = Opt("GUICoordMode", 1) ; Create GUI Local $iOrgWidth = 210, $iHeight = 200, $iMinSize = 250 Local $hGUI = GUICreate($sTitle, $iOrgWidth, $iHeight, Default, Default, BitOR($_ARRAYCONSTANT_WS_SIZEBOX, $_ARRAYCONSTANT_WS_MINIMIZEBOX, $_ARRAYCONSTANT_WS_MAXIMIZEBOX)) Local $aiGUISize = WinGetClientSize($hGUI) Local $iButtonWidth_2 = $aiGUISize[0] / 2 Local $iButtonWidth_3 = $aiGUISize[0] / 3 ; Create ListView Local $idListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1] - $iButtonMargin, $_ARRAYCONSTANT_LVS_SHOWSELALWAYS) GUICtrlSetBkColor($idListView, $_ARRAYCONSTANT_GUI_BKCOLOR_LV_ALTERNATE) GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_GRIDLINES, $_ARRAYCONSTANT_LVS_EX_GRIDLINES) GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT) GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE) Local $idCopy_ID = 9999, $idCopy_Data = 99999, $idData_Label = 99999, $idUser_Func = 99999, $idExit_Script = 99999 ; Check if any buttons required If $iButtonMargin Then ; Create Copy buttons $idCopy_ID = GUICtrlCreateButton("Copy Data && Hdr/Row", 0, $aiGUISize[1] - $iButtonMargin, $iButtonWidth_2, 20) $idCopy_Data = GUICtrlCreateButton("Copy Data Only", $iButtonWidth_2, $aiGUISize[1] - $iButtonMargin, $iButtonWidth_2, 20) ; Check if other buttons are required If $iButtonMargin = 40 Then Local $iButtonWidth_Var = $iButtonWidth_2 Local $iOffset = $iButtonWidth_2 If IsFunc($hUser_Function) Then ; Create UserFunc button if function passed $idUser_Func = GUICtrlCreateButton("Run User Func", $iButtonWidth_3, $aiGUISize[1] - 20, $iButtonWidth_3, 20) $iButtonWidth_Var = $iButtonWidth_3 $iOffset = $iButtonWidth_3 * 2 EndIf ; Create Exit button and data label $idExit_Script = GUICtrlCreateButton("Exit Script", $iOffset, $aiGUISize[1] - 20, $iButtonWidth_Var, 20) $idData_Label = GUICtrlCreateLabel($sDisplayData, 0, $aiGUISize[1] - 20, $iButtonWidth_Var, 18, BitOR($_ARRAYCONSTANT_SS_CENTER, $_ARRAYCONSTANT_SS_CENTERIMAGE)) ; Change label colour and create tooltip if required Select Case $bTruncated Or $iTranspose Or $bRange_Flag GUICtrlSetColor($idData_Label, 0xFF0000) GUICtrlSetTip($idData_Label, $sTipData) EndSelect EndIf EndIf ; Set resizing GUICtrlSetResizing($idListView, $_ARRAYCONSTANT_GUI_DOCKBORDERS) GUICtrlSetResizing($idCopy_ID, $_ARRAYCONSTANT_GUI_DOCKLEFT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT) GUICtrlSetResizing($idCopy_Data, $_ARRAYCONSTANT_GUI_DOCKRIGHT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT) GUICtrlSetResizing($idData_Label, $_ARRAYCONSTANT_GUI_DOCKLEFT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT) GUICtrlSetResizing($idUser_Func, $_ARRAYCONSTANT_GUI_DOCKHCENTER + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT) GUICtrlSetResizing($idExit_Script, $_ARRAYCONSTANT_GUI_DOCKRIGHT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT) ; Start ListView update GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_WM_SETREDRAW, 0, 0) ; Fill listview Local $idItem For $i = 0 To UBound($avArrayText) - 1 $idItem = GUICtrlCreateListViewItem($avArrayText[$i], $idListView) If $iAlt_Color Then GUICtrlSetBkColor($idItem, $iAlt_Color) EndIf Next ; Align columns if required - $iColAlign = 2 for Right and 4 for Center If $iColAlign Then Local Const $_ARRAYCONSTANT_LVCF_FMT = 0x01 Local Const $_ARRAYCONSTANT_LVM_SETCOLUMNW = (0x1000 + 96) Local $tColumn = DllStructCreate("uint Mask;int Fmt;int CX;ptr Text;int TextMax;int SubItem;int Image;int Order;int cxMin;int cxDefault;int cxIdeal") DllStructSetData($tColumn, "Mask", $_ARRAYCONSTANT_LVCF_FMT) DllStructSetData($tColumn, "Fmt", $iColAlign / 2) ; Left = 0; Right = 1; Center = 2 Local $pColumn = DllStructGetPtr($tColumn) ; Loop through columns For $i = 1 To $iSubItem_End - $iSubItem_Start + 1 GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETCOLUMNW, $i, $pColumn) Next EndIf ; End ListView update GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_WM_SETREDRAW, 1, 0) ; Allow for borders with and without vertical scrollbar Local $iBorder = 45 If UBound($avArrayText) > 20 Then $iBorder += 20 EndIf ; Adjust dialog width Local $iWidth = $iBorder, $iColWidth = 0, $aiColWidth[$iSubItem_End - $iSubItem_Start + 2], $iMin_ColWidth = 55 ; Get required column widths to fit items For $i = 0 To $iSubItem_End - $iSubItem_Start + 1 GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $_ARRAYCONSTANT_LVSCW_AUTOSIZE) $iColWidth = GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH, $i, 0) ; Set minimum if required If $iColWidth < $iMin_ColWidth Then GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMin_ColWidth) $iColWidth = $iMin_ColWidth EndIf ; Add to total width $iWidth += $iColWidth ; Store value $aiColWidth[$i] = $iColWidth Next ; Reduce width if no "Row" colukm If $iNoRow Then $iWidth -= 55 ; Now check max size If $iWidth > @DesktopWidth - 100 Then ; Apply max col width limit to reduce width $iWidth = $iBorder For $i = 0 To $iSubItem_End - $iSubItem_Start + 1 If $aiColWidth[$i] > $iMax_ColWidth Then ; Reset width GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMax_ColWidth) $iWidth += $iMax_ColWidth Else ; Retain width $iWidth += $aiColWidth[$i] EndIf Next EndIf ; Check max/min width If $iWidth > @DesktopWidth - 100 Then $iWidth = @DesktopWidth - 100 ElseIf $iWidth < $iMinSize Then $iWidth = $iMinSize EndIf ; Get row height Local $tRECT = DllStructCreate("struct; long Left;long Top;long Right;long Bottom; endstruct") ; $tagRECT DllCall("user32.dll", "struct*", "SendMessageW", "hwnd", GUICtrlGetHandle($idListView), "uint", $_ARRAYCONSTANT_LVM_GETITEMRECT, "wparam", 0, "struct*", $tRECT) ; Set required GUI height Local $aiWin_Pos = WinGetPos($hGUI) Local $aiLV_Pos = ControlGetPos($hGUI, "", $idListView) $iHeight = ((UBound($avArrayText) + 2) * (DllStructGetData($tRECT, "Bottom") - DllStructGetData($tRECT, "Top"))) + $aiWin_Pos[3] - $aiLV_Pos[3] ; Check min/max height If $iHeight > @DesktopHeight - 100 Then $iHeight = @DesktopHeight - 100 ElseIf $iHeight < $iMinSize Then $iHeight = $iMinSize EndIf If $iVerbose Then SplashOff() ; Display and resize dialog GUISetState(@SW_HIDE, $hGUI) WinMove($hGUI, "", (@DesktopWidth - $iWidth) / 2, (@DesktopHeight - $iHeight) / 2, $iWidth, $iHeight) GUISetState(@SW_SHOW, $hGUI) ; Switch to GetMessage mode Local $iOnEventMode = Opt("GUIOnEventMode", 0), $iMsg While 1 $iMsg = GUIGetMsg() ; Variable needed to check which "Copy" button was pressed Switch $iMsg Case $_ARRAYCONSTANT_GUI_EVENT_CLOSE ExitLoop Case $idCopy_ID, $idCopy_Data ; Count selected rows Local $iSel_Count = GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_GETSELECTEDCOUNT, 0, 0) ; Display splash dialog if required If $iVerbose And (Not $iSel_Count) And ($iItem_End - $iItem_Start) * ($iSubItem_End - $iSubItem_Start) > 10000 Then SplashTextOn("ArrayDisplay", "Copying data" & @CRLF & @CRLF & "Please be patient", 300, 100) EndIf ; Generate clipboard text Local $sClip = "", $sItem, $aSplit ; Add items For $i = 0 To $iItem_End - $iItem_Start ; Skip if copying selected rows and item not selected If $iSel_Count And Not (GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, $_ARRAYCONSTANT_LVIS_SELECTED)) Then ContinueLoop EndIf $sItem = $avArrayText[$i] If $iMsg = $idCopy_Data Then ; Remove row ID if required $sItem = StringRegExpReplace($sItem, "^\[\d+\].(.*)$", "$1") EndIf If $iCW_ColWidth Then ; Expand columns $aSplit = StringSplit($sItem, $sAD_Separator) $sItem = "" For $j = 1 To $aSplit[0] $sItem &= StringFormat("%-" & $iCW_ColWidth + 1 & "s", StringLeft($aSplit[$j], $iCW_ColWidth)) Next Else ; Use defined separator $sItem = StringReplace($sItem, $sAD_Separator, $vUser_Separator) EndIf $sClip &= $sItem & @CRLF Next ; Add header line if required If $iMsg = $idCopy_ID Then If $iCW_ColWidth Then $aSplit = StringSplit($sHeader, $sAD_Separator) $sItem = "" For $j = 1 To $aSplit[0] $sItem &= StringFormat("%-" & $iCW_ColWidth + 1 & "s", StringLeft($aSplit[$j], $iCW_ColWidth)) Next Else $sItem = StringReplace($sHeader, $sAD_Separator, $vUser_Separator) EndIf $sClip = $sItem & @CRLF & $sClip EndIf ;Send to clipboard ClipPut($sClip) ; Remove splash if used SplashOff() ; Refocus ListView GUICtrlSetState($idListView, $_ARRAYCONSTANT_GUI_FOCUS) Case $idUser_Func ; Get selected indices Local $aiSelItems[$iRowLimit] = [0] For $i = 0 To GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0) If GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, $_ARRAYCONSTANT_LVIS_SELECTED) Then $aiSelItems[0] += 1 $aiSelItems[$aiSelItems[0]] = $i + $iItem_Start EndIf Next ReDim $aiSelItems[$aiSelItems[0] + 1] ; Pass array and selection to user function $hUser_Function($aArray, $aiSelItems) GUICtrlSetState($idListView, $_ARRAYCONSTANT_GUI_FOCUS) Case $idExit_Script ; Clear up GUIDelete($hGUI) Exit EndSwitch If $iTimeOut <> Default And TimerDiff($iTimmer) > ($iTimeOut * 1000) Then ExitLoop ; <<- 2 of 2 lines added for timeout. WEnd ; Clear up GUIDelete($hGUI) Opt("GUICoordMode", $iCoordMode) ; Reset original Coord mode Opt("GUIOnEventMode", $iOnEventMode) ; Reset original GUI mode Opt("GUIDataSeparatorChar", $sCurr_Separator) ; Reset original separator Return 1 EndFunc ;==>_ArrayDisplayEx1 point
-
This example auto-formats the input data to a particular sequence of characters. For example 5 lowercase letters, followed by 4 digits, followed by 1 lowercase letter, like "abcde1234f ", becomes "abcde 1234 f ". #include <GUIConstants.au3> #include <WinApi.au3> #include <Array.au3> ; https://www.autoitscript.com/forum/topic/187551-custom-formating-text-in-inputbox-possible/ Global $hMain = GUICreate("Example", 300, 150) GUISetFont(10) Global $inpInput = GUICtrlCreateInput("", 10, 10, 180, 20) GUICtrlCreateLabel('Format: "aaaaa dddd a" (without added spaces)' & @CRLF & _ "Where:-" & @CRLF & @TAB & _ '"a" is a lowercase letter, (a-z), and;' & @CRLF & @TAB & _ '"d" is a digit (0-9).', 10, 35, 280, 70) GUICtrlSetFont(-1, 9) GUIRegisterMsg($WM_COMMAND, _WM_COMMAND) GUISetState(@SW_SHOW, $hMain) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) ; abced 1233 f If BitAND($wParam, 0x0000FFFF) = $inpInput Then Local $s = StringRegExpReplace(GUICtrlRead($inpInput), "[^\p{Ll}0-9]", "") ; Remove all characters that ae not lowercase letters nor digits. Switch StringLen($s) Case 0 To 5 $s = StringRegExpReplace($s, "[^\p{Ll}]", "") GUICtrlSetData($inpInput, $s) Case 6 To 9 $s = StringLeft($s, 5) & StringRegExpReplace(StringTrimLeft($s, 5), "[^0-9]", "") ;Remove all characters that ae not digits. GUICtrlSetData($inpInput, StringLeft($s, 5) & " " & StringMid($s, 6)) Case 10 To 12 $s = StringLeft($s, 9) & StringRegExpReplace(StringTrimLeft($s, 9), "[^\p{Ll}]", "") ; Remove all characters that ae not lowercase letters. GUICtrlSetData($inpInput, StringLeft($s, 5) & " " & StringMid($s, 6, 4) & " " & StringMid($s, 10, 1)) EndSwitch EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>_WM_COMMAND And here is an updated version. #include <GUIConstants.au3> #include <WinApi.au3> #include <Array.au3> ; https://www.autoitscript.com/forum/topic/187551-custom-formating-text-in-inputbox-possible/?do=findComment&comment=1349344 GUIRegisterMsg($WM_COMMAND, _WM_COMMAND) Global $a = _FormatedInput() ; Get formated data from input. MsgBox(0, "Results", $a) Func _FormatedInput() local $Res Global $hFormatedInput = GUICreate("Example", 300, 150) Global $inpInput = GUICtrlCreateInput("", 10, 10, 180, 25) GUICtrlSetFont(-1, 11) Local $idBut = GUICtrlCreateButton("Done", 200, 10, 80, 25) GUICtrlCreateLabel('Format: "aaaaa dddd a" (without added spaces)' & @CRLF & _ "Where:-" & @CRLF & @TAB & _ '"a" is a lowercase letter, (a-z), and;' & @CRLF & @TAB & _ '"d" is a digit (0-9).', 10, 40, 280, 70) GUICtrlSetFont(-1, 9) GUISetState(@SW_SHOW, $hFormatedInput) While 1 Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE, $idBut $iLen = StringLen(StringRegExpReplace(GUICtrlRead($inpInput), "[^\p{Ll}0-9]", "")) ; Remove all characters that ae not lowercase letters nor digits. ConsoleWrite($iLen & @CRLF) If $iLen < 10 Then $iReply = MsgBox(33, "Error", "Only " & $iLen & " characters entered !!" & @CRLF & _ ; 1 OK (1) and Cancel (2) + 32 Question-mark icon 'Press "OK" to accept input data as is, or;' & @CRLF & _ 'Press "Cancel" to continue to enter input data.') If $iReply = 1 Then ; OK (1) Pressed ExitLoop ; Accept lesser length input. Else ControlFocus($hFormatedInput, "", $inpInput) ; Return focus to input EndIf Else ExitLoop EndIf EndSwitch WEnd $Res = GUICtrlRead($inpInput) GUIDelete($hFormatedInput) Return $Res EndFunc ;==>_FormatedInput ; Ref to: https://www.autoitscript.com/forum/topic/180138-custom-input-mask/?do=findComment&comment=1293201 Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) ; abcde 1234 f If $hWnd = $hFormatedInput And _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $inpInput Then Local $s = StringRegExpReplace(GUICtrlRead($inpInput), "[^\p{Ll}0-9]", "") ; Remove all characters that ae not lowercase letters nor digits. Switch StringLen($s) Case 1 To 5 $s = StringRegExpReplace($s, "[^\p{Ll}]", "") GUICtrlSetData($inpInput, $s) ;ConsoleWrite(StringLen($s) & " 0-6 " & $s & @CRLF) Case 6 To 9 $s = StringLeft($s, 5) & StringRegExpReplace(StringTrimLeft($s, 5), "[^0-9]", "") ;Remove all characters that ae not digits. GUICtrlSetData($inpInput, StringLeft($s, 5) & " " & StringMid($s, 6)) ;ConsoleWrite(StringLen($s) & " 6-9 " & $s & @CRLF) Case 10 To 11 $s = StringLeft($s, 9) & StringRegExpReplace(StringTrimLeft($s, 9), "[^\p{Ll}]", "") ; Remove all characters that ae not lowercase letters. GUICtrlSetData($inpInput, StringLeft($s, 5) & " " & StringMid($s, 6, 4) & " " & StringMid($s, 10, 1)) ;ConsoleWrite(StringLen($s) & " 10-11 " & $s & @CRLF) EndSwitch EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>_WM_COMMAND1 point
-
Convert PDF to CSV, and working with it
wondermore reacted to mLipok for a topic
As far as I remember you can do this using https://mupdf.com/ ..... or QuickPDF Library (and here I know that for 100%). For the later one search here on the forum for my QuickPDF.au3 UDF1 point -
Sorry for the long downtime. Can anyone tell me what's the difference between my current version 0.6.0.2b and all the functions here in the forum?1 point
-
Example : compiled.exe #pragma compile(AutoItExecuteAllowed, True) ; .... ; ... ; you script code ; ... ; ... test.au3 MsgBox(0, "", "Hello !") To run test.au3 using compiled.exe as interpreter : compiled.exe /AutoIt3ExecuteScript test.au31 point
-
RetroComp, I use a slightly modified version of this UDF with great success to check on changes to files. Try running these 2 and see if you get better results: The UDF (save it as FileSystemMonitor_Mod.au3): #include-once #cs Title: File System Monitoring UDF Library for AutoIt3 Filename: FileSystemMonitor.au3 Description: A collection of functions for monitoring the Windows File System Author: seangriffin Version: V0.4 Last Update: 02/05/10 Requirements: AutoIt3 3.2 or higher #ce #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; #INCLUDES# ========================================================================================================= ; #GLOBAL VARIABLES# ================================================================================================= Global $pFSM_DirEvents, $pFSM_Dir, $pFSM_Overlapped, $tFSM_FNI, $pFSM_Buffer, $sFSM_Filename, $aFSM_Register, $iFSM_Buffersize, $tFSM_Overlapped Global $tFSM_Buffer, $tFSM_DirEvents, $iFSM_DirEvents, $hFSM_Event, $hFSM_ShellMonGUI = GUICreate("") ; #FUNCTION# ;=============================================================================== ; ; Name...........: _FileSysMonSetup() ; Description ...: Setup File System Monitoring. ; Syntax.........: _FileSysMonSetup($iMonitor_Type = 3, $sDirMon_Path = "C:\", $sShellMon_Path = "") ; Parameters ....: $iMonitor_Type - Optional: The type of monitoring to use. ; 1 = directory monitoring only ; 2 = shell monitoring only ; 3 = both directory and shell monitoring ; $sDirMon_Path - Optional: The path to use for directory monitoring. ; The path "C:\" is used if one isn't provided. ; $sShellMon_Path - Optional: The path to use for shell monitoring. ; The blank path is used if one isn't provided. This ; denotes that system-wide shell events will be monitored. ; Return values .: On Success - Returns True. ; On Failure - Returns False. ; Author ........: seangriffin ; Modified.......: ; Remarks .......: A call to this function should be inserted in a script prior to calling other ; functions in this UDF. Ideally the function should be placed before ; the main message loop in a GUI-based script. ; Related .......: ; Link ..........: ; Example .......: Yes ; ;========================================================================================== Func _FileSysMonSetup($iMonitor_Type = 3, $sDirMon_Path = "C:\", $sShellMon_Path = "") If BitAnd($iMonitor_Type, 1) Then ; Setup the Directory Event Handler Local $sdir = $sDirMon_Path $tFSM_Buffer = DllStructCreate("byte[4096]") $pFSM_Buffer = DllStructGetPtr($tFSM_Buffer) $iFSM_Buffersize = DllStructGetSize($tFSM_Buffer) $tFSM_FNI = 0 $pFSM_Dir = DllCall("kernel32.dll", "hwnd", "CreateFile", "Str", $sdir, "Int", 0x1, "Int", BitOR(0x1, 0x4, 0x2), "ptr", 0, "int", 0x3, "int", BitOR(0x2000000, 0x40000000), "int", 0) $pFSM_Dir = $pFSM_Dir[0] $tFSM_Overlapped = DllStructCreate("Uint OL1;Uint OL2; Uint OL3; Uint OL4; hwnd OL5") For $i = 1 To 5 DllStructSetData($tFSM_Overlapped, $i, 0) Next $pFSM_Overlapped = DllStructGetPtr($tFSM_Overlapped) $tFSM_DirEvents = DllStructCreate("hwnd DirEvents") $pFSM_DirEvents = DllStructGetPtr($tFSM_DirEvents) Local $hFSM_Event = DllCall("kernel32.dll", "hwnd", "CreateEvent", "UInt", 0, "Int", True, "Int", False, "UInt", 0) DllStructSetData($tFSM_Overlapped, 5, $hFSM_Event[0]) DllStructSetData($tFSM_DirEvents, 1, $hFSM_Event[0]) DllCall("kernel32.dll", "Int", "ReadDirectoryChangesW", "hwnd", $pFSM_Dir, "ptr", $pFSM_Buffer, "dword", $iFSM_Buffersize, "int", False, "dword", BitOR(0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x100), "Uint", 0, "Uint", $pFSM_Overlapped, "Uint", 0) $sFSM_Filename = "" EndIf If BitAND($iMonitor_Type, 2) Then ; Setup the Shell Event Handler ; Register a window message to associate an AutoIT function with the change notification events Local $aRet = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", "shchangenotifymsg") If @error Then Return SetError(@error, @extended, 0) Local $SHNOTIFY = $aRet[0] GUIRegisterMsg($SHNOTIFY, "_FileSysMonShellEventHandler") ; Setup the structure for registering the gui to receive shell notifications If StringCompare($sShellMon_Path, "") <> 0 Then Local $ppidl = DllCall("shell32.dll", "ptr", "ILCreateFromPath", "wstr", $sShellMon_Path) EndIf Local $shnotifystruct = DllStructCreate("ptr pidl; int fRecursive") If StringCompare($sShellMon_Path, "") <> 0 Then DllStructSetData($shnotifystruct, "pidl", $ppidl[0]) Else DllStructSetData($shnotifystruct, "pidl", 0) EndIf DllStructSetData($shnotifystruct, "fRecursive", 0) ; Register the gui to receive shell notifications $aFSM_Register = DllCall("shell32.dll", "int", "SHChangeNotifyRegister", "hwnd", $hFSM_ShellMonGUI, "int", BitOR(0x0001, 0x0002), "long", 0x7FFFFFFF, "uint", $SHNOTIFY, "int", 1, "ptr", DllStructGetPtr($shnotifystruct)) If StringCompare($sShellMon_Path, "") <> 0 Then DllCall("ole32.dll", "none", "CoTaskMemFree", "ptr", $ppidl[0]) EndIf EndIf Return True EndFunc ;==>_FileSysMonSetup ; #FUNCTION# ;=============================================================================== ; ; Name...........: _FileSysMonSetDirMonPath() ; Description ...: Change the path of Directory Monitoring ; Syntax.........: _FileSysMonSetDirMonPath($sDirMon_Path = "C:\") ; Parameters ....: $sDirMon_Path - Optional: The path to use for directory monitoring. ; The path "C:\" is used if one isn't provided. ; Return values .: On Success - Returns True. ; On Failure - Returns False. ; ; Author ........: seangriffin ; Modified.......: ; Remarks .......: For an unknown reason, after this function is called the ; ; Related .......: ; Link ..........: ; Example .......: Yes ; ;========================================================================================== Func _FileSysMonSetDirMonPath($sDirMon_Path = "C:\") Local $sdir = $sDirMon_Path $pFSM_Dir = DllCall("kernel32.dll", "hwnd", "CreateFile", "Str", $sdir, "Int", 0x1, "Int", BitOR(0x1, 0x4, 0x2), "ptr", 0, "int", 0x3, "int", BitOR(0x2000000, 0x40000000), "int", 0) $pFSM_Dir = $pFSM_Dir[0] For $i = 1 To 5 DllStructSetData($tFSM_Overlapped, $i, 0) Next Local $hFSM_Event = DllCall("kernel32.dll", "hwnd", "CreateEvent", "UInt", 0, "Int", True, "Int", False, "UInt", 0) DllStructSetData($tFSM_Overlapped, 5, $hFSM_Event[0]) DllStructSetData($tFSM_DirEvents, 1, $hFSM_Event[0]) DllCall("kernel32.dll", "Int", "ReadDirectoryChangesW", "hwnd", $pFSM_Dir, "ptr", $pFSM_Buffer, "dword", $iFSM_Buffersize, "int", False, "dword", BitOR(0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x100), "Uint", 0, "Uint", $pFSM_Overlapped, "Uint", 0) Return True EndFunc ;==>_FileSysMonSetDirMonPath ; #FUNCTION# ;=============================================================================== ; ; Name...........: _FileSysMonSetShellMonPath() ; Description ...: Change the path of Shell Monitoring ; Syntax.........: _FileSysMonSetShellMonPath($sDirMon_Path = "") ; Parameters ....: $sDirMon_Path - Optional: The path to use for shell monitoring. ; The path "" is used if one isn't provided. ; Return values .: On Success - Returns True. ; On Failure - Returns False. ; ; Author ........: seangriffin ; Modified.......: ; Remarks .......: ; ; Related .......: ; Link ..........: ; Example .......: Yes ; ;========================================================================================== Func _FileSysMonSetShellMonPath($sShellMon_Path = "") ; De-Register the gui from receiving shell notifications DllCall("shell32.dll", "int", "SHChangeNotifyDeregister", "ulong", $aFSM_Register[0]) ; Register a window message to associate an AutoIT function with the change notification events ;Local $SHNOTIFY = _WinAPI_RegisterWindowMessage("shchangenotifymsg") Local $aRet = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", "shchangenotifymsg") If @error Then Return SetError(@error, @extended, 0) Local $SHNOTIFY = $aRet[0] GUIRegisterMsg($SHNOTIFY, "_FileSysMonShellEventHandler") ; Setup the structure for registering the gui to receive shell notifications If StringCompare($sShellMon_Path, "") <> 0 Then Local $ppidl = DllCall("shell32.dll", "ptr", "ILCreateFromPath", "wstr", $sShellMon_Path) EndIf Local $shnotifystruct = DllStructCreate("ptr pidl; int fRecursive") If StringCompare($sShellMon_Path, "") <> 0 Then DllStructSetData($shnotifystruct, "pidl", $ppidl[0]) Else DllStructSetData($shnotifystruct, "pidl", 0) EndIf DllStructSetData($shnotifystruct, "fRecursive", 0) ; Register the gui to receive shell notifications $aFSM_Register = DllCall("shell32.dll", "int", "SHChangeNotifyRegister", "hwnd", $hFSM_ShellMonGUI, "int", BitOR(0x0001, 0x0002), "long", 0x7FFFFFFF, "uint", $SHNOTIFY, "int", 1, "ptr", DllStructGetPtr($shnotifystruct)) If StringCompare($sShellMon_Path, "") <> 0 Then DllCall("ole32.dll", "none", "CoTaskMemFree", "ptr", $ppidl[0]) EndIf Return True EndFunc ;==>_FileSysMonSetShellMonPath ; #FUNCTION# ;=============================================================================== ; ; Name...........: _FileSysMonDirEventHandler() ; Description ...: Monitors the file system for changes to a given directory. If a change event occurs, ; the user-defined "_FileSysMonActionEvent" function is called. ; Syntax.........: _FileSysMonDirEventHandler() ; Parameters ....: none ; Return values .: On Success - Returns True. ; On Failure - Returns False. ; ; Author ........: seangriffin ; Modified.......: ; Remarks .......: This function utilises the "ReadDirectoryChangesW" Win32 operating system function to ; monitor the a directory for changes. ; ; The ReadDirectoryChangesW function appears to queue events, such that whenever ; it is called, all unprocessed events are retrieved one at a time. ; ; The function "_FileSysMonSetup" must be called, with a $iMonitor_Type ; of either 1 or 3, prior to calling this function. ; ; A call to this function should be inserted within the main message loop of a GUI-based script. ; ; A user-defined function to action the events is required to be created by the user ; in the calling script, and must be defined as follows: ; ; Func _FileSysMonActionEvent($event_type, $event_id, $event_value) ; ; EndFunc ; ; Related .......: ; Link ..........: ; Example .......: Yes ; ;========================================================================================== Func _FileSysMonDirEventHandler() Local $aRet, $iOffset, $nReadLen, $tStr, $iNext, $ff $aRet = DllCall("User32.dll", "dword", "MsgWaitForMultipleObjectsEx", "dword", 1, "ptr", $pFSM_DirEvents, "dword", 100, "dword", 0x4FF, "dword", 0x6) If $aRet[0] = 0 Then $iOffset = 0 $nReadLen = 0 DllCall("kernel32.dll", "Uint", "GetOverlappedResult", "hWnd", $pFSM_Dir, "Uint", $pFSM_Overlapped, "UInt*", $nReadLen, "Int", True) While 1 $tFSM_FNI = DllStructCreate("dword Next;dword Action;dword FilenameLen", $pFSM_Buffer + $iOffset) $tStr = DllStructCreate("wchar[" & DllStructGetData($tFSM_FNI, "FilenameLen") / 2 & "]", $pFSM_Buffer + $iOffset + 12) $sFSM_Filename = DllStructGetData($tStr, 1) _FileSysMonActionEvent(0, DllStructGetData($tFSM_FNI, "Action"), $sFSM_Filename) $iNext = DllStructGetData($tFSM_FNI, "Next") If $iNext = 0 Then ExitLoop $iOffset += $iNext WEnd $ff = DllStructGetData($tFSM_Overlapped, 5) DllCall("kernel32.dll", "Uint", "ResetEvent", "UInt", $ff) DllCall("kernel32.dll", "Int", "ReadDirectoryChangesW", "hwnd", $pFSM_Dir, "ptr", $pFSM_Buffer, "dword", $iFSM_Buffersize, "int", False, "dword", BitOR(0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x100), "Uint", 0, "Uint", $pFSM_Overlapped, "Uint", 0) EndIf Return True EndFunc ;==>_FileSysMonDirEventHandler ; #FUNCTION# ;=============================================================================== ; ; Name...........: _FileSysMonShellEventHandler() ; Description ...: Monitors the file system for shell events. ; Syntax.........: _FileSysMonShellEventHandler() ; Parameters ....: $hWnd - The Window handle of the GUI in which the message appears. ; $iMsg - The Windows message ID. ; $wParam - The first message parameter as hex value. ; $lParam - The second message parameter as hex value. ; Return values .: On Success - Returns True. ; On Failure - Returns False. ; ; Author ........: seangriffin ; Modified.......: ; Remarks .......: If a directory was provided in "_FileSysMonSetup" then only events in ; that directory will be caught. If no directory was provided, then ; system-wide events will be caught. ; ; This function utilises the "SHChangeNotifyRegister" Win32 operating system functionality ; monitor a system or directory for changes relating to the Windows shell. ; ; The function "_FileSysMonSetup" must be called, with a $iMonitor_Type ; of either 2 or 3, prior to calling this function. ; ; A call to this function is not required. It is triggered automatically ; for each new shell event. ; ; A user-defined function to action the events is required to be created by the user ; in the calling script, and must be defined as follows: ; ; Func _FileSysMonActionEvent($event_type, $event_id, $event_value) ; ; EndFunc ; ; Related .......: ; Link ..........: ; Example .......: Yes ; ;========================================================================================== Func _FileSysMonShellEventHandler($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $tDestination, $wHighBit Local $tPath = DllStructCreate("dword dwItem1; dword dwItem2", $wParam) Local $aRet = DllCall("shell32.dll", "int", "SHGetPathFromIDList", "ptr", DllStructGetData($tPath, "dwItem1"), "str", "") ; Get the drive for which free space has changed If $lParam = 0x00040000 Then $tDestination = DllStructCreate("long") DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", DllStructGetPtr($tDestination), "ptr", (DllStructGetData($tPath, "dwItem1") + 2), "int", 4) ; CopyMemory $wHighBit = Int(Log(DllStructGetData($tDestination, 1)) / Log(2)) $aRet[2] = Chr(65 + $wHighBit) EndIf If $lParam <> 0x00000002 And $lParam <> 0x00000004 Then ; FILE_ACTION_ADDED & FILE_ACTION_REMOVED skipped due to a deadlock with Directory_Event_Handler() _FileSysMonActionEvent(1, $lParam, $aRet[2]) EndIf Return True EndFunc ;==>_FileSysMonShellEventHandlerAnd the example: #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <ListviewConstants.au3> #Include <GuiListView.au3> #include <WindowsConstants.au3> #include "FileSystemMonitor_Mod.au3" dim $msg ; GUI Setup $main_gui = GUICreate("Shell Notification Monitor (Press ESC to close)", 800, 320, -1, -1, -1, $WS_EX_TOPMOST) $path_input = GUICtrlCreateInput("M:\", 10, 10, 320) $use_path_button = GUICtrlCreateButton("Use Path", 350, 10) $listview = GUICtrlCreateListView("", 10, 40, 780, 250, $LVS_REPORT) _GUICtrlListView_SetUnicodeFormat($listview, False) _GUICtrlListView_InsertColumn($listview, 0, "Type", 200) _GUICtrlListView_InsertColumn($listview, 1, "Name (Hex)", 200) _GUICtrlListView_InsertColumn($listview, 2, "Value", 200) _GUICtrlListView_InsertColumn($listview, 3, "Time", 100) GUISetState(@SW_SHOW) ; Setup File System Monitoring _FileSysMonSetup(3, "M:\", "") ; Main Loop While 1 ; Handle Directory related events _FileSysMonDirEventHandler() If $msg = $use_path_button then _FileSysMonSetDirMonPath(GUICtrlRead($path_input)) _FileSysMonSetShellMonPath(GUICtrlRead($path_input)) EndIf If $msg = $GUI_EVENT_CLOSE then ExitLoop EndIf $msg = GUIGetMsg() WEnd Func _FileSysMonActionEvent($event_type, $event_id, $event_value) ConsoleWrite($event_type & " - " & $event_id & " - " & $event_value & @CRLF) Local $event_type_name Local $fs_event = ObjCreate("Scripting.Dictionary") Switch $event_type Case 0 $fs_event.item(Hex(0x00000001)) = "file added to the directory|FILE_ACTION_ADDED" $fs_event.item(Hex(0x00000002)) = "file removed from the directory|FILE_ACTION_REMOVED" $fs_event.item(Hex(0x00000003)) = "file was modified|FILE_ACTION_MODIFIED" $fs_event.item(Hex(0x00000004)) = "file was renamed old name|FILE_ACTION_RENAMED_OLD_NAME" $fs_event.item(Hex(0x00000005)) = "file was renamed new name|FILE_ACTION_RENAMED_NEW_NAME" Case 1 $fs_event.item(Hex(0x00000001)) = "Non-folder item name changed|SHCNE_RENAMEITEM" $fs_event.item(Hex(0x00000002)) = "Non-folder item created|SHCNE_CREATE" $fs_event.item(Hex(0x00000004)) = "Non-folder item deleted|SHCNE_DELETE" $fs_event.item(Hex(0x00000008)) = "Folder created|SHCNE_MKDIR" $fs_event.item(Hex(0x00000010)) = "Folder removed|SHCNE_RMDIR" $fs_event.item(Hex(0x00000020)) = "Storage media inserted into a drive|SHCNE_MEDIAINSERTED" $fs_event.item(Hex(0x00000040)) = "Storage media removed from a drive|SHCNE_MEDIAREMOVED" $fs_event.item(Hex(0x00000080)) = "Drive removed|SHCNE_DRIVEREMOVED" $fs_event.item(Hex(0x00000100)) = "Drive added|SHCNE_DRIVEADD" $fs_event.item(Hex(0x00000200)) = "Local computer folder shared via the network|SHCNE_NETSHARE" $fs_event.item(Hex(0x00000400)) = "Local computer folder not shared via the network|SHCNE_NETUNSHARE" $fs_event.item(Hex(0x00000800)) = "Item or folder attributes have changed|SHCNE_ATTRIBUTES" $fs_event.item(Hex(0x00001000)) = "Folder content has changed|SHCNE_UPDATEDIR" $fs_event.item(Hex(0x00002000)) = "Folder or non-folder has changed|SHCNE_UPDATEITEM" $fs_event.item(Hex(0x00004000)) = "Computer disconnected from server|SHCNE_SERVERDISCONNECT" $fs_event.item(Hex(0x00008000)) = "System image list image has changed|SHCNE_UPDATEIMAGE" $fs_event.item(Hex(0x00010000)) = "Not used|SHCNE_DRIVEADDGUI" $fs_event.item(Hex(0x00020000)) = "Folder name has changed|SHCNE_RENAMEFOLDER" $fs_event.item(Hex(0x00040000)) = "Drive free space has changed|SHCNE_FREESPACE" $fs_event.item(Hex(0x0002381F)) = "SHCNE_DISKEVENTS" $fs_event.item(Hex(0x0C0581E0)) = "SHCNE_GLOBALEVENTS" $fs_event.item(Hex(0x7FFFFFFF)) = "SHCNE_ALLEVENTS" $fs_event.item(Hex(0x80000000)) = "SHCNE_INTERRUPT" EndSwitch if StringLen($fs_event.item(Hex(Int($event_id)))) > 0 Then $event_type_name = StringSplit($fs_event.item(Hex(Int($event_id))), "|") $event_type_name[2] = $event_type_name[2] & "(" & $event_id & ")" _GUICtrlListView_InsertItem($listview, $event_type_name[1], 0) _GUICtrlListView_SetItemText($listview, 0, $event_type_name[2], 1) _GUICtrlListView_SetItemText($listview, 0, $event_value, 2) _GUICtrlListView_SetItemText($listview, 0, @HOUR & ":" & @MIN & ":" & @SEC, 3) EndIf EndFuncI get console reports like this: Event ID: 2 fred4.au3.2.bak deletedHow do you get on? M231 point
-
I just ran this and got 5 message boxes as I suspected. If you're having problems Mikeman27294 please post a re-producing script of the problem. AU3_Example.txt file: MsgBox(0, "It Works", "Hello World") AutoIt Script: _RunAU3("AU3_Example.txt") _RunAU3("AU3_Example.txt") _RunAU3("AU3_Example.txt") _RunAU3("AU3_Example.txt") _RunAU3("AU3_Example.txt") Func _RunAU3($sFilePath, $sWorkingDir = "", $iShowFlag = @SW_SHOW, $iOptFlag = 0) Return Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $sFilePath & '"', $sWorkingDir, $iShowFlag, $iOptFlag) EndFunc ;==>_RunAU3 SmartAlec, This is an example of how to do it, though I still expect you to do a bit of research on the subject.1 point