Jump to content

context menu on button array not showing up


Recommended Posts

Not sure $PC_Btns should work! dunno why it isnt.

Func CreateIcons()
    $LOCS = IniReadSection($ini, "LOCATIONS")
    For $i = 1 To $LOCS[0][0]
        $PC_Btns = IniReadSection($ini, $LOCS[$i][1])
        For $x = 1 To $PC_Btns[0][0]
            $ButCount += 1
            $ButHor += 1
            If $ButHor * $horPitch + $ButWid + $startX > $maxX Then
                $ButHor = 0
                $ButVert += 1
                If $ButVert * $VertPItch + $ButHeight + $StartY > $maxY Then Return -1;can't fit any more
            EndIf
            GUICtrlCreateButton($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch, $ButWid, $ButHeight, $BS_ICON)
            GUICtrlSetImage(-1, "shell32.dll", 16)
            GUICtrlCreateLabel($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch + $ButHeight + 6)
            GUICtrlSetOnEvent($PC_Btns, $PC_Btns[$x][0])

                    $Btn_context = GUICtrlCreateContextMenu($PC_Btns)
    $Btn_context_item = GUICtrlCreateMenuItem("Take Remote Screenshot", $Btn_context)
    GUICtrlSetOnEvent(-1,"About")
                        
    $Checkers_menu = GUICtrlCreateMenu("Checkers", $Btn_context)
    $Checkers_menu_item = GUICtrlCreateMenuItem("Bloomberg Info", $Checkers_menu)
    GUICtrlSetOnEvent(-1,"Change")
    Next
    Next
EndFunc
Edited by gcue
Link to comment
Share on other sites

Not sure $PC_Btns should work! dunno why it isnt.

Func CreateIcons()
    $LOCS = IniReadSection($ini, "LOCATIONS")
    For $i = 1 To $LOCS[0][0]
        $PC_Btns = IniReadSection($ini, $LOCS[$i][1])
        For $x = 1 To $PC_Btns[0][0]
            $ButCount += 1
            $ButHor += 1
            If $ButHor * $horPitch + $ButWid + $startX > $maxX Then
                $ButHor = 0
                $ButVert += 1
                If $ButVert * $VertPItch + $ButHeight + $StartY > $maxY Then Return -1;can't fit any more
            EndIf
            GUICtrlCreateButton($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch, $ButWid, $ButHeight, $BS_ICON)
            GUICtrlSetImage(-1, "shell32.dll", 16)
            GUICtrlCreateLabel($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch + $ButHeight + 6)
            GUICtrlSetOnEvent($PC_Btns, $PC_Btns[$x][0])

                    $Btn_context = GUICtrlCreateContextMenu($PC_Btns)
    $Btn_context_item = GUICtrlCreateMenuItem("Take Remote Screenshot", $Btn_context)
    GUICtrlSetOnEvent(-1,"About")
                        
    $Checkers_menu = GUICtrlCreateMenu("Checkers", $Btn_context)
    $Checkers_menu_item = GUICtrlCreateMenuItem("Bloomberg Info", $Checkers_menu)
    GUICtrlSetOnEvent(-1,"Change")
    Next
    Next
EndFunc

Can you supply a script we can run to test? (Code looks strangely familiar.)

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.
Link to comment
Share on other sites

martin!!

hehe yep its what u wrote.. slightly modified of course ;-)

what's not working:

-context menus not coming up for buttons

-if i add more PCs to the ini file i get an error "unknown funciton name"

here's the script in its entirety

thank you for your help!

Opt("GUIOnEventMode", 1)

#include <GUIConstants.au3>

#Include <Constants.au3>

#include <file.au3>

$toolsdir="C:\CRS\Tools"

If Not FileExists($toolsdir) Then

DirCreate($toolsdir)

EndIf

If Not FileExists($toolsdir & "\Dashboard") Then

DirCreate($toolsdir & "\Dashboard")

EndIf

Global $Ini = $toolsdir & "\Dashboard\settings.ini"

If Not FileExists($Ini) Then

MsgBox(262144, "Dashboard", "Settings.ini is missing. A generic one has been created for you.")

IniWrite($Ini, "LOCATIONS", "CRMC","CRMC_ASSETS")

IniWrite($Ini, "LOCATIONS", "GIG","GIG_ASSETS")

IniWrite($Ini, "LOCATIONS", "DR","DR_ASSETS")

_FileWriteToLine($Ini, 5, "", 0)

IniWrite($Ini, "CRMC_ASSETS", "ANDS_ETP","D0090774")

_FileWriteToLine($Ini, 9, "", 0)

IniWrite($Ini, "GIG_ASSETS", "ANDS_ESRV","D0090775")

_FileWriteToLine($Ini, 13, "", 0)

IniWrite($Ini, "DR_ASSETS", "DLG_ETP","D0049852")

ShellExecute($Ini)

EndIf

GUICreate("Dashboard v0.1", 500, 430)

GUISetBkColor (0xffffff)

$filemenu = GUICtrlCreateMenu("&File")

$fileopenitem = GUICtrlCreateMenuItem("Edit Asset List", $filemenu)

GUICtrlSetOnEvent(-1,"EditINI")

$fileexititem = GUICtrlCreateMenuItem("Exit", $filemenu)

