Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/19/2016 in all areas

  1. It doesn't make a big difference when you directly access the property $sResult = $oObject.PropertyName or call a function $sResult = _GetObjectProperty($oObject, "PropertyName") Func _GetObjctProperty($oObjcet, $sPropertyName) Return($oObject."PropertyName") ; Does not work EndFunc But it get's much more complex as soon as you need to check for a valid property name. You do not want your script to crash when a user passes no or an invalid property. If I find the time I will dig for this old thread. IIRC there was a solution for your problem.
    1 point
  2. Lmao, sounds like a work around I would have done if I hadn't known about window procedures. I hope you were at least using a mouse hook so the WM_MBUTTONDOWN was never sent to the GUI
    1 point
  3. I made a quick Autoit review (again) and I do not think this is possible to do with AutoIt exactly all the things, what @Xandy said EDIT: Oooops sorry forget about one:
    1 point
  4. You example is a little confusing to me. Shouldn't you be referring to the columns instead of having a row with headers? Anyways--as a starting point--here is an example I pieced together from a UDF I made a while back which queries in the fashion you want, but refers to the column names. The example creates a TempDB.MDB file (in the script dir), inserts test data, queries data, deletes TempDB. #AutoIt3Wrapper_UseX64=n #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 #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[4]=["[KEY] INTEGER","[DATA1] INTEGER","[DATA2] INTEGER","[DATA3] INTEGER"] ;Init Fields for Table Creation _CreateTable("REPAIR_DATA",$arrFields) ;Insert Records Dim $arrFieldsandValues[9][4]=[["[KEY]","[DATA1]","[DATA2]","[DATA3]"],[1,1,1,1],[2,1,1,1],[3,1,1,1],[4,1,1,1],[5,2,3,4],[6,1,1,1],[7,1,1,1],[8,1,1,1]] ;Init Fields and Values for Insert _InsertRecords("REPAIR_DATA",$arrFieldsandValues) ;Retrieve Records from Table with Where Clause Dim $arrSelectFields[4]=["KEY","DATA1","DATA2","DATA3"] ;Init Select Fields for Recordset Dim $arrWhereFields[1]=["[KEY] = 5"] $arrRecords = _GetRecords("REPAIR_DATA",$arrSelectFields,$arrWhereFields) _ArrayDisplay($arrRecords) ;Drop Database _DropDatabase() ;Closes ADO Connection first if using MS.JET.OLEDB.4.0 #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[1][1] ; $objRecordSet.MoveFirst ; $x = 0 ; For $objField in $objRecordSet.Fields ; ReDim $arrRecords[1][$x+1] ; $arrRecords[0][$x]=$objField.Name ; $x+=1 ; Next ; Do ; ReDim $arrRecords[UBound($arrRecords)+1][$x] ; $x = 0 ; For $objField in $objRecordSet.Fields ; $arrRecords[UBound($arrRecords)-1][$x] = $objField.Value ; $x+=1 ; Next ; $objRecordSet.MoveNext ; Until $objRecordSet.EOF 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 msgbox(0,"Get Records",$strOpen) 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
    1 point
  5. stealthmsgr

    ArrayWorkshop

    No problem. I'll use local and BTW I have found the error.
    1 point
  6. argumentum

    MessagePack UDF

    MsgPack.zip
    1 point
  7. GordonFreeman, Oh yes it is. That simple subtraction gives you the difference between the 2 numbers - but if you look carefully there are indeed 50 pixels: 10 ] 30 ] 50 ] 11 ] 31 ] 51 ] 12 ] 32 ] 52 ] 13 ] 33 ] 53 ] 14 ] 34 ] 54 ] 15 ] 35 ] 55 ] 16 ] 36 ] 56 ] 17 ] 37 ] 57 ] 18 ] 38 ] 58 ] 19 ] - first 10 39 ] - third 10 59 ] - fifth 10 20 ) 40 ) 21 ) 41 ) 22 ) 42 ) 23 ) 43 ) 24 ) 44 ) And 5 x 10 = 50 25 ) 45 ) 26 ) 46 ) 27 ) 47 ) 28 ) 48 ) 29 ) - second 10 49 ) - fourth 10 The subtraction ignores the "10" pixel. M23
    1 point
  8. LarsJ

    about dllcall help me!

    You can test with code like this: The size of the structure in post 1 seems to be 172 bytes. You can create an array with room for 50 structures in this way: ; Structure definition $MAX_ARRAY_SIZE = 50 ;$tag_LanSearchInfo2 = "char UID[21];char IP[16];ushort port;char DeviceName[132];char Reserved" ; Structure, 174 bytes $tag_LanSearchInfo2 = "align 1;char UID[21];char IP[16];ushort port;char DeviceName[132];char Reserved" ; Structure, 172 bytes $st_LanSearchInfo2 = DllStructCreate( $tag_LanSearchInfo2 ) ; Create structure $size_LanSearchInfo2 = DllStructGetSize( $st_LanSearchInfo2 ) ; Size of structure ConsoleWrite( "$size_LanSearchInfo2 = " & $size_LanSearchInfo2 & @CRLF ) $array_LanSearchInfo2 = DllStructCreate( "byte[" & $size_LanSearchInfo2 * $MAX_ARRAY_SIZE & "]" ) ; Array of structures You have to test the code to see if you need alignment or not. Now you can call the function like this: ; Function call $nWaitTimeMs = 5000 $nSendIntervalMs = 0 ; ???? DllCall( "IOTCAPIs.dll", "int", "IOTC_Lan_Search2_Ex", "struct*", $array_LanSearchInfo2, "int", $MAX_ARRAY_SIZE, "int", $nWaitTimeMs, "int", $nSendIntervalMs ) ;DllCall( "IOTCAPIs.dll", "int:cdecl", "IOTC_Lan_Search2_Ex", "struct*", $array_LanSearchInfo2, "int", $MAX_ARRAY_SIZE, "int", $nWaitTimeMs, "int", $nSendIntervalMs ) You have to test the code to see if you need the "cdecl" calling convention. ; Get count $count = 0 $pointer = DllStructGetPtr( $array_LanSearchInfo2 ) For $i = 0 To $MAX_ARRAY_SIZE - 1 $st_LanSearchInfo2 = DllStructCreate( $tag_LanSearchInfo2, $pointer ) If DllStructGetData( $st_LanSearchInfo2, "UID" ) Then $count += 1 $pointer += $size_LanSearchInfo2 Next ConsoleWrite( "$count = " & $count & @CRLF )
    1 point
  9. The trick is that you have to wait until the elements are visible. This works for me: #include <FF.au3> If _FFConnect() Then _FFTabAdd('rumah123.com') $oInput = _FFXPath('//*[@data-target="#LoginAgentModal"]') _FFCmd('FFau3.xpath.click()') While True _FFXPath('//input[@id="username"]') $result = _FFCmd('FFau3.xpath') If $result <> '' Then ExitLoop EndIf WEnd $cValue = 'me@me.com' $result = _FFCmd("FFau3.xpath.value='" & $cValue & "'") EndIf
    1 point
  10. one query really is the fastest easiest way to do it; but make sure that you have a where statement unless you want every single row updated. i'm not sure if you can do the increment and assign like that though, may have to actually write out "product = product + 1"
    1 point
×
×
  • Create New...