Jump to content

Multiping Help.


mucitbey
 Share

Recommended Posts

Hi,

Can we see the ip information of the selected computer in the marked part of the picture?
Thank you.

#include <Array.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include 'MultiPing.au3'

Opt("GUIOnEventMode", 1)

Global $usText, $ipText
Global $Win_X = 910, $Win_Y = 500

HotKeySet("{ESC}", "_Close")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

$Gui = GUICreate("", $Win_X, $Win_Y, @DesktopWidth -$Win_X, @DesktopHeight -$Win_Y-40, $WS_POPUP)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close", $Gui)
GUISetBkColor(0x000000)

$listview = GUICtrlCreateListView($Gui, 5, 5, $Win_X - 10, $Win_Y - 60)
GUICtrlSetFont(-1, 10, 800, 0, "Arial Narrow")
GUICtrlSetStyle(-1, $LVS_ICON)
GUICtrlSetBkColor(-1, $COLOR_SILVER)
$LH = GUICtrlGetHandle($listview)

$hImage = _GUIImageList_Create(45, 10)
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 45, 10)) ; Yellow
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 45, 10)) ; Red
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 45, 10)) ; Green
_GUICtrlListView_SetImageList($listview, $hImage, 0)

$button1 = GUICtrlCreateButton("E X I T", 400, $Win_Y - 40, $Win_X - 800, 30)
GUICtrlSetTip(-1, " Program Closed ")
GUICtrlSetOnEvent(-1, "_Close")
GUICtrlSetFont(-1, 22, 800, 0, "Arial Narrow")


Global $Infou = GUICtrlCreateLabel("", 5, $Win_Y - 50, 150, 20)
GUICtrlSetFont(-1, 12, 800, 0, "Arial Narrow")
GUICtrlSetBkColor(-1, $COLOR_SILVER)
GUICtrlSetTip(-1, "Selected PC Name")

Global $Infop = GUICtrlCreateLabel("", 5, $Win_Y - 25, 150, 20)
GUICtrlSetFont(-1, 12, 800, 0, "Arial Narrow")
GUICtrlSetBkColor(-1, $COLOR_SILVER)
GUICtrlSetTip(-1, "Selected PC IP")

GUISetState(@SW_SHOW)

$IPlist = _FileReadToArray_mod("TestList.txt")

_GUICtrlListView_BeginUpdate($listview)
_GUICtrlListView_AddArray($listview, $IPlist)
_GUICtrlListView_EndUpdate($listview)

While 1
    Sleep(10)
    $fResult = _nPing($IPlist, 1, 0, 0, "_refresh")
WEnd

Func _Refresh($Params)
    _GUICtrlListView_SetItemImage($listview, $Params[5], 0)
    Sleep(40)
    If $Params[4] = -1 Then
        _GUICtrlListView_SetItemImage($listview, $Params[5], 1)
        _GUICtrlListView_EnsureVisible($listview, $Params[5])
    Else
        _GUICtrlListView_SetItemImage($listview, $Params[5], 2)
    EndIf
EndFunc

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    If Not IsHWnd($listview) Then $hWndListView = GUICtrlGetHandle($listview)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_CLICK
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $usText = _GUICtrlListView_GetItemText($hWndListView, DllStructGetData($tInfo, "Index"))
                    $ipText = _GUICtrlListView_GetItemText($hWndListView, DllStructGetData($tInfo, "Index"))
                    GUICtrlSetData($Infou, $usText)
                    GUICtrlSetData($Infop, $ipText) ; <-- i couldn't do this part (to have a running code)

                Case $NM_RCLICK
                    MsgBox(0,"$NM_RCLICK", "Right Click")
                    ;_PcClose()

                Case $NM_DBLCLK
                    MsgBox(0,"$NM_DBLCLK", "Double Left Click")

            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func _PcClose()
    MsgBox(0, "TEST", $usText &@CRLF& $ipText)
EndFunc

Func _Close()
    Exit
EndFunc

image.png.2d2ab7f03d6989fddc44389fd0f34b3b.png

Link to comment
Share on other sites

Hard to say since you didn't make a runable script.  Mostly it will depends on $IPlist array structure.  But it is clearly doable in some way.  Make a true runable script that we can test on our own, we will find you a solution for sure.

Link to comment
Share on other sites

Quote

Computer_01;192.168.160.1
Computer_02;192.168.160.2
Computer_03;192.168.160.3
Computer_04;192.168.160.4
Computer_05;192.168.160.5
Computer_06;192.168.160.6
Computer_07;192.168.160.7
Computer_08;192.168.160.8
Computer_09;192.168.160.9
Computer_10;192.168.160.10

TestList.txt

I'm sorry I forgot to share the txt file instance.

Link to comment
Share on other sites

      Hello again,
     Clicking on the empty space on the list (no object) gives the error below and terminates the GUI.
Is there anyone who has a solution to this issue?

$ipText = $IPlist[DllStructGetData($tInfo, "Index")][1]
$ipText = $IPlist[^ ERROR

Thanks in advance for the help.

Link to comment
Share on other sites

  • Developers

You forgot to show the actual error message, but assume it's something with subscripts&array meaning that the returned value of  DllStructGetData($tInfo, "Index") is no a correct one that exists in the array.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...