GUICtrlSetOnEvent(-1,"Xbutton")

$helpmenu = GUICtrlCreateMenu ("&Help")

$changeitem = GUICtrlCreateMenuitem ("Change Log",$helpmenu)

GUICtrlSetOnEvent(-1,"Change")

$helpitem = GUICtrlCreateMenuitem ("About",$helpmenu)

GUICtrlSetOnEvent(-1,"About")

$contextmenu = GUICtrlCreateContextMenu ()

$combo = GUICtrlCreateCombo("Select Location...", 290, 5, 200, 20, $CBS_DROPDOWNLIST)

GUICtrlSetData(-1, LoadCombo(), "Location...")

Func LoadCombo()

Local $arr = IniReadSection($Ini, "LOCATIONS"), $Local

If Not @error Then

For $i = 1 To $arr[0][0]

$Local &= $arr[$i][0] & "|"

Next

Return StringTrimRight($Local, 1)

EndIf

Return "No assets loaded"

EndFunc

$ButHeight = 40

$ButWid = 40

$horPitch = $ButWid + 70

$horPitch = $ButWid + 70

$VertPItch = $ButHeight + 10

$maxX = 500;depends on your window size or whatever

$maxY = 300;ditto

$startX = 20

$StartY = 10

$ButCount = 0;no buttons yet

$ButHor = 4

$ButVert = 0

CreateIcons()

Func CreateIcons()

$LOCS = IniReadSection($ini, "LOCATIONS")

For $i = 1 To $LOCS[0][0]

$PC_Btns = IniReadSection($ini, $LOCS[$i][1])

For $x = 1 To $PC_Btns[0][0]

$ButCount += 1

$ButHor += 1

If $ButHor * $horPitch + $ButWid + $startX > $maxX Then

$ButHor = 0

$ButVert += 1

If $ButVert * $VertPItch + $ButHeight + $StartY > $maxY Then Return -1;can't fit any more

EndIf

GUICtrlCreateButton($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch, $ButWid, $ButHeight, $BS_ICON)

GUICtrlSetImage(-1, "shell32.dll", 16)

GUICtrlCreateLabel($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch + $ButHeight + 6)

GUICtrlSetOnEvent($PC_Btns, $PC_Btns[$x][0])

$Btn_context = GUICtrlCreateContextMenu($PC_Btns)

$Btn_context_item = GUICtrlCreateMenuItem("Take Remote Screenshot", $Btn_context)

GUICtrlSetOnEvent(-1,"About")

$Btn_context_item = GUICtrlCreateMenuItem("Get ETP Logs", $Btn_context)

GUICtrlSetOnEvent(-1,"Xbutton")

$Btn_context_item = GUICtrlCreateMenuItem("Manage", $Btn_context)

GUICtrlSetOnEvent(-1,"Xbutton")

$Btn_context_item = GUICtrlCreateMenuItem("Netsupport", $Btn_context)

GUICtrlSetOnEvent(-1,"Xbutton")

$Btn_context_item = GUICtrlCreateMenuItem("Kill Process", $Btn_context)

GUICtrlSetOnEvent(-1,"Xbutton")

$Checkers_menu = GUICtrlCreateMenu("Checkers", $Btn_context)

$Checkers_menu_item = GUICtrlCreateMenuItem("Bloomberg Info", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Reuters Info", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Novell Broadcast Setting", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Exclusion Variable", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Active Processes", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Encryption Status", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("MAC and HD Serial", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Uptime", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Security", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

Next

Next

EndFunc

;$Btn = GUICtrlCreateButton ("ANDS ETP", 20,40,40,40, $BS_ICON)

;GUICtrlSetImage (-1, "shell32.dll",16)

;GUICtrlCreateLabel("ANDS_ETP", 5, 80)

;GUICtrlSetOnEvent($Btn, "ANDS_ETP")

;========== begin window context menu =============

$file_window_context_menu = GUICtrlCreateMenu("File",$contextmenu)

$file_window_context_menu_item = GUICtrlCreateMenuItem("Edit Asset List", $file_window_context_menu)

GUICtrlSetOnEvent(-1,"EditINI")

$file_window_context_menu_item = GUICtrlCreateMenuItem("Exit", $file_window_context_menu)

GUICtrlSetOnEvent(-1,"Xbutton")

$checkers_window_context_menu = GUICtrlCreateMenu("<Location> Checkers",$contextmenu)

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Bloomberg", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Reuters", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"About")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Novell Broadcast Setting", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Exclusion Variable", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Active Processes", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Encryption Status", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("MAC and HD Serial", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Uptime", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Security", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

;========== end window context menu =============

GUICtrlCreateLabel("STATUS:", 5, 360)

GUICtrlCreateLabel("Idle. ", 5, 380)

GUICtrlSetFont (-1,7, 600)

GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton")

GUISetState ()

While 1

sleep(10)

Wend

Func ANDS_ETP()

$asset = "d0090774"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

GUICtrlCreateLabel("Opening " & $asset & " ", 5, 380)

GUICtrlSetFont (-1,7, 600)

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

GUICtrlCreateLabel("Idle. ", 5, 380)

GUICtrlSetFont (-1,7, 600)

EndIf

EndFunc

Func ANDS_ESRV()

$asset = "d0090775"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func DLG_ETP()

$asset = "d0049852"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func DLG_ESRV()

$asset = "d0075934"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func JASB_ETP()

$asset = "d0058259"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func JASB_ESRV()

$asset = "d0069669"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func JSR_ETP()

$asset = "d0056849"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func JSR_ESRV()

$asset = "d0100554"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func JEEG_ETP()

$asset = "d0058258"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func JEEG_ESRV()

$asset = "d0098509"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func JEM_ETP()

$asset = "d0078011"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func NFB_ETP()

$asset = "d0091117"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func MADL_LTP()

$asset = "l0095110"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func MADL_DTP()

$asset = "d0057968"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func TEST_PC()

$asset = "d0049855"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func PATCH_PC()

$asset = "d0058256"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func CWI_GU()

$asset = "d0079214"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func CRGI_GU()

$asset = "d0095765"

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

EndIf

EndFunc

Func EditINI()

ShellExecuteWait($Ini)

GUICTrlSetdata($combo,"")

GUICTrlSetdata($combo, "Select Asset...|" & LoadCombo(), "Select Asset...")

EndFunc

Func Change()

MsgBox(262144, "Dashboard v0.1", 'Change Log'&@CRLF & _

''&@CRLF & _

'No Changes'&@CRLF & _

''&@CRLF & _

'Please contact GXM x90760 for suggestions or bug reports.')

EndFunc

Func About()

MsgBox(64, "About", 'Dashboard v0.1'&@CRLF & _

''&@CRLF & _

'Launchpad for '&@CRLF & _

''&@CRLF & _

'1.'&@CRLF & _

'2.'&@CRLF & _

'3. '&@CRLF & _

'4.'&@CRLF & _

''&@CRLF & _

'Contact GXM x90760 for questions/suggestions.')

EndFunc

Func Xbutton()

Exit

EndFunc

Can you supply a script we can run to test? (Code looks strangely familiar.)

Link to comment
Share on other sites

martin!!

hehe yep its what u wrote.. slightly modified of course ;-)

