Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/24/2016 in all areas

  1. A one user ask about Creating XLS file with ADO. This was interesting to me so I use uncle google and find this: https://forums.autodesk.com/t5/visual-basic-customization/ado-connection-create-file-excel/td-p/1675928 EDIT: https://msdn.microsoft.com/en-us/library/ms675849(v=vs.85).aspx How you can read in this mentioned above link, This is not posible with ADO but quite easy with ADOX. Here is AutoIt example: ;~ https://forums.autodesk.com/t5/visual-basic-customization/ado-connection-create-file-excel/td-p/1675928 ;~ https://msdn.microsoft.com/en-us/library/ms675849(v=vs.85).aspx #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 Global Const $ADO_adInteger = 3 Global Const $ADO_adVarWChar = 202 #include <Array.au3> #include <MsgBoxConstants.au3> _Example() Func _Example() ; Error monitoring. This will trap all COM errors while alive. ; This particular object is declared as local, meaning after the function returns it will not exist. Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") #forceref $oErrorHandler Local $oConnection = ObjCreate('ADODB.Connection') Local $oCatalog = ObjCreate('ADOX.Catalog') Local $oTable = ObjCreate('ADOX.Table') ; Local $oColumn = ObjCreate('ADOX.Column') $oConnection.open("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & @ScriptDir & '\ADOX_EXAMPLE__MyContacts.xls' & ";Extended Properties=Excel 8.0") $oCatalog.ActiveConnection = $oConnection With $oTable .Name = "MyContacts" .ParentCatalog = $oCatalog ; Create fields and append them to the new Table object. .Columns.Append("ContactId", $ADO_adInteger) .Columns.Append("CustomerID", $ADO_adVarWChar, 16) ; Make the ContactId column and auto incrementing column .Columns("ContactId").Properties("AutoIncrement") = True ; Create fields and append them to the new Table object. .Columns.Append("FirstName", $ADO_adVarWChar, 80) .Columns.Append("LastName", $ADO_adVarWChar, 80) .Columns.Append("Phone", $ADO_adVarWChar, 20) .Columns.Append("Notes", $ADO_adVarWChar) EndWith $oCatalog.Tables.Append($oTable) ;Clean up $oConnection.Close $oConnection = Null ; $oColumn = Null $oTable = Null $oCatalog = Null EndFunc ;==>_Example ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Have fun, mLipok
    1 point
  2. Step 1: Open all-new binary file for writing. Step 2: Write your bytes to that. Step 3: Open the file you want to alter for reading. Step 4: Iterate over the bytes in the read file, write them to the write file. Step 5: Close both file handles. Step 6: Delete file you want to alter. Step 7: Rename (and move if in different directory) your new file to the name (and path) of the old. EDIT: More detailed version of JohnOne's answer.
    1 point
  3. #include 'ArrayWorkshop.au3' _UniqueRegion($aArray) Edit Actually, I just thought about this. There can't be any duplicate paths to files: Windows won't allow it. You must mean something more complicated, perhaps you mean duplicate file names regardless of folder location. To do that, you could copy the array, remove duplicates from the 2nd column, search the original array for unique entries and create a new array with unique file names (any path). Of course a duplicate file name does not imply that the contents are the same. All the functions you need are in the help file starting with the prefix '_Array'. However if you were just giving an example of how you might use it, then you might like to try _UniqueRegion() with an example that contains fully duplicated rows. Suppose you combined data from several sources, then _UniqueRegion() might be suitable.
    1 point
  4. JohnQSmith

    Simple calculator

    Multiply the fractional part by 60 to get minutes, then the fractional part of that to get seconds. .81818 * 60 = 49.0908 ~ 49 minutes .0908 * 60 = 5.448 seconds
    1 point
  5. Nope, but inferring emotion in text is a good start at getting me there. Focus on the task and less on the niceties, if you walked into a coding forum looking for people who are not completely socially inept, then thats on you.
    1 point
  6. I'm guessing he's just asking what the end result should look like, because there's a hundred ways of doing this and no one wants to waste time writing code when you want one of the other 99 ways it could be done. Show us what the start array looks like, what you'd like the end array to look like, and then there's a goal to reach for. Also, don't change the parameters of your request in the middle of everything because that's a sure way to cause anger issues. Make sure you know exactly what it is you need the code to do before you start asking for help, or writing the code.
    1 point
  7. 1 point
  8. No, there are just a metric shit ton of more questions when asking to simply dedup a 2d array. So lets start, I'll provide an answer and you lead us down the bunny trail. The biggest help would be the endgame, because I have to assume you want duplicates gone leaving the data in some sort of ingestable format. #include<array.au3> local $a2D = [['1','2'],['3','4'],['4','5'],['5','6']] _ArrayDisplay($a2D) For $i = ubound($a2D) - 1 to 0 step -1 For $c = 1 to 0 step -1 $vSrch = _ArraySearch($a2D , $a2D[$i][$c] , 0 , $i - 1) If $vSrch > 1 then $a2D[$i][$c] = "" Next Next _ArrayDisplay($a2D)
    1 point
  9. FileRead to read your file (store it in a variable) StringInStr to search for the string in your variable
    1 point
  10. Iczer

    WinHTTP functions

    it seems culprit was KB968730 (lack of it) it's ok now
    1 point
  11. spudw2k

    Merge two files

    If you change the redirector for your ipconfig command to >> it will append the results to the text file. netsh mbn show interface dump > c:\temp\a.txtipconfig /all >> c:\temp\a1.txt This page may have some useful information for you regarding command line execution and output redirection.
    1 point
  12. That depends on form's enctype. If it's default or "application/x-www-form-urlencoded" then it should work out of the box. If it's "multipart/form-data" then pass it like this: BinaryToString(StringToBinary("æ¼¢whatever", 4), 1) ...Maybe I should have this made built-in.
    1 point
  13. dynamitemedia, In my script I use the $sFilter variable to tell the _List_Images function what to list - so you need to do the same thing by setting the initial value of the variable to what you want displayed when the script starts and then adjusting its content when one of the 2 buttons is pressed. Once you have the list you will need obviously need to add the images to the buttons - I used GUICtrlSetData to get the file name into the button, so you would need to replace that with a GUICtrlSetImage line. Other than that I think that the script is pretty much what you want - if not, then please do come back. M23
    1 point
  14. dynamitemedia, I see - looks like a child GUI might be the way to go here. I will see what I can do. M23 Edit: Not very difficult to code - now you just scroll the image buttons and leave the top ones in place: #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> #include "GUIScrollbars_Ex.au3" ; Put your image paths in this array - sized to match required number of buttons Global $aImage[37]; = ["Image_Path_1", "Image_Path_2", "Image_Path_3", "Image_Path_4", "Image_Path_5", "Image_Path_6", "Image_Path_7", "Image_Path_8"] $iCount = UBound($aImage) ; Create array to hold button and label ControlIDs Global $aButton[$iCount], $aLabel[$iCount] ; Max buttons per row Global $iCol_Count = 5 ; Determine rows required $iRow_Count = Ceiling($iCount / $iCol_Count) Mainscript() Func Mainscript() ; Set max dialog size $iDialog_Width = 1265 $iDialog_Depth = 525 ; Determine button width $iButton_Dim = Floor(($iDialog_Width - 10 - _WinAPI_GetSystemMetrics(2)) / $iCol_Count) ; Determine required depth $iVisRows = 0 While 1 $iVisRows += 1 If $iButton_Dim * $iVisRows > $iDialog_Depth Then $iVisRows -= 1 ExitLoop EndIf WEnd $iDialog_Depth = ($iButton_Dim * $iVisRows) + 10 ; Add the space for the buttons to get the main GUI size $iMain_Depth = $iDialog_Depth + 100 ; Create main GUI $hGUI = GUICreate("MainGUI", $iDialog_Width, $iMain_Depth) $cPrograms = GUICtrlCreateButton("Programs", ($iDialog_Width / 2) - 320, 20, 300, 60) $cNetWorks = GUICtrlCreateButton("NetWorks", ($iDialog_Width / 2) + 20, 20, 300, 60) GUISetState() ; Create dialog $hDialog = GUICreate("", $iDialog_Width, $iDialog_Depth, 0, 100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) GUISetBkColor(0xFFFFFF) If $iRow_Count > $iVisRows Then _GUIScrollbars_Generate($hDialog, 0, $iButton_Dim * $iRow_Count) EndIf ; Create labels For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aLabel[$iIndex] = GUICtrlCreateLabel("", 10 + ($iButton_Dim * $j), 10 + ($iButton_Dim * $i), $iButton_Dim - 10, $iButton_Dim - 10) GUICtrlSetBkColor($aLabel[$iIndex], 0xFFFFFF) GUICtrlSetState($aLabel[$iIndex], $GUI_DISABLE) GUICtrlSetResizing($aLabel[$iIndex], $GUI_DOCKALL) Next Next ; Create buttons For $i = 0 To $iRow_Count - 1 For $j = 0 To $iCol_Count - 1 $iIndex = $j + ($i * $iCol_Count) If $iIndex > $iCount - 1 Then ExitLoop $aButton[$iIndex] = GUICtrlCreateButton("Button " & ($iIndex + 1), 15 + ($iButton_Dim * $j), 15 + ($iButton_Dim * $i), $iButton_Dim - 20, $iButton_Dim - 20, $BS_BITMAP) GUICtrlSetImage($aButton[$iIndex], $aImage[$iIndex]) GUICtrlSetResizing($aButton[$iIndex], $GUI_DOCKALL) Next Next ; Set default button GUICtrlSetState($aButton[0], $GUI_FOCUS) GUICtrlSetBkColor($aLabel[0], 0x00FF00) $hActive = GUICtrlGetHandle($aButton[0]) ; Create dummy controls $cDummy_Up = GUICtrlCreateDummy() $cDummy_Dn = GUICtrlCreateDummy() $cDummy_Left = GUICtrlCreateDummy() $cDummy_Right = GUICtrlCreateDummy() GUISetState() ; Set the Up/Down/Left/Right keys as accelerators - they will only act like this when your GUI is active Local $aAccelKeys[4][2] = [["{UP}", $cDummy_Up], ["{DOWN}", $cDummy_Dn], ["{LEFT}", $cDummy_Left], ["{RIGHT}", $cDummy_Right]] GUISetAccelerators($aAccelKeys) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $cDummy_Up _Move_Focus($hDialog, 1) Case $cDummy_Dn _Move_Focus($hDialog, 2) Case $cDummy_Left _Move_Focus($hDialog, 3) Case $cDummy_Right _Move_Focus($hDialog, 4) Case Else For $i = 0 To $iCount - 1 If $iMsg = $aButton[$i] Then MsgBox($MB_SYSTEMMODAL, "Pressed", "Button " & $i + 1) ExitLoop EndIf Next EndSwitch ; Get focused control $hCurrFocus = _WinAPI_GetFocus() ; If it has changed If $hCurrFocus <> $hActive Then ; See if it is a button For $i = 0 To $iCount - 1 If $hCurrFocus = GUICtrlGetHandle($aButton[$i]) Then ; Reset all the labels For $j = 0 To $iCount - 1 GUICtrlSetBkColor($aLabel[$j], 0xFFFFFF) Next ; Highlight the correct label GUICtrlSetBkColor($aLabel[$i], 0x00FF00) ExitLoop EndIf Next $hActive = $hCurrFocus EndIf WEnd EndFunc ;==>Mainscript Func _Move_Focus($hDialog, $iMode) Local $iNext_Button, $iRow, $iNewRow Local $iRow_Count = Ceiling($iCount / $iCol_Count) ; Get active control $hActive = _WinAPI_GetFocus() For $i = 0 To $iCount - 1 ; If it is a button If $hActive = GUICtrlGetHandle($aButton[$i]) Then ; Determine row $iRow = Int($i / $iCol_Count) $iNewRow = $iRow ; Set default value for next button $iNext_Button = $i Switch $iMode Case 1 ; Not if in top row If $iRow Then $iNext_Button -= $iCol_Count ; Set new row $iNewRow -= 1 EndIf Case 2 ; Not if in bottom row or there no button below If ($iRow < $iRow_Count - 1) And ($i + $iCol_Count < $iCount) Then $iNext_Button += $iCol_Count ; Set new row $iNewRow += 1 EndIf Case 3 ; If not first button If $i <> 0 Then $iNext_Button -= 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf Case 4 ; If not last button If $i <> $iCount Then $iNext_Button += 1 $iNewRow = Int($iNext_Button / $iCol_Count) EndIf EndSwitch ; Set focus to new button GUICtrlSetState($aButton[$iNext_Button], $GUI_FOCUS) ; Get button into view by scrolling to page which includes button _GUIScrollbars_Scroll_Page($hDialog, 0, Int($iNewRow / 2) + 1) ; No point in looking further ExitLoop EndIf Next EndFunc ;==>_Move_Focus But looking at your code I see you are recursively calling the programsGui function - really not a good idea as it can only end in tears. You need to recast the code so that only the buttons are changed, rather than deleting and recreating the entire GUI each time. I will see what I can do to restructure the code this morning if I find time.
    1 point
×
×
  • Create New...