Sign in to follow this  
Followers 0
BigDaddyO

How to use GUICtrlSetImage from script A to modify script B?

5 posts in this topic

Hello all,

I have a tool simmilar to gafrosts Admin tool but when I looked at his I was very interested in the icons that specify online or offline. I wanted to put that into mine but since the computers I monitor do not log into a network I have to use Ping to see if the computers are on or off.

Well, I got everything working great. The script launches, and all the computers are pinged and depending upon the responce the Icons in the GUI will show the Online icon or the Offline icon.

Now for the Problem...

The only way I could figure out how to ping all the comptuers about every 3 - 5 seconds is to use the adlib command, which again worked fine only the GUI will sometimes lag until the adlib function has finished. So Now I am thinking I will write a seperate script to house the pinging commands and run it from the main script. Only I can't figure out how to set the images in the main GUI from this other script. I tried using the Handle of the icon item but that didn't work.

any ideas?

Thanks,

Mike


Share this post


Link to post
Share on other sites



hay mike

are you talking about two separate .exe's or just two gui's

phil

Share this post


Link to post
Share on other sites

Two seperate EXE's, The reason is because AutoIT can not perform multiple functions at the same time so I have to split them up into different EXE's

In the main EXE I plan on using the Adlib function every 5 seconds to call a function that will simply launch the other EXE using a RUN command.


Share this post


Link to post
Share on other sites

the first thing that comes to mind is writing to a .ini file, not practial for something thats going to change every 3 to 5 sec's. perhaps it would help me and other's to see an outline of your script, i'm learning also!

Share this post


Link to post
Share on other sites

OK,

Using the Windows Dock Method from gafrost I was able to make two executables. The main EXE which I modified only to launch the second exe on startup and to processclose the second exe on exit.

The Second exe is below. This will automatically dock it's self to the left side of the main EXE and run it's online offline function to graphically display if a comptuer is on or off.

The function sometimes slows down the docking feature but it always catchs up.

Mike

#NoTrayIcon
Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1
Dim $OptionsMenu1, $OptionsItem1,$OptionsItem2,$OptionsItem3,$OptionsItem4, $separator1
Dim $Online420 = 0, $Online510 = 0, $Online530 = 0, $Online5000 = 0, $Online5100 = 0, $Online280 = 0
#include <GuiConstants.au3>;Commands for creating and interacting with the GUI Interface
#include <ImageData.au3>;Stores the IP addressess of the test PC's
FileInstall(".\Include\Online.ico", @TempDir & "\Online.ico")
FileInstall(".\Include\Offline.ico", @TempDir & "\Offline.ico")
$online = @TempDir & "\Online.ico"
$offline = @TempDir & "\Offline.ico"

;===================================================================================================


$GUI2 = WinGetHandle("Test PC Info", "")
$StartPOS = WinGetPos($GUI2, "")
;===================================================================================================



$hidden = GUICreate("hidden", 10, 10, -1, -1)
$GUI1 = GUICreate("", 43, 373, $StartPOS[0] - 45, $StartPOS[1], $WS_POPUPWINDOW, -1, $hidden)
GUICtrlCreateLabel("Stats", 5, 35, 40, 20)
GUICtrlSetFont(-1, 10, 600)
$Icon420 = GUICtrlCreateIcon($offline, -1, 5, 65)
$Icon510 = GUICtrlCreateIcon($offline, -1, 5, 105)
$Icon530 = GUICtrlCreateIcon($offline, -1, 5, 145)
$Icon5000 = GUICtrlCreateIcon($offline, -1, 5, 185)
$Icon280 = GUICtrlCreateIcon($offline, -1,  5, 225)
$Icon5100 = GUICtrlCreateIcon($offline, -1, 5, 265)

GuiSetState()
_GetOnOffline()
AdlibEnable("_GetOnOffline", 2000)

;===================================================================================================



While 1
   If $Dock Then _KeepWindowsDocked()
   Sleep(10)
WEnd

Func _KeepWindowsDocked()
   $p_win1 = WinGetPos($GUI1)
   $p_win2 = WinGetPos($GUI2)
    If $Dock_Location == 1 Then
        If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1),8) Or $Dock = 2) Then
            $x1 = $p_win1[0]
            $y1 = $p_win1[1]
            $x2 = $p_win1[2] + $x1
            $y2 = $y1
            WinMove($GUI2, "", $x2, $y2)
            $Dock = 1
        ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2),8)) Then
            $x2 = $p_win2[0]
            $y2 = $p_win2[1]
            $x1 = $p_win2[0] - $p_win1[2]
            $y1 = $y2
            WinMove($GUI1, "", $x1, $y1)
        EndIf
    Else
        If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1),8) Or $Dock = 2) Then
            $x1 = $p_win1[0]
            $y1 = $p_win1[1]
            $x2 = $x1
            $y2 = $p_win1[3] + $y1
            WinMove($GUI2, "", $x2, $y2)
            $Dock = 1
        ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2),8)) Then
            $x2 = $p_win2[0]
            $y2 = $p_win2[1]
            $x1 = $x2
            $y1 = $p_win2[1] - $p_win1[3]
            WinMove($GUI1, "", $x1, $y1)
        EndIf
    EndIf
EndFunc ;==>_KeepWindowsDocked


Func _GetOnOffline()
Ping($ipVL420, 5)
if not @error Then
    if $Online420 = 0 Then
        GUICtrlSetImage($Icon420, $online)
        $Online420 = 1
    EndIf
Else
    if $Online420 = 1 Then
        GUICtrlSetImage($Icon420, $offline)
        $Online420 = 0
    EndIf
EndIf
    
Ping($ipD510, 5)
if not @error Then
    if $Online510 = 0 Then
        GUICtrlSetImage($Icon510, $online)
        $Online510 = 1
    EndIf
Else
    if $Online510 = 1 Then
        GUICtrlSetImage($Icon510, $offline)
        $Online510 = 0
    EndIf
EndIf
    
Ping($ipD530, 5)
if not @error Then
    if $Online530 = 0 Then
        GUICtrlSetImage($Icon530, $online)
        $Online530 = 1
    EndIf
Else
    if $Online530 = 1 Then
        GUICtrlSetImage($Icon530, $offline)
        $Online530 = 0
    EndIf
EndIf
    
Ping($ipDC5000, 5)
if not @error Then
    if $Online5000 = 0 Then
        GUICtrlSetImage($Icon5000, $online)
        $Online5000 = 1
    EndIf
Else
    if $Online5000 = 1 Then
        GUICtrlSetImage($Icon5000, $offline)
        $Online5000 = 0
    EndIf
EndIf
    
Ping($ipGX280, 5)
if not @error Then
    if $Online280 = 0 Then
        GUICtrlSetImage($Icon280, $online)
        $Online280 = 1
    EndIf
Else
    if $Online280 = 1 Then
        GUICtrlSetImage($Icon280, $offline)
        $Online280 = 0
    EndIf
EndIf
    
Ping($ipDC5100, 5)
if not @error Then
    if $Online5100 = 0 Then
        GUICtrlSetImage($Icon5100, $online)
        $Online5100 = 1
    EndIf
Else
    if $Online5100 = 1 Then
        GUICtrlSetImage($Icon5100, $offline)
        $Online5100 = 0
    EndIf
EndIf
EndFunc;_GetOnOffline()

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