what's not working:

-context menus not coming up for buttons

-if i add more PCs to the ini file i get an error "unknown funciton name"

here's the script in its entirety

thank you for your help!

This fixes the context menu. Partly my fault becaus in the code I gave you I removed the variable reference used for the dynamically created buttons because I couldn't see what it was used for.

Func CreateIcons()
    $LOCS = IniReadSection($Ini, "LOCATIONS")
    For $i = 1 To $LOCS[0][0]
        $PC_Btns = IniReadSection($Ini, $LOCS[$i][1])
        For $x = 1 To $PC_Btns[0][0]
            $ButCount += 1
            $ButHor += 1
            If $ButHor * $horPitch + $ButWid + $startX > $maxX Then
                $ButHor = 0
                $ButVert += 1
                If $ButVert * $VertPItch + $ButHeight + $StartY > $maxY Then Return -1;can't fit any more
            EndIf
            $buttemp = GUICtrlCreateButton($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch, $ButWid, $ButHeight, $BS_ICON)
            GUICtrlSetImage(-1, "shell32.dll", 16)
            GUICtrlCreateLabel($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch + $ButHeight + 6)
            GUICtrlSetOnEvent($buttemp, $PC_Btns[$x][0])

            $Btn_context = GUICtrlCreateContextMenu($buttemp)
            $Btn_context_item = GUICtrlCreateMenuItem("Take Remote Screenshot", $Btn_context)
            GUICtrlSetOnEvent(-1, "About")
            $Btn_context_item = GUICtrlCreateMenuItem("Get ETP Logs", $Btn_context)
            GUICtrlSetOnEvent(-1, "Xbutton")
            $Btn_context_item = GUICtrlCreateMenuItem("Manage", $Btn_context)
            GUICtrlSetOnEvent(-1, "Xbutton")
            $Btn_context_item = GUICtrlCreateMenuItem("Netsupport", $Btn_context)
            GUICtrlSetOnEvent(-1, "Xbutton")
            $Btn_context_item = GUICtrlCreateMenuItem("Kill Process", $Btn_context)
            GUICtrlSetOnEvent(-1, "Xbutton")

            $Checkers_menu = GUICtrlCreateMenu("Checkers", $Btn_context)
            $Checkers_menu_item = GUICtrlCreateMenuItem("Bloomberg Info", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Reuters Info", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Novell Broadcast Setting", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Exclusion Variable", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Active Processes", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Encryption Status", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("MAC and HD Serial", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Uptime", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Security", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
        Next
    Next
EndFunc ;==>CreateIcons

The ini file refers to the function to be called so if you add another PC with a new function then you have to first have that function in your script.

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.
Link to comment
Share on other sites

you were right- that worked like a charm

as you can imagine, im going to try to run several functions against each of the PC items.

there are several functions i will be implementing to this.. as in the example you've already seen, i had to create a function for every button

to do one action

i would have to set one of variables global right? i tried it on a few places and couldnt get it working.

the assets shouldnt have to be hardcoded into the script itself (which defeats the purpose of the ini).. there's gotta be an easier way. any ideas?

Edited by gcue
Link to comment
Share on other sites

you were right- that worked like a charm

as you can imagine, im going to try to run several functions against each of the PC items.

there are several functions i will be implementing to this.. as in the example you've already seen, i had to create a function for every button

to do one action

i would have to set one of variables global right? i tried it on a few places and couldnt get it working.

the assets shouldnt have to be hardcoded into the script itself (which defeats the purpose of the ini).. there's gotta be an easier way. any ideas?

You only need to have one function for everyone.

Change the create icons fn to this

Func CreateIcons()
    Global $iplist[20];<---------added
    $LOCS = IniReadSection($Ini, "LOCATIONS")
    For $i = 1 To $LOCS[0][0]
        $PC_Btns = IniReadSection($Ini, $LOCS[$i][1])
        For $x = 1 To $PC_Btns[0][0]
            $ButCount += 1
            
            $ButHor += 1
            If $ButHor * $horPitch + $ButWid + $startX > $maxX Then
                $ButHor = 0
                $ButVert += 1
                If $ButVert * $VertPItch + $ButHeight + $StartY > $maxY Then Return -1;can't fit any more
            EndIf
            $buttemp = GUICtrlCreateButton($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch, $ButWid, $ButHeight, $BS_ICON)
            GUICtrlSetImage(-1, "shell32.dll", 16)
            GUICtrlCreateLabel($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch + $ButHeight + 6)
            GUICtrlSetOnEvent($buttemp, "mgfunc");$PC_Btns[$x][0]);<-----------changed
            If UBound($iplist) < $buttemp Then ReDim $iplist[$buttemp + 5];<-----added
            $iplist[$buttemp] = $PC_Btns[$x][1];save the address<-----------------added

            $Btn_context = GUICtrlCreateContextMenu($buttemp)
            $Btn_context_item = GUICtrlCreateMenuItem("Take Remote Screenshot", $Btn_context)
            GUICtrlSetOnEvent(-1, "About")
            $Btn_context_item = GUICtrlCreateMenuItem("Get ETP Logs", $Btn_context)
            GUICtrlSetOnEvent(-1, "Xbutton")
            $Btn_context_item = GUICtrlCreateMenuItem("Manage", $Btn_context)
            GUICtrlSetOnEvent(-1, "Xbutton")
            $Btn_context_item = GUICtrlCreateMenuItem("Netsupport", $Btn_context)
            GUICtrlSetOnEvent(-1, "Xbutton")
            $Btn_context_item = GUICtrlCreateMenuItem("Kill Process", $Btn_context)
            GUICtrlSetOnEvent(-1, "Xbutton")

            $Checkers_menu = GUICtrlCreateMenu("Checkers", $Btn_context)
            $Checkers_menu_item = GUICtrlCreateMenuItem("Bloomberg Info", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Reuters Info", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Novell Broadcast Setting", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Exclusion Variable", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Active Processes", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Encryption Status", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("MAC and HD Serial", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Uptime", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Security", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
        Next
    Next
EndFunc  ;==>CreateIcons

Then there is only one function for anyone-

Func mgfunc()
    $asset = $iplist[@GUI_CtrlId]
;ConsoleWrite($asset & @CRLF)
    Ping($asset)
    If @error Then
        MsgBox(0, "Dashboard", $asset & " is offline.")
    Else
        GUICtrlCreateLabel("Opening " & $asset & " ", 5, 380)
        GUICtrlSetFont(-1, 7, 600)
        Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")
        GUICtrlCreateLabel("Idle. ", 5, 380)
        GUICtrlSetFont(-1, 7, 600)
    EndIf
EndFunc  ;==>mgfunc

The way I did it is a bit inefficient because not every element of the array $iplist will be used, but it will work and it gives the idea. Better would be to have the array as 2 dimensions with 2 elements for each button. The first element could be the control iD, the second to address. Then in the mgfunc you would have to loop through the elements until you found @GUI_CtrlId. Simpler to leave it as I did it I suppose.

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.
Link to comment
Share on other sites

works great!!

by the same logic, this should work (but its not - it doesnt even try to run compmgmt.msc - it fails the ping and doesnt report the asset in the msgbox)

Func Manage()

$asset = $iplist[@GUI_CtrlId]

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

GUICtrlCreateLabel("Opening " & $asset & " ", 5, 380)

GUICtrlSetFont(-1, 7, 600)

Run(@ComSpec & " /c compmgmt.msc /computer=" & $asset)

GUICtrlCreateLabel("Idle. ", 5, 380)

GUICtrlSetFont(-1, 7, 600)

EndIf

EndFunc ;==>Manage

Link to comment
Share on other sites

works great!!

by the same logic, this should work (but its not - it doesnt even try to run compmgmt.msc - it fails the ping and doesnt report the asset in the msgbox)

Can't tell you without more information. @Gui_CtrlId is the id of the control that caused the event that called the function. If the function was called some other way the who knows what will happen? @Gui_CtrlId is only valid in an event function as the manual tells you.

If Func Manage() is just a replacement for mgfunc() (sorry about my vanity BTW, being inventive saps my brain) then it should work.

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.
Link to comment
Share on other sites

actually manage is a whole seperate function.

heres teh script again in its entirety

im going to keep adding functions.. i still dont understand why the reference to $assets is different

thanks again for all your help martin! =)

