Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/25/2014 in all areas

  1. Jon

    AutoIt v3.3.13.19 Beta

    I've starting uploading the beta docs as well. Beta docs: https://www.autoitscript.com/autoit3/files/beta/autoit/docs/ Script breaking changes: https://www.autoitscript.com/autoit3/files/beta/autoit/docs/script_breaking_changes.htm
    2 points
  2. You don't need beta for this. Just add: DllCall("ole32.dll", "long", "OleInitialize", "ptr", 0) ...line somewhere in your script if you plan to use clipboard this way later.
    2 points
  3. spudw2k

    ADODB Example

    Man, seems like I've been waiting for days for the site to come back up so I could post this. I'm putting together a Scan Engine tool that collects system info (via WMI, Reg, etc...). It will collectively store the data on either a SQL server, or local MDB. Here's a simple UDF I made to handle the ADODB stuff. I'll share the rest (Scan Engine Builder) when it's ready. _ADODB.au3 #Region - Constants and Variables Global $objConnection = ObjCreate("ADODB.Connection") Global $objRecordSet = ObjCreate("ADODB.Recordset") Global $errADODB = ObjEvent("AutoIt.Error","_ErrADODB") Global $adCurrentProvider = 0 Global $adCurrentDataSource = 0 Const $adOpenForwardOnly = 0 Const $adOpenKeyset = 1 Const $adOpenDynamic = 2 Const $adOpenStatic = 3 Const $adLockReadOnly = 1 Const $adLockPessimistic = 2 Const $adLockOptimistic = 3 Const $adLockBatchOptimistic = 4 Const $adProviderSQLOLEDB = "SQLOLEDB" Const $adProviderMSJET4 = "Microsoft.Jet.OLEDB.4.0" Const $adProviderMSJET12 = "Microsoft.ACE.OLEDB.12.0" #EndRegion #Region - Functions, Subs, Methods Func _AddColumn($varTableName,$varColumnName,$varColumnType) If Not IsObj($objConnection) Then Return -1 $strAddCol = "ALTER TABLE " & $varTableName & " ADD " & $varColumnName & " " & $varColumnType Return $objConnection.Execute($strAddCol) EndFunc Func _CloseConnection() Return $objConnection.Close EndFunc Func _CloseRecordSet() Return $objRecordSet.Close EndFunc Func _CreateDatabase($varDatabaseName=0) If $adCurrentProvider = $adProviderMSJET4 Then $objADOXCatalog = ObjCreate("ADOX.Catalog") $strProvider = "Provider=" & $adCurrentProvider & ";Data Source=" & $adCurrentDataSource $objADOXCatalog.Create($strProvider) $objADOXCatalog = 0 Return 0 ElseIf $varDatabaseName Then $objConnection.Execute("CREATE DATABASE " & $varDatabaseName) Return $objConnection.Execute("USE " & $varDatabaseName) EndIf Return 0 EndFunc Func _CreateTable($varTableName,$arrFields) If Not IsObj($objConnection) Then Return -1 If Not IsString($varTableName) Then Return -2 If Not IsArray($arrFields) Then Return -3 $varFields = "" $varFieldCount = Ubound($arrFields)-1 For $x = 0 to $varFieldCount $varFields &= $arrFields[$x] If $x < $varFieldCount Then $varFields &= " ," Next Return $objConnection.Execute("CREATE TABLE " & $varTableName & "(" & $varFields & ")") EndFunc Func _DropColumn($varTableName,$varColumnName) If Not IsObj($objConnection) Then Return -1 $strDropCol = "ALTER TABLE " & $varTableName & " DROP COLUMN " & $varColumnName Return $objConnection.Execute($strDropCol) EndFunc Func _DropDatabase($varDatabaseName=0) If Not IsObj($objConnection) Then Return -1 If $adCurrentProvider = $adProviderMSJET4 Then _CloseConnection() If MsgBox(4+16,"Are you sure?","Are you sure you want to delete" & @CRLF & $adCurrentDataSource & " ?" & @CRLF & @CRLF & "This Cannot Be Undone!") = 6 Then Return FileDelete($adCurrentDataSource) EndIf Else $objConnection.Execute("USE master") Return $objConnection.Execute("DROP DATABASE " & $varDatabaseName) EndIf EndFunc Func _DropTable($varTableName) If Not IsObj($objConnection) Then Return -1 Return $objConnection.Execute("DROP TABLE " & $varTableName) EndFunc Func _GetRecords($varTable,$arrSelectFields,$arrWhereFields=0) If Not IsObj($objConnection) Then Return -1 If Not IsObj($objRecordSet) Then Return -2 _OpenRecordset($varTable,$arrSelectFields,$arrWhereFields) If Not $objRecordSet.RecordCount Or ($objRecordSet.EOF = True) Then Return -3 Dim $arrRecords $arrRecords = $objRecordSet.GetRows() _CloseRecordSet() Return $arrRecords EndFunc Func _GetTablesAndColumns($varSystemTables=0) If Not IsObj($objConnection) Then Return -1 $objADOXCatalog = ObjCreate("ADOX.Catalog") $objADOXCatalog.ActiveConnection = $objConnection Dim $arrTables[1][2]=[['Table Name','Columns Array']] Dim $arrColumns[1][2]=[['Column Name','Column Type']] For $objTable In $objADOXCatalog.Tables Local $varSkipTable = 0 If Not $varSystemTables Then If StringInstr($objTable.Type,"SYSTEM") or StringInstr($objTable.Name,"MSys")=1 Then $varSkipTable = 1 EndIf If Not $varSkipTable Then ReDim $arrTables[UBound($arrTables)+1][2] $arrTables[UBound($arrTables)-1][0] = $objTable.Name ReDim $arrColumns[1][2] For $objColumn in $objTable.Columns ReDim $arrColumns[UBound($arrColumns)+1][2] $arrColumns[UBound($arrColumns)-1][0] = $objColumn.Name $arrColumns[UBound($arrColumns)-1][1] = $objColumn.Type Next $arrTables[UBound($arrTables)-1][1] = $arrColumns EndIf Next $objADOXCatalog = 0 Return $arrTables EndFunc Func _InsertRecords($varTableName,$arrFieldsAndValues) If Not IsObj($objConnection) Then Return -1 If Not IsArray($arrFieldsAndValues) Then Return -2 For $y = 1 To UBound($arrFieldsAndValues)-1 $strInsert = "INSERT INTO " & $varTableName & " (" $varFieldCount = UBound($arrFieldsAndValues,2)-1 For $x = 0 To $varFieldCount $strInsert &= $arrFieldsAndValues[0][$x] If $x < $varFieldCount Then $strInsert &= "," Next $strInsert &= ") VALUES (" For $x = 0 To $varFieldCount $strInsert &= "'" & $arrFieldsAndValues[$y][$x] & "'" If $x < $varFieldCount Then $strInsert &= "," Next $strInsert &= ");" $objConnection.Execute($strInsert) If $errADODB.number Then If Msgbox(4+16+256,"Insert Record Error","Statement failed:" & @CRLF & $strInsert & @CRLF & @CRLF & "Would you like to continue?") <> 6 Then Return -3 EndIf Next Return 1 EndFunc Func _OpenConnection($varProvider,$varDataSource,$varTrusted=0,$varInitalCatalog="",$varUser="",$varPass="") If Not IsObj($objConnection) Then Return -1 $adCurrentDataSource = $varDataSource $adCurrentProvider = $varProvider If $adCurrentProvider = $adProviderMSJET4 Then If Not FileExists($adCurrentDataSource) Then If MsgBox(4+16,$adCurrentDataSource & " does not exist.","Would you like to attempt" & @CRLF & "to create it?") = 6 Then _CreateDatabase() Else Return 0 EndIf EndIf EndIf $strConnect = "Provider=" & $adCurrentProvider & ";Data Source=" & $adCurrentDataSource & ";" If $varTrusted Then $strConnect &= "Trusted_Connection=Yes;" If $varUser Then $strConnect &= "User ID=" & $varUser & ";" If $varPass Then $strConnect &= "Password=" & $varPass & ";" $objConnection.Open($strConnect) If $varInitalCatalog Then Return $objConnection.Execute("USE " & $varInitalCatalog) Else Return 1 EndIf EndFunc Func _OpenRecordset($varTable,$arrSelectFields,$arrWhereFields=0,$varCursorType=$adOpenForwardOnly,$varLockType=$adLockReadOnly) If Not IsObj($objConnection) Then Return -1 If Not IsObj($objRecordSet) Then Return -2 $strOpen = "SELECT " $varFieldCount = UBound($arrSelectFields)-1 For $x = 0 to $varFieldCount $strOpen &= "[" & $arrSelectFields[$x] & "]" If $x < $varFieldCount Then $strOpen &= ", " Next $strOpen &= " FROM " & $varTable If IsArray($arrWhereFields) Then $strOpen &= " WHERE " $varFieldCount = UBound($arrWhereFields)-1 For $x = 0 to $varFieldCount $strOpen &= $arrWhereFields[$x] If $x < $varFieldCount Then $strOpen &= ", " Next EndIf Return $objRecordSet.Open($strOpen,$objConnection,$varCursorType,$varLockType) EndFunc Func _ErrADODB() Msgbox(0,"ADODB COM Error","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $errADODB.description & @CRLF & _ "err.windescription:" & @TAB & $errADODB.windescription & @CRLF & _ "err.number is: " & @TAB & hex($errADODB.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $errADODB.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $errADODB.scriptline & @CRLF & _ "err.source is: " & @TAB & $errADODB.source & @CRLF & _ "err.helpfile is: " & @TAB & $errADODB.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $errADODB.helpcontext _ ) Local $err = $errADODB.number If $err = 0 Then $err = -1 EndFunc #EndRegion Demo Script #include <_ADODB.au3> #include <Array.au3> ;Only needed for This Demo Script $adCurrentProvider = $adProviderMSJET4 ;Microsoft.Jet.OLEDB.4.0 $adCurrentDataSource = @ScriptDir & "\TEMPDB.MDB" ;Establish ADO Connection _OpenConnection($adCurrentProvider,$adCurrentDataSource) ;Create Table Dim $arrFields[3]=["Firstname VARCHAR(50)","Lastname VARCHAR(50)","AnotherField VARCHAR(50)"] ;Init Fields for Table Creation _CreateTable("TestTable",$arrFields) ;Insert Record Dim $arrFieldsandValues[3][3]=[["Firstname","Lastname","AnotherField"],["John","Smith","Rulez"],["Dave","Thomas","Rulez"]] ;Init Fields and Values for Insert _InsertRecords("TestTable",$arrFieldsandValues) ;Retrieve Records from Table Dim $arrSelectFields[3]=["Firstname","Lastname","AnotherField"] ;Init Select Fields for Recordset $arrRecords = _GetRecords("TestTable",$arrSelectFields) _ArrayDisplay($arrRecords) ;Retrieve Records from Table with Where Clause Dim $arrWhereFields[1]=["Firstname = 'Dave'"] $arrRecords = _GetRecords("TestTable",$arrSelectFields,$arrWhereFields) _ArrayDisplay($arrRecords) ;Capture Tables and Colums $tables = _GetTablesAndColumns(1) ;Param causes display if SYSTEM tables. Default (no param) hides these tables _ArrayDisplay($tables) ;Display Tables For $x = 1 to UBound($tables)-1 ;Display Table Columns _ArrayDisplay($tables[$x][1],"Table Name: " & $tables[$x][0]) Next ;Add Column to Table _AddColumn("TestTable","Field2","VARCHAR(10)") ;Drop Column from Table _DropColumn("TestTable","Field2") ;Drop Table _DropTable("TestTable") ;Drop Database _DropDatabase() ;Closes ADO Connection first if using MS.JET.OLEDB.4.0 ;Close ADO Connection ;_CloseConnection() edit: Made a few small changes. I added the ability to create JET DB Files (.MDB) so it is a bit more useful for demo purposes. Added Where Clause to Example Sooner or later I'll modify the GetTablesAndColumns to translate the field types into the literal data types (text,int,date,etc...) and make a more meaningful demo (Multiple tables and what ever else I can think of or someone recommends). edit: Made a few changes based on inputs from Kinshima in post #10 edit: changed _GetRecords() func based on input from @‌kvcinu
    1 point
  4. I couldn't find such a function (could be I'm not looking in the right place), but I thought this was useful. ; #FUNCTION# ==================================================================================================================== ; Name...........: _GUICtrlListView_GetContents ; Description ...: A function to captures the contents of a SysListView32 control into an Array ; Syntax.........: _GUICtrlListView_GetContents($hWnd) ; Parameters ....: $hWnd - A handle to a SysListView32 control. ; Return values .: Success - An array containing SysListView32 control contents. ; Failure - Returns zero and sets the @error flag: ; |1 - $hWnd Parameter failed IsHwnd type check. ; |2 - If Row or Column count of SysListView32 control equals zero. ; Author ........: Paul Wilson (spudw2k) ; Modified.......: 11/05/2020 (spudw2k) ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _GUICtrlListView_GetContents($hWnd) If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0) ;Verify input variable is valid Handle $iCols = _GUICtrlListView_GetColumnCount($hWnd) ;Get SysListView control Column count $iRows = _GUICtrlListView_GetItemCount($hWnd) ;Get SysListView control Row count If $iCols = 0 Or $iRows = 0 Then Return SetError (2, 0, 0) ;If Column or Row count + 0, then error Dim $aListView[$iRows+1][$iCols] ;Instantiate Array, sized to hold SysListView contents (rows & columns) For $iX = 0 to $iCols-1 ;Loop through Columns $aListView[0][$iX] = _GUICtrlListView_GetColumn($hWnd,$iX)[5] ;Get Column name and set first row of array Next ;Continue Loop for each Column For $iX = 0 to $iRows-1 ;Loop through Rows For $iY = 0 To $iCols-1 ;Loop Through Columns $aListView[$iX+1][$iY]=_GUICtrlListView_GetItemText($hWnd,$iX,$iY) ;Get Column value and set Rou# / Col# in array Next ;Continue Loop for each Column Next ;Continue Loop through each Row Return $aListView ;Return array containing SysListView contents EndFunc ;==>_GUICtrlListView_GetContents Demo #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <Array.au3> Local $hGUI, $hImage, $hListView $hGUI = GUICreate("(UDF Created) ListView Create", 400, 300) $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268) _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100) _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2) GUISetState(@SW_SHOW) $aListViewContents = _GUICtrlListView_GetContents($hListView) _ArrayDisplay($aListViewContents) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Func _GUICtrlListView_GetContents($hWnd) If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0) ;Verify input variable is valid Handle $iCols = _GUICtrlListView_GetColumnCount($hWnd) ;Get SysListView control Column count $iRows = _GUICtrlListView_GetItemCount($hWnd) ;Get SysListView control Row count If $iCols = 0 Or $iRows = 0 Then Return SetError (2, 0, 0) ;If Column or Row count + 0, then error Dim $aListView[$iRows+1][$iCols] ;Instantiate Array, sized to hold SysListView contents (rows & columns) For $iX = 0 to $iCols-1 ;Loop through Columns $aListView[0][$iX] = _GUICtrlListView_GetColumn($hWnd,$iX)[5] ;Get Column name and set first row of array Next ;Continue Loop for each Column For $iX = 0 to $iRows-1 ;Loop through Rows For $iY = 0 To $iCols-1 ;Loop Through Columns $aListView[$iX+1][$iY]=_GUICtrlListView_GetItemText($hWnd,$iX,$iY) ;Get Column value and set Rou# / Col# in array Next ;Continue Loop for each Column Next ;Continue Loop through each Row Return $aListView ;Return array containing SysListView contents EndFunc ;==>_GUICtrlListView_GetContents
    1 point
  5. I believe screensavers are typically executed by calling the .scr file with the /s paramter. i.e. C:\Windows\System32\scrnsave.scr /s
    1 point
  6. A simple Google search shows this page, which shows you the location in the registry, along with how to change it. http://www.sevenforums.com/tutorials/2109-screen-saver-change.html
    1 point
  7. ups late. _GUICtrlTreeView_SelectItem($hTreeView, $iItem ) #AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #Tidy_Parameters=/sf #include-once #include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> OnAutoItExitRegister("_EXIT_BEFORE") Opt('GUIOnEventMode', 1) Opt('GUIEventOptions', 1) Opt('MustDeclareVars', 1) Global Const $bDEBUG = True Global $aGuiSize[2] = [320, 250] Global $sGuiTitle = "GuiTitle" Global $hGui Global $hButton_Read Global $hTreeView, $hStyle, $hExStyle Global $oItem = ObjCreate("Scripting.Dictionary") $oItem.Add("color", ObjCreate("Scripting.Dictionary")) $oItem.Item("color").Add("red", 0) $oItem.Item("color").Add("blue", 1) $oItem.Item("color").Add("green", 2) $oItem.Item("color").Add("white", 3) $oItem.Add("computer", ObjCreate("Scripting.Dictionary")) $oItem.Item("computer").Add("keyboard", 0) $oItem.Item("computer").Add("mouose", 1) $oItem.Add("number", ObjCreate("Scripting.Dictionary")) $oItem.Item("number").Add("one", 1) $oItem.Item("number").Add("two", 1) $oItem.Item("number").Add("tree", 1) $hGui = GUICreate($sGuiTitle, $aGuiSize[0], $aGuiSize[1]) GUISetOnEvent($GUI_EVENT_CLOSE, '_EXIT') $hButton_Read = GUICtrlCreateButton("read", 10, 220, 80, 20) GUICtrlSetOnEvent($hButton_Read, "read") $hStyle = BitOR($TVS_CHECKBOXES, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_SHOWSELALWAYS, $TVS_FULLROWSELECT, $TVS_TRACKSELECT, $TVS_NOTOOLTIPS, $TVS_DISABLEDRAGDROP) $hExStyle = Default ;~ $WS_EX_CLIENTEDGE - Do not use, add more 2 pixels $hTreeView = GUICtrlCreateTreeView(10, 10, 300, 200, $hStyle, $hExStyle) Local $iNext = 1 For $each In $oItem.keys Local $parent = GUICtrlCreateTreeViewItem($each, $hTreeView) _GUICtrlTreeView_SetItemParam($hTreeView, $parent, $iNext) $iNext += 1 For $subitem In $oItem.Item($each).keys Local $child = GUICtrlCreateTreeViewItem($subitem, $parent) _GUICtrlTreeView_SetItemParam($hTreeView, $child, $iNext) $iNext += 1 Next GUICtrlSetState($parent, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW, $hGui) While Sleep(10) WEnd Func __IsParent($hTreeView) Return _GUICtrlTreeView_GetParentHandle($hTreeView) EndFunc ;==>__IsParent Func __Parent_Mark($hTreeView, $iItem) ConsoleWrite("__Parent_Mark( $hTreeView=" & $hTreeView & ", $iItem=" & $iItem & " )" & @LF) EndFunc ;==>__Parent_Mark Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @CRLF & _ "+======================================================" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint Func _EXIT() Exit EndFunc ;==>_EXIT Func _EXIT_BEFORE($sInput = 0) If $bDEBUG Then ConsoleWrite("#Func _exit( $sInput=" & (IsDeclared("sInput") ? $sInput : "Null") & " )" & @LF) GUIDelete($hGui) EndFunc ;==>_EXIT_BEFORE Func read() ConsoleWrite("read" & @LF) Local $parent = _GUICtrlTreeView_GetFirstVisible($hTreeView) Do ConsoleWrite("+$parent[ " & $parent & " ] mark[" & (_GUICtrlTreeView_GetChecked($hTreeView, $parent) ? "x" : " ") & "] text[ " & _GUICtrlTreeView_GetText($hTreeView, $parent) & " ]" & @LF) Local $child = _GUICtrlTreeView_GetFirstChild($hTreeView, $parent) Do ConsoleWrite(" $child[ " & $child & " ] mark[" & (_GUICtrlTreeView_GetChecked($hTreeView, $child) ? "x" : " ") & "] text[ " & _GUICtrlTreeView_GetText($hTreeView, $child) & " ]" & @LF) $child = _GUICtrlTreeView_GetNextSibling($hTreeView, $child) Until $child = 0 $parent = _GUICtrlTreeView_GetNextSibling($hTreeView, $parent) Until $parent = 0 EndFunc ;==>read Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview $hWndTreeview = $hTreeView If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndTreeview Local $tInfo = DllStructCreate($tagNMMOUSE, $lParam) Local $tPOINT, $iXX, $iYY, $aPos, $iItem Local Static $CLICK_TREE_VIEW = False Switch $iCode Case $NM_CLICK ; The user has clicked the left mouse button within the control $tPOINT = _WinAPI_GetMousePos(True, $hGui) $iXX = DllStructGetData($tPOINT, "X") $iYY = DllStructGetData($tPOINT, "Y") $aPos = ControlGetPos($hGui, "", $hTreeView) $iItem = _GUICtrlTreeView_HitTestItem($hTreeView, $iXX - $aPos[0], $iYY - $aPos[1]) ConsoleWrite("normal clique[ " & $iItem & " ]" & @LF) $CLICK_TREE_VIEW = True _GUICtrlTreeView_SelectItem($hTreeView, $iItem ) ConsoleWrite("!test" & @CRLF) ; Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control $tPOINT = _WinAPI_GetMousePos(True, $hGui) $iXX = DllStructGetData($tPOINT, "X") $iYY = DllStructGetData($tPOINT, "Y") $aPos = ControlGetPos($hGui, "", $hTreeView) $iItem = _GUICtrlTreeView_HitTestItem($hTreeView, $iXX - $aPos[0], $iYY - $aPos[1]) _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ConsoleWrite("clique duplo [ " & $iItem & " ]" & @LF) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_SETCURSOR ; control is setting the cursor in response to a WM_SETCURSOR message ;~ Local $tInfo = DllStructCreate($tagNMMOUSE, $lParam) $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom")) $iIDFrom = DllStructGetData($tInfo, "IDFrom") $iCode = DllStructGetData($tInfo, "Code") If $CLICK_TREE_VIEW Then $iItem = DllStructGetData($tInfo, "ItemSpec") __Parent_Mark($hTreeView, $iItem) ConsoleWrite("seleção [" & (_GUICtrlTreeView_GetChecked($hTreeView, $iItem) ? "x" : " ") & "][ " & _GUICtrlTreeView_GetText($hTreeView, $iItem) & " ] IsParent[ " & __IsParent($hTreeView) & " ]" & @LF) $CLICK_TREE_VIEW = False EndIf Return 0 ; to enable the control to set the cursor ; Return 1 ; nonzero to prevent the control from setting the cursor EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Saludos
    1 point
  8. Something like this ? #Include <Array.au3> ; Just for _ArrayDisplay #Include <Word.au3> Local $sFile = "test.docx" Local $oWord = _Word_Create() Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\" & $sFile) ; For one property, set its name as second parameter Local $sPACKAGE_NAME = _WordDocGetCustomProperties($oDoc, "PACKAGE_NAME") If $sPACKAGE_NAME = "" Then MsgBox(16, "Error", "PACKAGE_NAME property not set in " & $sFile) ; For all properties, do not set the second parameter Local $aProperties = _WordDocGetCustomProperties($oDoc) _ArrayDisplay($aProperties) Func _WordDocGetCustomProperties($oDoc, $sPropertyName = "") If NOT IsObj($oDoc) Then Return SetError(1, 0, 0) Local $sName, $sValue Local $iCount = $oDoc.CustomDocumentProperties.count If $iCount = 0 Then Return SetError(1, 0, 0) Local $aResult[$iCount][2] If $sPropertyName <> "" Then Redim $aResult[1][2] For $i = 1 To $iCount $sName = $oDoc.CustomDocumentProperties($i).name $sValue = $oDoc.CustomDocumentProperties($i).value If $sPropertyName = "" Then $aResult[$i - 1][0] = $sName $aResult[$i - 1][1] = $sValue ElseIf $sPropertyName = $sName Then Return $sValue EndIf Next If $sPropertyName <> "" Then Return SetError(1, 0, 0) Return $aResult EndFunc
    1 point
  9. Better to do it thru VBA (for speed and its native in your environment easy to debug) Just a quick starter (you have to built the part to scan / open all documents you are interested in) Sub ScanProperties() Set myDoc = ActiveDocument iBuiltIn = myDoc.BuiltInDocumentProperties.Count For i = 1 To iBuiltIn tName = myDoc.BuiltInDocumentProperties(i).Name On Error Resume Next tValue = myDoc.BuiltInDocumentProperties(i).Value If Err.Number <> 0 Then tValue = "Undefined value" Err.Clear End If On Error GoTo 0 Debug.Print i & ";" & tName & ";" & tValue Next iBuiltIn = myDoc.CustomDocumentProperties.Count For i = 1 To iBuiltIn tName = myDoc.CustomDocumentProperties(i).Name On Error Resume Next tValue = myDoc.CustomDocumentProperties(i).Value If Err.Number <> 0 Then tValue = "Undefined value" Err.Clear End If On Error GoTo 0 Debug.Print i & ";" & tName & ";" & tValue Next End Sub
    1 point
  10. This is a really awesome update as it includes the expansion of expressions for example StringLen('$') would expand to 1 or BitOR(1, 2) would become 3. Let me know if you find any issues. Thanks. PreExpand Beta: Download: http://www.autoitscript.com/autoit3/mvps/guinness/PreExpand_v1.3.15.38(beta).zip
    1 point
  11. Danyfirex

    Guitar Tab Tester

    Hi all, last night I was playing with >MIDI UDF by Ascend4nt, and thought about making a game to learn the notes on the fretboard of the guitar (in the final I did not the game) but I made a guitar tablature tester. (Maybe I I add the game later.) Functions. Play notes. Play notes. while MouseDown+MouseMove Play Tabs. Change Speed. Highlight Note. Note: The tab file are into the tabs folder (see the file format if you want add more tabs) It does not supports sound effects as (slide,bend,pull off) Only clean notes. Update Version 0.1.3 (02/03/2014) Latest version! Version 0.1.3 (02/03/2014) Changed: _PlayTab Funcion rewritten Added: Play/Stop while Tab is sounding Added: Change Timing while Tab is sounding Added: Number Fret marks Added: Some tabs Guitar Tab Tester 0.1.3.rar Update Version 0.1.2 (18/02/2014) Older version! Version 0.1.2 (18/02/2014) Fixed: Notes up 9 fret Doesn't Sound Fixed: Notes Highlighting Added: English Notation Added: Some tabs Changed: GUI Look Changed: Code Structure Guitar Tab Tester 0.1.2.rar Capture: Well I hope You understand it was a hard fight vs Google traslate. (sorry for my English) suggestions, criticism, comments, help are wellcome. Saludos
    1 point
  12. Holger

    Tristate GUI TreeView

    Hi here is the lib you could use to create a GUI tristate treeview. Just take a look in the zip-file. Extract all files in to the same dir and the take a look into the sample-file. I also put some state image bitmaps in. It's just like a beginning (version 0.2). The next thing I'm working on is to check for the right state: that means it's not usefull to put the state "GUI_INDERMINATE" manually to an item! And if the state of an item is changing then call a userdefined function to i.e. set another entry in the combo box(like in the sample) or doing some other things... If you have any problems/question then just let me know Greets Holger tristatestuff.zip
    1 point
  13. Zinthose

    Hex Edit Functions

    I needed a way to HexEdit / Patch a file to repair a common file corruption problem in a software package my company uses. I first used the AutoIt core FileOpen / FileWrite functions but this method required me to open the whole file into memory. The files I work with can be several hundred megabytes in size and easily cause out of memory errors. So, After searching / hacking I came up with this solution. I hope someone finds it useful #include <WinAPI.au3> _Demo() Func _Demo() Local Const $TestFile_Path = @ScriptDir & "\Test.Bin" Local $TestFile_ID, $bData, $Offset ;## Hex offsets / lengths of the data stored in the file. Local Const $Offset_Phone[2] = [0x012, 4] Local Const $Offset_NewToy[2] = [0x1b6, 18] Local Const $Offset_Recycle[2] = [0x594, 24] ;## Binary string of the test file. Local Const $TestFile_Data = "0x" & _ "42494E000000000000000000000000000000867530900000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000446F6E27742054617A65206D" & _ "652042726F21000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000536F796C656E742067726565" & _ "6E2069732070656F706C6521000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" & _ "000000000000000000000000" ;## Create Test File $TestFile_ID = FileOpen($TestFile_Path, 14) FileWrite($TestFile_ID, Binary($TestFile_Data)) FileClose($TestFile_ID) ;## Read the Recycle Value $bData = _HexRead($TestFile_Path, $Offset_Recycle[0], $Offset_Recycle[1]) ;## Convert data to a string and display. MsgBox(4096, Default, "Recycle:" & @CRLF & BinaryToString($bData)) ;## Change the recycle value $bData = StringToBinary("It Tastes like chicken!!") _HexWrite($TestFile_Path, $Offset_Recycle[0], $bData) ;## Read the Recycle Value $bData = _HexRead($TestFile_Path, $Offset_Recycle[0], $Offset_Recycle[1]) ;## Convert data to a string and display. MsgBox(4096, Default, "Recycle:" & @CRLF & BinaryToString($bData)) ;## Search for a specific value and display $Offset = _HexSearch($TestFile_Path, $bData) MsgBox(4096, "HexSearch Function", "Search performed to locate data stream: " & @CRLF & @TAB & $bData & @CRLF & "Result = 0x" & Hex($Offset, 3)) EndFunc #Region ;**** HexEdit Functions Func _HexWrite($FilePath, $Offset, $BinaryValue) Local $Buffer, $ptr, $bLen, $fLen, $hFile, $Result, $Written ;## Parameter Checks If Not FileExists($FilePath) Then Return SetError(1, @error, 0) $fLen = FileGetSize($FilePath) If $Offset > $fLen Then Return SetError(2, @error, 0) If Not IsBinary($BinaryValue) Then Return SetError(3, @error, 0) $bLen = BinaryLen($BinaryValue) If $bLen > $Offset + $fLen Then Return SetError(4, @error, 0) ;## Place the supplied binary value into a dll structure. $Buffer = DllStructCreate("byte[" & $bLen & "]") DllStructSetData($Buffer, 1, $BinaryValue) If @error Then Return SetError(5, @error, 0) $ptr = DllStructGetPtr($Buffer) ;## Open File $hFile = _WinAPI_CreateFile($FilePath, 2, 4, 0) If $hFile = 0 Then Return SetError(6, @error, 0) ;## Move file pointer to offset location $Result = _WinAPI_SetFilePointer($hFile, $Offset) $err = @error If $Result = 0xFFFFFFFF Then _WinAPI_CloseHandle($hFile) Return SetError(7, $err, 0) EndIf ;## Write new Value $Result = _WinAPI_WriteFile($hFile, $ptr, $bLen, $Written) $err = @error If Not $Result Then _WinAPI_CloseHandle($hFile) Return SetError(8, $err, 0) EndIf ;## Close File _WinAPI_CloseHandle($hFile) If Not $Result Then Return SetError(9, @error, 0) EndFunc Func _HexRead($FilePath, $Offset, $Length) Local $Buffer, $ptr, $fLen, $hFile, $Result, $Read, $err, $Pos ;## Parameter Checks If Not FileExists($FilePath) Then Return SetError(1, @error, 0) $fLen = FileGetSize($FilePath) If $Offset > $fLen Then Return SetError(2, @error, 0) If $fLen < $Offset + $Length Then Return SetError(3, @error, 0) ;## Define the dll structure to store the data. $Buffer = DllStructCreate("byte[" & $Length & "]") $ptr = DllStructGetPtr($Buffer) ;## Open File $hFile = _WinAPI_CreateFile($FilePath, 2, 2, 0) If $hFile = 0 Then Return SetError(5, @error, 0) ;## Move file pointer to offset location $Pos = $Offset $Result = _WinAPI_SetFilePointer($hFile, $Pos) $err = @error If $Result = 0xFFFFFFFF Then _WinAPI_CloseHandle($hFile) Return SetError(6, $err, 0) EndIf ;## Read from file $Read = 0 $Result = _WinAPI_ReadFile($hFile, $ptr, $Length, $Read) $err = @error If Not $Result Then _WinAPI_CloseHandle($hFile) Return SetError(7, $err, 0) EndIf ;## Close File _WinAPI_CloseHandle($hFile) If Not $Result Then Return SetError(8, @error, 0) ;## Return Data $Result = DllStructGetData($Buffer, 1) Return $Result EndFunc Func _HexSearch($FilePath, $BinaryValue, $StartOffset = Default) Local $Buffer, $ptr, $hFile, $Result, $Read, $SearchValue, $Pos, $BufferSize = 2048 ;## Parameter Defaults If $StartOffset = Default Then $StartOffset = 0 ;## Parameter Checks If Not FileExists($FilePath) Then Return SetError(1, @error, 0) $fLen = FileGetSize($FilePath) If $StartOffset > $fLen Then Return SetError(2, @error, 0) If Not IsBinary($BinaryValue) Then Return SetError(3, @error, 0) If Not IsNumber($StartOffset) Then Return SetError(4, @error, 0) ;## Prep the supplied binary value for search $SearchValue = BinaryToString($BinaryValue) ;## Define the dll structure to store the data. $Buffer = DllStructCreate("byte[" & $BufferSize & "]") $ptr = DllStructGetPtr($Buffer) ;## Open File $hFile = _WinAPI_CreateFile($FilePath, 2, 2, 1) If $hFile = 0 Then Return SetError(5, @error, 0) ;## Move file pointer to offset location $Result = _WinAPI_SetFilePointer($hFile, $StartOffset) $err = @error If $Result = 0xFFFFFFFF Then _WinAPI_CloseHandle($hFile) Return SetError(5, $err, 0) EndIf ;## Track the file pointer's position $Pos = $StartOffset ;## Start Search Loop While True ;## Read from file $Read = 0 $Result = _WinAPI_ReadFile($hFile, $ptr, $BufferSize, $Read) $err = @error If Not $Result Then _WinAPI_CloseHandle($hFile) Return SetError(6, $err, 0) EndIf ;## Prep read data for search $Result = DllStructGetData($Buffer, 1) $Result = BinaryToString($Result) ;## Search the read data for first match $Result = StringInStr($Result, $SearchValue) If $Result > 0 Then ExitLoop ;## Test for EOF and return -1 to signify value was not found If $Read < $BufferSize Then _WinAPI_CloseHandle($hFile) Return -1 EndIf ;## Value not found, Continue Tracking file pointer's position $Pos += $Read WEnd ;## Close File _WinAPI_CloseHandle($hFile) If Not $Result Then Return SetError(7, @error, 0) ;## Calculate the offset and return $Result = $Pos + $Result - 1 Return $Result EndFunc Func _WinAPI_SetFilePointer($hFile, $nDistance, $nMethod = 0) Local $nRet $nRet = DllCall("kernel32.dll", "dword", "SetFilePointer", "ptr", $hFile, "long", $nDistance, "ptr", 0, "dword", $nMethod) Return $nRet[0] EndFunc #EndRegion ** UPDATES ** Added new function: _HexSearch()
    1 point
×
×
  • Create New...