Leaderboard
Popular Content
Showing content with the highest reputation on 05/06/2017 in all areas
-
Ah okay! I thought perhaps you might want to create a 2D array only containing unique rows, and functions for that exist. These are two different things. Carry on!1 point
-
Deye, I don't think any distributed functions work on arrays with more than 2 dimensions. The following strips column #4 from a 10 column "2D" array... #include <array.au3> ; create and populate a 10 column 2D array Local $a2Darray[10][10] For $1 = 0 To UBound($a2Darray) - 1 For $2 = 0 To UBound($a2Darray, 2) - 1 $a2Darray[$2][$1] = StringFormat('%03i-%03i', $1, $2) Next Next _ArrayDisplay($a2Darray) ; create a 1D array from column #4 of the previous array Local $a1Darray[UBound($a2Darray)] For $1 = 0 To UBound($a2Darray) - 1 $a1Darray[$1] = $a2Darray[$1][3] Next _ArrayDisplay($a1Darray, 'Column 4 of 2D array') kylomas1 point
-
arp -a output .txt
antonioj84 reacted to Subz for a topic
Try the following, you can use partial string (left to right) of what ever you like to search for e.g IP Address "192.168", Mac Address "90-"or Type "Static", you can leave fields blank to return the entire arp list. #Include <Array.au3> #Include <AutoItConstants.au3> $aARP_192168 = ARP_OUTPUT('', '90-', '') _ArrayDisplay($aARP_192168) Func ARP_OUTPUT($vIPAddress = '', $vMacAddress = '', $vType = '') Local $iPid = Run("cmd /c arp -a","",@SW_HIDE,$STDOUT_CHILD) ProcessWaitClose($iPid) Local $sArp = StdoutRead($iPid) Local $aArpTable = StringRegExp($sArp, "((?:\d+\.){3}\d+)\h+((?:[[:xdigit:]]{2}-){5}[[:xdigit:]]{2})\h+(\V+)", 3) Local $aArpTable2D[0][3] For $i = 0 To UBound($aArpTable) - 1 Step 3 If $vIPAddress <> '' And StringLeft(StringStripWS($aArpTable[$i], 7), StringLen($vIPAddress)) <> $vIPAddress Then ContinueLoop If $vMacAddress <> '' And StringLeft(StringStripWS($aArpTable[$i + 1], 7), StringLen($vMacAddress)) <> $vMacAddress Then ContinueLoop If $vType <> '' And StringStripWS($aArpTable[$i + 2], 7) <> $vType Then ContinueLoop _ArrayAdd($aArpTable2D, $aArpTable[$i] & '|' & $aArpTable[$i + 1] & '|' & $aArpTable[$i + 2]) Next Return $aArpTable2D EndFunc1 point -
You're confusing internal encoding used by an SQLite DB and the encoding used for results of your queries. When you get results with things like _SQLite_GetTable2d or similar, the strings you get are already UTF16-LE. No such beast can exist. When your create a DB with default options, it's created with internal UTF8 setting. Every string you insert then from AutoIt using the standard UDF is converted from UTF16 to UTF8 by SQLite internally and transparently. When you query the DB and fetch results, strings are also automagically converted from internal UTF8 to UTF16.1 point
-
Yes you are. They will all work correctly, some remarks yet : The first one will insert a crlf just before any $M encountered, so it could be done a little simpler StringRegExpReplace(FileRead("ahihi.txt"), '(?=\$M)', @crlf) If the second one is made to remove all "$=P1298*x" precisely then it could be done more selective - which is always a good idea when using regex StringRegExpReplace(FileRead("ahihi.txt"), '\$=P1298\*\d+', '') Nothing to say about the third1 point
-
Embedding 3rd Party app and 2 browsers in GUI - I'm THIS close.
Xandy reacted to coffeeturtle for a topic
Are you experiencing a strange occurrence and that the window instead of being embedded is acting like an overlay? In other words, are you getting a window covering up another and can actually click and drag it out separating the two? If so, I wonder about the DLL calls you're making to make the parent/child windows. I could be wrong. But wouldn't something like this be more helpful: $h_HWND = _IEPropertyGet($o_IE, "hwnd") $hhwnd = WinGetProcess($hWnd) _WinAPI_SetParent($h_HWND, [your GUI]) _WinAPI_MoveWindow($h_HWND, $0, $0, 1049, 550, False) _WinAPI_SetWindowLong($h_HWND, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) The two browser windows would be something like this: $o_IE = ObjCreate("InternetExplorer.Application") $o_IE.theatermode = True $o_IE.fullscreen = True $o_IE.statusbar = False _IENavigate($o_IE, 'about:blank') and $o_IETwo = ObjCreate("InternetExplorer.Application") $o_IETwo.theatermode = True $o_IETwo.fullscreen = True $o_IETwo.statusbar = False _IENavigate($o_IETwo, 'about:blank') I hope this helps. The other folks here can add more insights.1 point -
arp -a output .txt
antonioj84 reacted to Subz for a topic
@jguinch How would you get the full arp table like below with RegEx? Local $iPid = Run("cmd /c arp -a","",@SW_HIDE,$STDOUT_CHILD) ProcessWaitClose($iPid) Local $sArp = StdoutRead($iPid) Local $aArpTable = StringSplit($sArp, @LF) Local $aArpTable1D ;~ String Split Local $aArpTable2D[1][3] For $i = $aArpTable[0] To 1 Step - 1 If StringStripWS($aArpTable[$i], 8) = '' Then ContinueLoop $aArpTable1D = StringSplit(StringStripWS($aArpTable[$i], 7), ' ', 2) _ArrayTranspose($aArpTable1D) If UBound($aArpTable1D, 2) = 3 Then _ArrayConcatenate($aArpTable2D, $aArpTable1D) Next _ArraySort($aArpTable2D, 0, 1) $aArpTable2D[0][0] = UBound($aArpTable2D) - 1 _ArrayDisplay($aArpTable2D)1 point -
Convert ms to day/hour/min/sec
argumentum reacted to mikell for a topic
#include <Date.au3> $hTimer = TimerInit() $rtime = 2 * 86400000 ;2 days in ms While 1 sleep(1000) Local $fDiff = TimerDiff($hTimer) Local $ctime = $rtime - $fDiff if $fDiff > $rtime Then ;GetnPost() ToolTip("TIMESUP!!!!",0,0) Sleep(5000) Local $hTimer = TimerInit() Else ToolTip("TIMELEFT: " & _Convert($ctime), 0, 0) EndIf WEnd Func _Convert($ms) Local $day, $hour, $min, $sec _TicksToTime($ms, $hour, $min, $sec) If $hour > 24 Then $day = $hour/24 $hour = Mod($hour, 24) EndIf Return StringFormat("%02i/%02i/%02i/%02i", $day, $hour, $min, $sec) EndFunc1 point -
You need to form an array of structures. The problem is variable length of the array so you have to create raw binary structure tha wraps complete MIB_IPNETTABLE structure. Once you do that it's only a matter of collecting by interpretting chunks of raw structure as array of MIB_IPNETROW's and printing interesting data. I understand that there might be difficulties for you to understand what I'm talking about here so I wrote a function to show you how that few sentences look written in AutoIt as opposed to English: PrintIpNetTable() Func PrintIpNetTable() ; Start with initial call to calculate the size of the sructure Local $aCall = DllCall("iphlpapi.dll", "dword", "GetIpNetTable", _ "ptr*", 0, _ "dword*", 0, _ "bool", 1) ; Check for errors If @error Then Return SetError(1, 0, 0) If $aCall[0] <> 122 Then Return SetError(2, 0, 0) ; ERROR_INSUFFICIENT_BUFFER ; Read the size Local $iSize = $aCall[2] ; Allocate that much Local $tByteStructure = DllStructCreate("byte[" & $iSize & "]") ; Get pointer Local $pPointer = DllStructGetPtr($tByteStructure) ; Now fill the struct $aCall = DllCall("iphlpapi.dll", "dword", "GetIpNetTable", _ "ptr", $pPointer, _ "dword*", $iSize, _ "bool", 1) ; Interpret as modified MIB_IPNETTABLE structure to read the number of entries Local $tMIB_IPNETTABLE_NumEnries = DllStructCreate("dword dwNumEntries;", $pPointer) ; Read that number Local $iNumEntries = DllStructGetData($tMIB_IPNETTABLE_NumEnries, "dwNumEntries") $pPointer += 4 ; skip the size of that dword Local Const $MAXLEN_PHYSADDR = 8 Local $tMIB_IPNETROW ; Loop through the array of structures printing read data For $i = 0 To $iNumEntries - 1 $tMIB_IPNETROW = DllStructCreate("dword dwIndex;" & _ "dword dwPhysAddrLen;" & _ "byte bPhysAddr[" & $MAXLEN_PHYSADDR & "];" & _ "dword dwAddr;" & _ "dword dwType;", _ $pPointer) ; Print read ConsoleWrite("+Index " & DllStructGetData($tMIB_IPNETROW, "dwIndex") & ":" & @CRLF & _ @TAB & "Physical address = " & BinToMAC(DllStructGetData($tMIB_IPNETROW, "bPhysAddr"), DllStructGetData($tMIB_IPNETROW, "dwPhysAddrLen")) & @CRLF & _ @TAB & "IPv4 address = " & NumToIP(DllStructGetData($tMIB_IPNETROW, "dwAddr")) & @CRLF & _ @TAB & "Type = " & ARPType(DllStructGetData($tMIB_IPNETROW, "dwType")) & @CRLF & @CRLF) ; Skip this struct and continue looping $pPointer += DllStructGetSize($tMIB_IPNETROW) Next ; Bye, bye... EndFunc ;==>PrintIpNetTable ; Few helper functions Func NumToIP($iIP) Return Int(BinaryMid($iIP, 1, 1)) & "." & Int(BinaryMid($iIP, 2, 1)) & "." & Int(BinaryMid($iIP, 3, 1)) & "." & Int(BinaryMid($iIP, 4, 1)) EndFunc Func BinToMAC($bIn, $iSeg) If $iSeg = 0 Then Return "00-00-00-00-00-00" Local $sOut For $i = 1 To $iSeg $sOut &= Hex(BinaryMid($bIn, $i, 1)) & "-" Next Return StringTrimRight($sOut, 1) EndFunc Func ARPType($iType) Local Static $aType[5] = ["", "Unknown", "Invalid", "Dynamic", "Static"] If $iType < 1 Or $iType > 4 Then $iType = 1 Return $aType[$iType] EndFunc1 point