Opt("GUIOnEventMode", 1)

#include <GUIConstants.au3>

#Include <Constants.au3>

#include <file.au3>

$toolsdir="C:\CRS\Tools"

If Not FileExists($toolsdir) Then

DirCreate($toolsdir)

EndIf

If Not FileExists($toolsdir & "\Dashboard") Then

DirCreate($toolsdir & "\Dashboard")

EndIf

Global $Ini = $toolsdir & "\Dashboard\settings.ini"

If Not FileExists($Ini) Then

MsgBox(262144, "Dashboard", "Settings.ini is missing. A generic one has been created for you.")

IniWrite($Ini, "LOCATIONS", "CRMC","CRMC_ASSETS")

IniWrite($Ini, "LOCATIONS", "GIG","GIG_ASSETS")

IniWrite($Ini, "LOCATIONS", "DR","DR_ASSETS")

_FileWriteToLine($Ini, 5, "", 0)

IniWrite($Ini, "CRMC_ASSETS", "ANDS_ETP","D0090774")

_FileWriteToLine($Ini, 9, "", 0)

IniWrite($Ini, "GIG_ASSETS", "ANDS_ESR","D0090775")

_FileWriteToLine($Ini, 13, "", 0)

IniWrite($Ini, "DR_ASSETS", "DLG_ETP","D0049852")

