Sign in to follow this  
Followers 0
mod147

GUICtrlSetOnEvent contextmenu ID - Array

3 posts in this topic

Hi all,

i've made a little handy monitor-ping for our lan.

the script reads a ini file with name and ip of each computer and shows a GUI with name and online or offline status on each comp.<-- works fine

now i want to give each computername, witch is a lable in the GUI, a contextmenu with 3 items. <-- works fine to.

if i click on one of thies item i call a function, but in the function i dont now the Lables index i right clicked.

here a snipet

For $I = 1 To 30
        $comp = IniRead(@ScriptDir & "\Monitor_Kipszer.ini", $I, "Name", "")
        $IP_PING = IniRead(@ScriptDir & "\Monitor_Kipszer.ini", $I, "ip", "")
        $Lable[$I]= GUICtrlCreateLabel($comp, 24, $zeile, 73, 17)
            GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor(-1, 0xFFFFFF)
            $Menu[$I] = GUICtrlCreateContextMenu($Lable[$I]);context mneu for a lable
            $MenuItem1[$I] = GUICtrlCreateMenuitem("Explore c$", $Menu[$I]);for the context menu Item1 
            GUICtrlSetOnEvent(-1, "explorec")
            $MenuItem2[$I] = GUICtrlCreateMenuitem("Vnc-dolgoz", $Menu[$I]);for the context menu Item2
            GUICtrlSetOnEvent(-1, "vncdolgoz")
            $MenuItem3[$I] = GUICtrlCreateMenuitem("Vnc-néz", $Menu[$I]);for the context menu Item3
            GUICtrlSetOnEvent(-1, "vncnez")
            $pic[$I] = GUICtrlCreatePic(@ScriptDir&"\btnred.GIF", 120, $zeile, 16, 16, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
        $zeile += 20
    Next

i do not like to write for each lable 3 functions, need it shorter.

can someone give me a hint, pls

cheers zoltan

sorry for my bad english

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi all,

i've made a little handy monitor-ping for our lan.

the script reads a ini file with name and ip of each computer and shows a GUI with name and online or offline status on each comp.<-- works fine

now i want to give each computername, witch is a lable in the GUI, a contextmenu with 3 items. <-- works fine to.

if i click on one of thies item i call a function, but in the function i dont now the Lables index i right clicked.

here a snipet

For $I = 1 To 30
        $comp = IniRead(@ScriptDir & "\Monitor_Kipszer.ini", $I, "Name", "")
        $IP_PING = IniRead(@ScriptDir & "\Monitor_Kipszer.ini", $I, "ip", "")
        $Lable[$I]= GUICtrlCreateLabel($comp, 24, $zeile, 73, 17)
            GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
            GUICtrlSetColor(-1, 0xFFFFFF)
            $Menu[$I] = GUICtrlCreateContextMenu($Lable[$I]);context mneu for a lable
            $MenuItem1[$I] = GUICtrlCreateMenuitem("Explore c$", $Menu[$I]);for the context menu Item1 
            GUICtrlSetOnEvent(-1, "explorec")
            $MenuItem2[$I] = GUICtrlCreateMenuitem("Vnc-dolgoz", $Menu[$I]);for the context menu Item2
            GUICtrlSetOnEvent(-1, "vncdolgoz")
            $MenuItem3[$I] = GUICtrlCreateMenuitem("Vnc-néz", $Menu[$I]);for the context menu Item3
            GUICtrlSetOnEvent(-1, "vncnez")
            $pic[$I] = GUICtrlCreatePic(@ScriptDir&"\btnred.GIF", 120, $zeile, 16, 16, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
        $zeile += 20
    Next

i do not like to write for each lable 3 functions, need it shorter.

can someone give me a hint, pls

cheers zoltan

sorry for my bad english

Not tested but hopefully it helps

GUICtrlSetOnEvent(-1, "vncnez")

Func vncnez()
    Local $in, $group

    For $in = 1 To 30
        If $MenuItem3[$in] = @GUI_CtrlId Then
            $group = $in
            ExitLoop
        EndIf
    Next
    ConsoleWrite("the menu is for computer " & $label[$group] & @CRLF)

EndFunc ;==>vncnez
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Not tested but hopefully it helps

GUICtrlSetOnEvent(-1, "vncnez")

Func vncnez()
    Local $in, $group

    For $in = 1 To 30
        If $MenuItem3[$in] = @GUI_CtrlId Then
            $group = $in
            ExitLoop
        EndIf
    Next
    ConsoleWrite("the menu is for computer " & $label[$group] & @CRLF)

EndFunc;==>vncnez

Thank you, :D after i change it to:

Func vncnez()
    Local $in, $group

    For $in = 1 To 30
        If $MenuItem3[$in] = @GUI_CtrlId Then
          MsgBox(0,"IP,Name ",  $IP_PING[$In] & @CRLF & $comp[$in]) 
           ExitLoop
        EndIf
    Next

EndFunc;==>vncnez

i got what i want :D

thx for your hint

Share this post


Link to post
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
Sign in to follow this  
Followers 0