Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/26/2017 in all areas

  1. spudw2k

    _NetStat_GetData

    An oldie but goodie, I was cleaning house and found this old snippet I made back in Apr 2013. It still has some utility, so I figured I'd share it. It runs netstat and populates the output into an array. Very Pretty simple. #include <Constants.au3> #include <Process.au3> #include <Array.au3> Local $aNetStatData = _NetStat_GetData() Local $sHeaders = _ArrayToString($aNetStatData,"|",0,0) _ArrayDelete($aNetStatData, 0) _ArrayDisplay($aNetStatData,"NetStat", "", 32, Default, $sHeaders) Func _NetStat_GetData($bAddProcessName = True) Local $aNetStatData = _NetStat_ProcessOutput(_NetStat_GetOutput()) If $bAddProcessName Then _NetStat_AddProcessName($aNetStatData) Return $aNetStatData EndFunc Func _NetStat_GetOutput() ;Run netstat CMD and get StdOut Local $sNetStatOutput = _RunCMD("netstat.exe -a -o -f") Return $sNetStatOutput EndFunc Func _NetStat_ProcessOutput($sNetStatOutput) ;Convert netstat StdOut to Array Local $arr = StringSplit(StringStripWS($sNetStatOutput,4),@CR) Local $aRecord Dim $aNetStatData[1][5]=[["Protocol","Local Address","Foreign Address","State","PID"]] ReDim $aNetStatData[$arr[0]-3][5] For $iX = 1 To UBound($aNetStatData)-1 $aRecord = StringSplit($arr[$iX+3]," ") If $aRecord[1]="TCP" Then For $iY = 0 to $aRecord[0]-1 $aNetStatData[$iX][$iY] = $aRecord[$iY+1] Next ElseIf $aRecord[1]="UDP" Then For $iY = 0 to $aRecord[0]-2 $aNetStatData[$iX][$iY] = $aRecord[$iY+1] Next $aNetStatData[$iX][4] = $aRecord[4] EndIf Next Return $aNetStatData EndFunc Func _NetStat_AddProcessName(ByRef $aNetStatData) ;Add processname to NetStat Array ;Create NetStat PID / Process Name Array Local $aPIDs = _ArrayUnique($aNetStatData,4,0,0,0) _ArrayColInsert($aPIDs,1) $aPIDs[0][1] = "Process Name" For $iX = 1 To UBound($aPIDs)-1 $aPIDs[$iX][1] = _ProcessGetName($aPIDs[$iX][0]) Next ;Add Process Names to NetStat Array _ArrayColInsert($aNetStatData,5) $aNetStatData[0][5] = "Process Name" For $iX = 1 to UBound($aNetStatData)-1 Local $sProcessName = $aPIDs[_ArraySearch($aPIDs, $aNetStatData[$iX][4])][1] If $sProcessName Then $aNetStatData[$iX][5] = $sProcessName Next EndFunc Func _RunCMD($sCMD) ;Run CMD and Return StdOut Local $iPID = Run(@ComSpec & " /c " & $sCMD, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $sStdOut While 1 $sStdOut &= StdoutRead($iPID) If @error Then ExitLoop WEnd Return $sStdOut EndFunc
    1 point
  2. If you want the image stretched then try this: #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1, $hImage, $hGraphic, $iW, $iH, $iW_Prev, $iH_Prev, $PicPreview, $ButtonPreview, $iW_New, $iH_New, $iPrev_Min, $hBitmap_Prev, $hBitmapGDI_Prev _GDIPlus_StartUp() $hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("https://www.autoitscript.com/images/favicon/favicon-180x180.png")) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $iW_Prev = 572 $iH_Prev = 268 $Form1 = GUICreate("Form1", 615, 438, 374, 347) $PicPreview = GUICtrlCreatePic("", 24, 152, $iW_Prev, $iH_Prev) $ButtonPreview = GUICtrlCreateButton("Preview", 520, 112, 75, 25) GUISetState(@SW_SHOW) $hBitmap_Prev = _GDIPlus_ImageResize($hImage, $iW_Prev, $iH_Prev, 6) $hBitmapGDI_Prev = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Prev) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hImage) _GDIPlus_ImageDispose($hBitmap_Prev) _WinAPI_DeleteObject($hBitmapGDI_Prev) _GDIPlus_ShutDown() Exit Case $ButtonPreview _WinAPI_DeleteObject(GUICtrlSendMsg($PicPreview, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmapGDI_Prev)) EndSwitch WEnd
    1 point
  3. Merry Christmas to you too. Jos
    1 point
  4. Look at IUIAutomation thread in the examples forum, specifically FAQ #31
    1 point
  5. This works fine on my system winclose("[CLASS:Chrome_WidgetWin_1]") Closing it with iuiautomation stuff you just have to click the closing button right top of window or click 1 by 1 if you want to do it per tab no special things on that observed. Protected/fixed tabs you can only close with ctrl+w
    1 point
  6. Gianni

    AUTOIT BASICS

    Here is one by @Jfish
    1 point
  7. Please provide an example of the data to compare.
    1 point
×
×
  • Create New...