ShellExecute($Ini)

EndIf

GUICreate("Dashboard v0.1", 520, 430)

GUISetBkColor (0xffffff)

$filemenu = GUICtrlCreateMenu("&File")

$fileopenitem = GUICtrlCreateMenuItem("Edit Asset List", $filemenu)

GUICtrlSetOnEvent(-1,"EditINI")

$fileexititem = GUICtrlCreateMenuItem("Exit", $filemenu)

GUICtrlSetOnEvent(-1,"Xbutton")

$helpmenu = GUICtrlCreateMenu ("&Help")

$changeitem = GUICtrlCreateMenuitem ("Change Log",$helpmenu)

GUICtrlSetOnEvent(-1,"Change")

$helpitem = GUICtrlCreateMenuitem ("About",$helpmenu)

GUICtrlSetOnEvent(-1,"About")

$contextmenu = GUICtrlCreateContextMenu ()

$combo = GUICtrlCreateCombo("Select Location...", 290, 5, 200, 20, $CBS_DROPDOWNLIST)

GUICtrlSetData(-1, LoadCombo(), "Location...")

Func LoadCombo()

Local $arr = IniReadSection($Ini, "LOCATIONS"), $Local

If Not @error Then

For $i = 1 To $arr[0][0]

$Local &= $arr[$i][0] & "|"

Next

Return StringTrimRight($Local, 1)

EndIf

Return "No assets loaded"

EndFunc ;==>LoadCombo

$ButHeight = 40

$ButWid = 40

$horPitch = $ButWid + 45

$horPitch = $ButWid + 45

$VertPItch = $ButHeight + 30

$maxX = 470;depends on your window size or whatever

$maxY = 380;ditto

$startX = 5

$StartY = 0

$ButCount = 0;no buttons yet

$ButHor = 6

$ButVert = 0

Func CreateIcons()

Global $iplist[20]

$LOCS = IniReadSection($ini, "LOCATIONS")

For $i = 1 To $LOCS[0][0]

$PC_Btns = IniReadSection($ini, $LOCS[$i][1])

For $x = 1 To $PC_Btns[0][0]

$ButCount += 1

$ButHor += 1

If $ButHor * $horPitch + $ButWid + $startX > $maxX Then

$ButHor = 0

$ButVert += 1

If $ButVert * $VertPItch + $ButHeight + $StartY > $maxY Then Return -1;can't fit any more

EndIf

$buttemp=GUICtrlCreateButton($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch, $ButWid, $ButHeight, $BS_ICON)

GUICtrlSetImage(-1, "shell32.dll", 16)

GUICtrlCreateLabel($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch + $ButHeight + 6)

GUICtrlSetOnEvent($buttemp, "UNC")

If UBound($iplist) < $buttemp Then ReDim $iplist[$buttemp + 5]

$iplist[$buttemp] = $PC_Btns[$x][1]

$Btn_context = GUICtrlCreateContextMenu($buttemp)

$Btn_context_item = GUICtrlCreateMenuItem("Take Remote Screenshot", $Btn_context)

GUICtrlSetOnEvent(-1,"About")

$Btn_context_item = GUICtrlCreateMenuItem("Manage", $Btn_context)

GUICtrlSetOnEvent(-1,"Manage")

$Btn_context_item = GUICtrlCreateMenuItem("Netsupport", $Btn_context)

GUICtrlSetOnEvent(-1,"Xbutton")

$Checkers_menu = GUICtrlCreateMenu("Checkers", $Btn_context)

$Checkers_menu_item = GUICtrlCreateMenuItem("Bloomberg Info", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Reuters Info", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Novell Broadcast Setting", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Exclusion Variable", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Active Processes", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Encryption Status", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("MAC and HD Serial", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Uptime", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$Checkers_menu_item = GUICtrlCreateMenuItem("Security", $Checkers_menu)

GUICtrlSetOnEvent(-1,"Change")

$get_menu = GUICtrlCreateMenu("Get Logs", $Btn_context)

$get_menu_item = GUICtrlCreateMenuItem("ETP", $get_menu)

GUICtrlSetOnEvent(-1,"Change")

$get_menu_item = GUICtrlCreateMenuItem("Channel", $get_menu)

GUICtrlSetOnEvent(-1,"Change")

$get_menu_item = GUICtrlCreateMenuItem("Liquidnet", $get_menu)

GUICtrlSetOnEvent(-1,"Change")

$get_menu_item = GUICtrlCreateMenuItem("LAVA", $get_menu)

GUICtrlSetOnEvent(-1,"Change")

$get_menu_item = GUICtrlCreateMenuItem("Pipeline", $get_menu)

GUICtrlSetOnEvent(-1,"Change")

Next

Next

EndFunc ;==>CreateIcons

CreateIcons()

;========== begin window context menu =============

$file_window_context_menu = GUICtrlCreateMenu("File",$contextmenu)

$file_window_context_menu_item = GUICtrlCreateMenuItem("Edit Asset List", $file_window_context_menu)

GUICtrlSetOnEvent(-1,"EditINI")

$file_window_context_menu_item = GUICtrlCreateMenuItem("Exit", $file_window_context_menu)

GUICtrlSetOnEvent(-1,"Xbutton")

$checkers_window_context_menu = GUICtrlCreateMenu("<Location> Checkers",$contextmenu)

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Bloomberg", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Reuters", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"About")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Novell Broadcast Setting", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Exclusion Variable", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Active Processes", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Encryption Status", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("MAC and HD Serial", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Uptime", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Security", $checkers_window_context_menu)

GUICtrlSetOnEvent(-1,"Change")

;========== end window context menu =============

GUICtrlCreateLabel("STATUS:", 5, 360)

GUICtrlCreateLabel("Idle. ", 5, 380)

GUICtrlSetFont (-1,7, 600)

GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton")

GUISetState ()

While 1

sleep(10)

Wend

Func UNC()

$asset = $iplist[@GUI_CtrlId]

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

GUICtrlCreateLabel("Opening " & $asset & " ", 5, 380)

GUICtrlSetFont(-1, 7, 600)

Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")

GUICtrlCreateLabel("Idle. ", 5, 380)

GUICtrlSetFont(-1, 7, 600)

EndIf

EndFunc ;==>UNC

Func Manage()

$asset = $iplist[@GUI_CtrlId]

Ping($asset)

If @error Then

MsgBox(0, "Dashboard", $asset & " is offline.")

Else

GUICtrlCreateLabel("Opening " & $asset & " ", 5, 380)

GUICtrlSetFont(-1, 7, 600)

Run(@ComSpec & " /c compmgmt.msc /computer=" & $asset)

GUICtrlCreateLabel("Idle. ", 5, 380)

GUICtrlSetFont(-1, 7, 600)

EndIf

EndFunc ;==>Manage

Func EditINI()

ShellExecuteWait($Ini)

GUICTrlSetdata($combo,"")

GUICTrlSetdata($combo, "Select Asset...|" & LoadCombo(), "Select Asset...")

EndFunc ;==>EditINI

Func Change()

MsgBox(262144, "Dashboard v0.1", 'Change Log'&@CRLF & _

''&@CRLF & _

'No Changes'&@CRLF & _

''&@CRLF & _

'Please contact GXM x90760 for suggestions or bug reports.')

EndFunc ;==>Change

Func About()

MsgBox(64, "About", 'Dashboard v0.1'&@CRLF & _

''&@CRLF & _

'Launchpad for '&@CRLF & _

''&@CRLF & _

'1.'&@CRLF & _

'2.'&@CRLF & _

'3. '&@CRLF & _

'4.'&@CRLF & _

''&@CRLF & _

'Contact GXM x90760 for questions/suggestions.')

EndFunc ;==>About

Func Xbutton()

Exit

EndFunc ;==>Xbutton

Can't tell you without more information. @Gui_CtrlId is the id of the control that caused the event that called the function. If the function was called some other way the who knows what will happen? @Gui_CtrlId is only valid in an event function as the manual tells you.

If Func Manage() is just a replacement for mgfunc() (sorry about my vanity BTW, being inventive saps my brain) then it should work.

Edited by gcue
Link to comment
Share on other sites

actually manage is a whole seperate function.

heres teh script again in its entirety

im going to keep adding functions.. i still dont understand why the reference to $assets is different

thanks again for all your help martin! =)

The control ID which calls the Manage function isn't the button so the value of @Gui_CtrlId won't give the correct info. You just have to repeat what I did for the button but for the context menu item.

You need to get an understanding of what's happening here so you can make these changes yourself and fix it when needed. (I get bored quickly :) )

My approach also needs a bit of a rethink. As I said in a previous post it works, but if the idea is going to be applied several, or even many, times then a neater solution is desirable rather than having arrays which are only partially used.

NOT TESTED AGAIN.

Opt("GUIOnEventMode", 1)
#include <GUIConstants.au3>
#include <Constants.au3>
#include <file.au3>

$toolsdir = "C:\CRS\Tools"

If Not FileExists($toolsdir) Then
    DirCreate($toolsdir)
EndIf

If Not FileExists($toolsdir & "\Dashboard") Then
    DirCreate($toolsdir & "\Dashboard")
EndIf

Global $Ini = $toolsdir & "\Dashboard\settings.ini"

If Not FileExists($Ini) Then
    MsgBox(262144, "Dashboard", "Settings.ini is missing. A generic one has been created for you.")
    IniWrite($Ini, "LOCATIONS", "CRMC", "CRMC_ASSETS")
    IniWrite($Ini, "LOCATIONS", "GIG", "GIG_ASSETS")
    IniWrite($Ini, "LOCATIONS", "DR", "DR_ASSETS")
    _FileWriteToLine($Ini, 5, "", 0)
    IniWrite($Ini, "CRMC_ASSETS", "ANDS_ETP", "D0090774")
    _FileWriteToLine($Ini, 9, "", 0)
    IniWrite($Ini, "GIG_ASSETS", "ANDS_ESR", "D0090775")
    _FileWriteToLine($Ini, 13, "", 0)
    IniWrite($Ini, "DR_ASSETS", "DLG_ETP", "D0049852")
    ShellExecute($Ini)
EndIf

GUICreate("Dashboard v0.1", 520, 430)
GUISetBkColor(0xffffff)

$filemenu = GUICtrlCreateMenu("&File")
$fileopenitem = GUICtrlCreateMenuItem("Edit Asset List", $filemenu)
GUICtrlSetOnEvent(-1, "EditINI")
$fileexititem = GUICtrlCreateMenuItem("Exit", $filemenu)
GUICtrlSetOnEvent(-1, "Xbutton")

$helpmenu = GUICtrlCreateMenu("&Help")
$changeitem = GUICtrlCreateMenuItem("Change Log", $helpmenu)
GUICtrlSetOnEvent(-1, "Change")
$helpitem = GUICtrlCreateMenuItem("About", $helpmenu)
GUICtrlSetOnEvent(-1, "About")

$contextmenu = GUICtrlCreateContextMenu()

$combo = GUICtrlCreateCombo("Select Location...", 290, 5, 200, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, LoadCombo(), "Location...")

Func LoadCombo()
    Local $arr = IniReadSection($Ini, "LOCATIONS"), $Local
    If Not @error Then
        For $i = 1 To $arr[0][0]
            $Local &= $arr[$i][0] & "|"
        Next
        Return StringTrimRight($Local, 1)
    EndIf
    Return "No assets loaded"
EndFunc  ;==>LoadCombo

$ButHeight = 40
$ButWid = 40
$horPitch = $ButWid + 45
$horPitch = $ButWid + 45
$VertPItch = $ButHeight + 30
$maxX = 470;depends on your window size or whatever
$maxY = 380;ditto
$startX = 5
$StartY = 0
$ButCount = 0;no buttons yet
$ButHor = 6
$ButVert = 0

Func CreateIcons()
    Global $iplist[20], $contexts[20]
    $LOCS = IniReadSection($Ini, "LOCATIONS")
    For $i = 1 To $LOCS[0][0]
        $PC_Btns = IniReadSection($Ini, $LOCS[$i][1])
        For $x = 1 To $PC_Btns[0][0]
            $ButCount += 1
            $ButHor += 1
            If $ButHor * $horPitch + $ButWid + $startX > $maxX Then
                $ButHor = 0
                $ButVert += 1
                If $ButVert * $VertPItch + $ButHeight + $StartY > $maxY Then Return -1;can't fit any more
            EndIf
            $buttemp = GUICtrlCreateButton($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch, $ButWid, $ButHeight, $BS_ICON)
            GUICtrlSetImage(-1, "shell32.dll", 16)
            GUICtrlCreateLabel($PC_Btns[$x][0], $startX + $ButHor * $horPitch, $StartY + $ButVert * $VertPItch + $ButHeight + 6)
            GUICtrlSetOnEvent($buttemp, "UNC")
            If UBound($iplist) < $buttemp Then
                ReDim $iplist[$buttemp + 5]
            EndIf
            $iplist[$buttemp] = $PC_Btns[$x]

            $Btn_context = GUICtrlCreateContextMenu($buttemp)
            
            $contexts[$Btn_context] = $PC_Btns[$x]
            $Btn_context_item = GUICtrlCreateMenuItem("Take Remote Screenshot", $Btn_context)
            GUICtrlSetOnEvent(-1, "About")
            $Btn_context_item = GUICtrlCreateMenuItem("Manage", $Btn_context)
            GUICtrlSetOnEvent(-1, "Manage")
            If UBound($contexts) < $Btn_context_item Then
                ReDim $contexts[$Btn_context_item + 5]
            EndIf
            $contexts[$Btn_context_item] = $PC_Btns[$x]
            
            $Btn_context_item = GUICtrlCreateMenuItem("Netsupport", $Btn_context)
            GUICtrlSetOnEvent(-1, "Xbutton")

            $Checkers_menu = GUICtrlCreateMenu("Checkers", $Btn_context)
            $Checkers_menu_item = GUICtrlCreateMenuItem("Bloomberg Info", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Reuters Info", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Novell Broadcast Setting", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Exclusion Variable", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Active Processes", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Encryption Status", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("MAC and HD Serial", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Uptime", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $Checkers_menu_item = GUICtrlCreateMenuItem("Security", $Checkers_menu)
            GUICtrlSetOnEvent(-1, "Change")

            $get_menu = GUICtrlCreateMenu("Get Logs", $Btn_context)
            $get_menu_item = GUICtrlCreateMenuItem("ETP", $get_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $get_menu_item = GUICtrlCreateMenuItem("Channel", $get_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $get_menu_item = GUICtrlCreateMenuItem("Liquidnet", $get_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $get_menu_item = GUICtrlCreateMenuItem("LAVA", $get_menu)
            GUICtrlSetOnEvent(-1, "Change")
            $get_menu_item = GUICtrlCreateMenuItem("Pipeline", $get_menu)
            GUICtrlSetOnEvent(-1, "Change")
        Next
    Next
EndFunc  ;==>CreateIcons

CreateIcons()

;========== begin window context menu =============

$file_window_context_menu = GUICtrlCreateMenu("File", $contextmenu)
$file_window_context_menu_item = GUICtrlCreateMenuItem("Edit Asset List", $file_window_context_menu)
GUICtrlSetOnEvent(-1, "EditINI")
$file_window_context_menu_item = GUICtrlCreateMenuItem("Exit", $file_window_context_menu)
GUICtrlSetOnEvent(-1, "Xbutton")

$checkers_window_context_menu = GUICtrlCreateMenu("<Location> Checkers", $contextmenu)
$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Bloomberg", $checkers_window_context_menu)
GUICtrlSetOnEvent(-1, "Change")
$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Reuters", $checkers_window_context_menu)
GUICtrlSetOnEvent(-1, "About")
$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Novell Broadcast Setting", $checkers_window_context_menu)
GUICtrlSetOnEvent(-1, "Change")
$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Exclusion Variable", $checkers_window_context_menu)
GUICtrlSetOnEvent(-1, "Change")
$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Active Processes", $checkers_window_context_menu)
GUICtrlSetOnEvent(-1, "Change")
$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Encryption Status", $checkers_window_context_menu)
GUICtrlSetOnEvent(-1, "Change")
$checkers_window_context_menu_item = GUICtrlCreateMenuItem("MAC and HD Serial", $checkers_window_context_menu)
GUICtrlSetOnEvent(-1, "Change")
$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Uptime", $checkers_window_context_menu)
GUICtrlSetOnEvent(-1, "Change")
$checkers_window_context_menu_item = GUICtrlCreateMenuItem("Security", $checkers_window_context_menu)
GUICtrlSetOnEvent(-1, "Change")

;========== end window context menu =============

GUICtrlCreateLabel("STATUS:", 5, 360)
GUICtrlCreateLabel("Idle. ", 5, 380)
GUICtrlSetFont(-1, 7, 600)

GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton")

GUISetState()

While 1
    Sleep(10)
WEnd

Func UNC()
    $asset = $iplist[@GUI_CtrlId][0]
    Ping($asset)
    If @error Then
        MsgBox(0, "Dashboard", $asset & " is offline.")
    Else
        GUICtrlCreateLabel("Opening " & $asset & " ", 5, 380)
        GUICtrlSetFont(-1, 7, 600)
        Run(@WindowsDir & "\explorer.exe " & "\\" & $asset & "\c$")
        GUICtrlCreateLabel("Idle. ", 5, 380)
        GUICtrlSetFont(-1, 7, 600)
    EndIf
EndFunc  ;==>UNC

Func Manage()
    $asset = $contexts[@GUI_CtrlId]
    Ping($asset)
    If @error Then
        MsgBox(0, "Dashboard", $asset & " is offline.")
    Else
        GUICtrlCreateLabel("Opening " & $asset & " ", 5, 380)
        GUICtrlSetFont(-1, 7, 600)
        Run(@ComSpec & " /c compmgmt.msc /computer=" & $asset)
        GUICtrlCreateLabel("Idle. ", 5, 380)
        GUICtrlSetFont(-1, 7, 600)
    EndIf
EndFunc  ;==>Manage


Func EditINI()
    ShellExecuteWait($Ini)
    GUICtrlSetData($combo, "")
    GUICtrlSetData($combo, "Select Asset...|" & LoadCombo(), "Select Asset...")
EndFunc  ;==>EditINI

Func Change()
    MsgBox(262144, "Dashboard v0.1", 'Change Log' & @CRLF & _
            '' & @CRLF & _
            'No Changes' & @CRLF & _
            '' & @CRLF & _
            'Please contact GXM x90760 for suggestions or bug reports.')
EndFunc  ;==>Change

Func About()
    MsgBox(64, "About", 'Dashboard v0.1' & @CRLF & _
            '' & @CRLF & _
            'Launchpad for ' & @CRLF & _
            '' & @CRLF & _
            '1.' & @CRLF & _
            '2.' & @CRLF & _
            '3. ' & @CRLF & _
            '4.' & @CRLF & _
            '' & @CRLF & _
            'Contact GXM x90760 for questions/suggestions.')
EndFunc  ;==>About

Func Xbutton()
    Exit
EndFunc  ;==>Xbutton
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.
Link to comment
Share on other sites

i got an array error.

"array variable has incorrect number of subscripts or subscript dimension range exceeded"

so everytime i add a new function im going to have to create a new array of some kind?

Link to comment
Share on other sites

Based on the previous ideas, and because of the difficulty of implementing them, I made OnEventFun.au3 UDF to make all this much easier.

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.
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...