Jump to content

Refresh everything in the GUI


Chimaera
 Share

Recommended Posts

Been doing some searching for a refresh button but i need it to refresh everything in the gui

Im doing sort of a basic gui with a check sheet so that we can run it on a machine after work has finished to see what is left to do like 

does the internet work, can you hear audio, Is the machine activated  etc

There will be red crosses and green ticks and after something has been fixed i need to refresh it so the ticks change colour if a task is completed

I see there are bits about refreshing certain sections or buttons but i cant seem to find anything about refresh the whole gui

That is one example i found about refresh another suggestion was AdLibregister but that didnt seem quite what i wanted

So is there a simple way to refresh a Gui and everything in it ?

The gui only contains the functions to check internet etc etc and a few labels

Link to comment
Share on other sites

No, there's no simple  way to do that. You'd need to reset every control, label, etc. that's in/on the GUI individually.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Ok no problem i had a feeling that would be the case

I will have to tie the button to a function then run the checks one after another like the melba example i guess

Many thanks

Link to comment
Share on other sites

not sure if this will give desired effect, couldn't hurt to try.

_WinAPI_RedrawWindow ($GUI)
If @error Then
    MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!")
EndIf

"Yeah yeah yeah patience, how long will that take?"  -Ed Gruberman

REAL search results  |  SciTE4AutoIt3 Editor Full Version

Link to comment
Share on other sites

Quick example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example1()
Func Example1()
   $hGUI = GUICreate("Example1", 300, 200)

   ;    Create a Dummy and set it to the position of the $lblOne
   $dmyBegin = GUICtrlCreateDummy() + 1
   $lblOne = GUICtrlCreateLabel("Check Cable", 10, 10, 100, 20)
   $lblTwo = GUICtrlCreateLabel("Check Internet", 10, 30, 100, 20)
   $lblThree = GUICtrlCreateLabel("Restart computer", 10, 50, 100, 20)
   $dmyEnd = GUICtrlCreateDummy()
   ;    $dmyEnd is set to one past $lblThree
   ;    $currentLabel sets the position of which label to update. It starts at 1.
   $currentLabel = $dmyBegin
   $btnUpdate = GUICtrlCreateButton("Update", 10, 70, 50, 20)

   GUISetState(@SW_SHOW)
   While 1
      Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
         Exit
      Case $btnUpdate
         updateLabel($currentLabel, $dmyEnd)
      EndSwitch
   WEnd
EndFunc

;    Passing ByRef means it changes the variable in the updateLabel function and updates the variable in the Example1 function
Func updateLabel(ByRef $label, $end)
   ;    Check to make sure we haven't already updated everything
   If $label = $end Then
      MsgBox("","Error", "Every label is already updated!")
      Return
   ;    Update the next label
   Else
      GUICtrlSetColor($label, 0x00FF00)
      ;    Add 1 to the label so it updates the next one when we call the function again. You don't have to use ByRef, you could do $currentLabel += 1 in the Example1 function instead
      $label += 1
   EndIf
EndFunc

In short, $lblOne = 1, $lblTwo = 2, $lblThree = 3, and $dmyBegin = 1 (I started it at 0 but added 1 to it to set it to the first label)

Link to comment
Share on other sites

Thx for the suggestions ill have a look

@InunoTaishou

What im trying to do is have a button that will refresh all the parts of the gui everytime you press the button not one at a time.

So if i have a fault in device manager it shows a red cross on the gui so i go and fix the drivers that are faulty then press the refresh button and it will turn into a green tick as the problem has been resolved in device manager.

Its kinda like a running checklist for the tech to see whats wrong and left to do on a machine with a refresh button to recheck 

Link to comment
Share on other sites

I did a similare script ... my methode was clearly to refresh each thing one after one...

 

I used a $Scanrefresh100 variable, my sleep in the general script is 20 ms then i used after each command or function : $Debutscan100=99

After each while a

$Debutscan100= $Debutscan100 +1

and at the end of my script a scan section with alllllll the needed refresh command with a contition...

If

$Debutscan100= 100 then

endif

and at the end of the scan section a $Debutscan100= 0

So this logic help me to refresh all label without spam the process

Refresh label 1 etc....

If you need the exemple i post my script...

 

Check after this line

;=========================================Debut des scans===================================================










Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Chimaera please post a repo. If i have understand:

; Johnmcloud 2015
#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Example", 300, 200)

$dBegin = GUICtrlCreateDummy()
GUICtrlCreateLabel("Check Cable", 10, 10, 100, 20)
GUICtrlCreateLabel("Check Internet", 10, 30, 100, 20)
GUICtrlCreateLabel("Restart computer", 10, 50, 100, 20)
$dEnd = GUICtrlCreateDummy()

$bUpdate = GUICtrlCreateButton("Update", 10, 70, 50, 20)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $bUpdate
            _Update($dBegin, $dEnd)
    EndSwitch
WEnd

Func _Update($iStart, $iEnd)
    Local $iID
    For $iID = $iStart + 1 To $iEnd - 1
        ConsoleWrite("ID: " & $iID & " - " & GUICtrlRead($iID) & @CR)
        GUICtrlSetColor($iID, 0xFF0000)
;~      Switch GUICtrlRead($iID)
;~          Case "Check Cable"
;~              ;do this
;~          Case "Check Internet"
;~              ;do that
;~          Case "Restart computer"
;~              ;do this
;~      EndSwitch
    Next
EndFunc   ;==>_Update

An alternative to Dummy is use EnumChildWindows for get all control

Edited by johnmcloud
Link to comment
Share on other sites

Thx for the suggestions ill have a look

@InunoTaishou

What im trying to do is have a button that will refresh all the parts of the gui everytime you press the button not one at a time.

So if i have a fault in device manager it shows a red cross on the gui so i go and fix the drivers that are faulty then press the refresh button and it will turn into a green tick as the problem has been resolved in device manager.

Its kinda like a running checklist for the tech to see whats wrong and left to do on a machine with a refresh button to recheck 

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example1()
Func Example1()
   $hGUI = GUICreate("Example1", 300, 200)

   ;    Create a Dummy and set it to the position of the $lblOne
   $dmyBegin = GUICtrlCreateDummy() + 1
   $lblOne = GUICtrlCreateLabel("Check Cable", 10, 10, 100, 20)
   $lblTwo = GUICtrlCreateLabel("Check Internet", 10, 30, 100, 20)
   $lblThree = GUICtrlCreateLabel("Restart computer", 10, 50, 100, 20)
   $dmyEnd = GUICtrlCreateDummy()
   ;    $dmyEnd is set to one past $lblThree
   ;    $currentLabel sets the position of which label to update. It starts at 1.
   $currentLabel = $dmyBegin
   $btnUpdate = GUICtrlCreateButton("Update", 10, 70, 50, 20)
   $btnResetAll = GUICtrlCreateButton("Reset", 70, 70, 50, 20)

   GUISetState(@SW_SHOW)
   While 1
      Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
         Exit
      Case $btnUpdate
         updateLabel($currentLabel, $dmyEnd)
      Case $btnResetAll
         ;  Loop through every Ctrl and set them all to black
         For $i = $dmyBegin to $dmyEnd
            GUICtrlSetColor($i, 0x000000)
         Next
         ;  Set the currentLabel back to the beginning
         $currentLabel = $dmyBegin
      EndSwitch
   WEnd
EndFunc

;   Passing ByRef means it changes the variable in the updateLabel function and updates the variable in the Example1 function
Func updateLabel(ByRef $label, $end)
   ;    Check to make sure we haven't already updated everything
   If $label = $end Then
      MsgBox("","Error", "Every label is already updated!")
      Return
   ;    Update the next label
   Else
      GUICtrlSetColor($label, 0x00FF00)
      ; Add 1 to the label so it updates the next one when we call the function again. You don't have to use ByRef, you could do $currentLabel += 1 in the Example1 function instead
      $label += 1
   EndIf
EndFunc

Now with a reset all button!

The update label function is a single use button that sets the next label to green.

Reset all button uses a for loop to go through all of the labels.

Link to comment
Share on other sites

Ok ive been working with this today the snag i have is im not changing colours im refreshing functions like this (not a reproducer just example)

Local $dmyBegin = GUICtrlCreateDummy() + 1
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
GUICtrlCreateLabel("Is Machine Activated", 60, 20, 150, 25)
_Settings()
$activate = _ActivationStatus()
GUICtrlCreateLabel( $activate, $sInfoLeft, 20, 380, 25)
_Settings()
    If $activate = True Then
        GUICtrlCreateIcon( $tick, -1, 17, 17, 25, 25)
    Else
        GUICtrlCreateIcon($cross, -1, 17, 17, 25, 25)
    EndIf
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
GUICtrlCreateLabel("Are Drivers Installed", 60, 60, 150, 25)
_Settings()
 $devicemgr = _DeviceProblems()
 ConsoleWrite($devicemgr & @CRLF)
 GUICtrlCreateLabel($devicemgr, $sInfoLeft, 60, 380, 25)
_Settings()
    If $devicemgr = True Then
        GUICtrlCreateIcon( $tick, -1, 17, 57, 25, 25)
    Else
        GUICtrlCreateIcon($cross, -1, 17, 57, 25, 25)
    EndIf

So rather than change colours with text i need it to recheck functions like these

$activate = _ActivationStatus()
$devicemgr = _DeviceProblems() 

Ive tried adding the functions to the button and in the loop to no joy

This is how the labels look and if i fix the device manager and press the refresh button the red one would turn green

post-60350-0-03453500-1424983756.png

The True/False part will be hidden later

Edited by Chimaera
Link to comment
Share on other sites

Been working on this at work and got this to work but it doesnt seem responsive atmo but ill keep refining

Case $RefreshButton
            For $i = $dmyBegin to $dmyEnd
                  Switch GUICtrlRead($i)
                      Case $devicemgr
                           $devicemgr = _DeviceProblems()
                            If $devicemgr = True Then
                                GUICtrlCreateIcon( $tick, -1, 17, 57, 25, 25)
                            Else
                                GUICtrlCreateIcon( $cross, -1, 17, 57, 25, 25)
                            EndIf
                      Case $tspack
                            $tspack = _TS_Pack()
                            If $tspack = True Then
                                GUICtrlCreateIcon( $tick, -1, 17, 137, 25, 25)
                            Else
                                GUICtrlCreateIcon( $cross, -1, 17, 97, 25, 25)
                            EndIf
    ;~                Case "Restart computer"
    ;~                    ;do this
                  EndSwitch
            Next
Link to comment
Share on other sites

Chimaera,

Next time please post a reproducer script of what you want to do, not necessary the entire code or a part of it but something someone can copy-past on SciTe...so is more easy to understand and less time to make everything. I think that you know how it works here, you have more than 2.000 posts :D

Based on your code-style:

; Johnmcloud test code - 2015
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

Global $lMachine, $lDriver, $lInternet
Global $iMachine, $iDriver, $iInteret
Global $sMachine, $sDriver, $sInternet
Global $hGUI, $dBegin, $dEnd, $iButton

$hGUI = GUICreate("Johnmcloud", 220, 180)
GUISetFont(Default, 800)

$dBegin = GUICtrlCreateDummy()
$sMachine = _ActivationStatus(1) ; assuming is true
GUICtrlCreateLabel("Is Machine Activated", 40, 16)
;~ $lMachine = GUICtrlCreateLabel($sMachine, 175, 16)
If $sMachine = "TRUE" Then
    $iMachine = GUICtrlCreateIcon("shell32.dll", -111, 6, 6)
Else
    $iMachine = GUICtrlCreateIcon("shell32.dll", -110, 6, 6)
EndIf

$sInternet = _InternetStatus(0) ; assuming is False
GUICtrlCreateLabel("Is Internet Connected", 39, 58)
;~ $lInternet = GUICtrlCreateLabel($sInternet, 175, 104)
If $sInternet = "TRUE" Then
    $iInteret = GUICtrlCreateIcon("shell32.dll", -111, 6, 95)
Else
    $iInteret = GUICtrlCreateIcon("shell32.dll", -110, 6, 95)
EndIf

$sDriver = _DeviceProblems(0) ; assuming is false
GUICtrlCreateLabel("Are Driver Installed", 39, 104)
;~ $lDriver = GUICtrlCreateLabel($sDriver, 175, 58)
If $sDriver = "TRUE" Then
    $iDriver = GUICtrlCreateIcon("shell32.dll", -111, 6, 49)
Else
    $iDriver = GUICtrlCreateIcon("shell32.dll", -110, 6, 49)
EndIf

$dEnd = GUICtrlCreateDummy()

$iButton = GUICtrlCreateButton("Update", 90, 140, 50, 25)
GUICtrlSetFont(-1, Default, 400)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $iButton
            _Update($dBegin, $dEnd)
    EndSwitch
WEnd

Func _Update($iStart, $iEnd)
    Local $iID
    For $iID = $iStart + 1 To $iEnd - 1
;~      If GUICtrlRead($iID) = "FALSE" Then ; check only false value, if are the true...are true so skip it
            Switch GUICtrlRead($iID) ; search for the label, if you use GUICtrlRead($iID) = "FALSE" you need to use Switch GUICtrlRead($iID-1)
                Case "Is Machine Activated" ; is True, is skipped if you use GUICtrlRead($iID) = "FALSE" but you need to add it in case is False
                    $sMachine = _ActivationStatus(1)
;~                  GUICtrlSetData($iID, $sMachine)
                    If $sMachine = "TRUE" Then
                        GUICtrlSetImage($iID + 1, "shell32.dll", -111)
                    Else
                        GUICtrlSetImage($iID + 1, "shell32.dll", -110)
                    EndIf
                Case "Is Internet Connected"
                    $sInternet = _InternetStatus(1) ; this time return true just for see the change
;~                  GUICtrlSetData($iID, $sInternet)
                    If $sInternet = "TRUE" Then
                        GUICtrlSetImage($iID + 1, "shell32.dll", -111)
                    Else
                        GUICtrlSetImage($iID + 1, "shell32.dll", -110)
                    EndIf
                Case "Are Driver Installed"
                    $sDriver = _InternetStatus(1) ; this time return true just for see the change
;~                  GUICtrlSetData($iID, $sDriver)
                    If $sDriver = "TRUE" Then
                        GUICtrlSetImage($iID + 1, "shell32.dll", -111)
                    Else
                        GUICtrlSetImage($iID + 1, "shell32.dll", -110)
                    EndIf
            EndSwitch
;~      EndIf
    Next
EndFunc   ;==>_Update

Func _ActivationStatus($sParam)
    If $sParam = 0 Then Return "FALSE"
    If $sParam = 1 Then Return "TRUE"
EndFunc   ;==>_ActivationStatus

Func _DeviceProblems($sParam)
    If $sParam = 0 Then Return "FALSE"
    If $sParam = 1 Then Return "TRUE"
EndFunc   ;==>_DeviceProblems

Func _InternetStatus($sParam)
    If $sParam = 0 Then Return "FALSE"
    If $sParam = 1 Then Return "TRUE"
EndFunc   ;==>_InternetStatus
Edited by johnmcloud
Link to comment
Share on other sites

Its a bad habit of mine apologies

I often only have an idea when i start thats why its vague sometimes, ill report back when i can thx

Link to comment
Share on other sites

Ok ive gone a slightly different path to use the update part in a simpler format but i have hit an problem

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $devicemgr

Local $GUI_Start = GUICreate("Final Check", 300, 300, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
GUICtrlCreateLabel("Are Drivers Installed", 60, 60, 150, 25)
_Settings()
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
_Update() ; Update the gui with info
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
Local $RefreshButton = GUICtrlCreateButton(" Refresh List ", 60, 200, 130, 55)
_Settings()
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
GUISetState()

Local $nMsg = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $RefreshButton
            Sleep(2000)
            _Update()
    EndSwitch
WEnd

Func _Update()
    $devicemgr = _DeviceProblems()
    If $devicemgr = True Then
        GUICtrlCreateIcon("shell32.dll", -111, 6, 60)
        ConsoleWrite('Device Manager Is ' & $devicemgr & @CRLF)
    Else
        GUICtrlCreateIcon("shell32.dll", -110, 6, 60)
        ConsoleWrite('Device Manager Is ' & $devicemgr & @CRLF)
    EndIf
EndFunc   ;==>_Update

Func _Settings()
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;~ GUICtrlSetDefBkColor(0xFF0000) ; For Checking Label Placements
    GUICtrlSetFont(-1, 11, 600, "", "Tahoma")
EndFunc   ;==>_Settings

Func _DeviceProblems()
    Local $Code = "", $codemsg = "", $strComputer = "."
    #forceref $codemsg
    Local $bProblemsExist = False, $bDisabledExist = False
    Local $DEVobjWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
    Local $DEVcolItems = $DEVobjWMIService.ExecQuery("Select * from Win32_PnPEntity " & "WHERE ConfigManagerErrorCode <> 0")
    For $DEVobjItem In $DEVcolItems
        $Code = $DEVobjItem.name
        If $DEVobjItem.ConfigManagerErrorcode >= 1 And $DEVobjItem.ConfigManagerErrorcode <= 52 Then
            $bProblemsExist = True
        EndIf
        Return False
    Next
    If $bDisabledExist = False And $bProblemsExist = False Then
        Return True
    EndIf
EndFunc   ;==>_DeviceProblems

There is a reproducer

Now disable a dvd drive in device manager then run the code it will flag as false on the gui load so all good but

If you change the device manager to enable

And the press the button it registers the change in the consolewrite but wont change the icon until you press the button a second time

Device Manager Is False

Device Manager Is True
Device Manager Is True <<<<<<< doesnt change the icon until here

 

Any suggestions as to why?

Edited by Chimaera
Link to comment
Share on other sites

Uh, a reproducer :D

Your error is simple, you open the GUI and example you have True, so GUICtrlCreateIcon create an icon. But if you want to change that icon you don't need to apply another GUICtrlCreateIcon, in this case you have 2 control with two different icon, but change the previus one control

This work:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $devicemgr
Global $iIconDriver = -1 ; <<<<< declare only ONE icon for "Are Drivers Installed"

Local $GUI_Start = GUICreate("Final Check", 300, 300, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
GUICtrlCreateLabel("Are Drivers Installed", 60, 60, 150, 25)
_Settings()
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>

;$iIconDriver = GUICtrlCreateIcon("", 0, 6, 60) <<<<< If you put here is better
_Update() ; Update the gui with info
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>

Local $RefreshButton = GUICtrlCreateButton(" Refresh List ", 60, 200, 130, 55)
_Settings()
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
GUISetState()

Local $nMsg = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $RefreshButton
            Sleep(2000)
            _Update()
    EndSwitch
WEnd

Func _Update()
    $devicemgr = _DeviceProblems()
    If $devicemgr = True Then
        If $iIconDriver = -1 Then $iIconDriver = GUICtrlCreateIcon("", 0, 6, 60) ; <<<<< If the control not exist, create it
        If $iIconDriver <> -1 Then GUICtrlSetImage($iIconDriver, "shell32.dll", -111) ; <<<<< If the control exist, change the icon
        ConsoleWrite('Device Manager Is ' & $devicemgr & @CRLF)
    Else
        If $iIconDriver = -1 Then $iIconDriver = GUICtrlCreateIcon("", 0, 6, 60) ; <<<<< If the control not exist, create it
        If $iIconDriver <> -1 Then GUICtrlSetImage($iIconDriver, "shell32.dll", -110) ; <<<<< If the control exist, change the icon
        ConsoleWrite('Device Manager Is ' & $devicemgr & @CRLF)
    EndIf
EndFunc   ;==>_Update

Func _Settings()
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;~ GUICtrlSetDefBkColor(0xFF0000) ; For Checking Label Placements
    GUICtrlSetFont(-1, 11, 600, "", "Tahoma")
EndFunc   ;==>_Settings

Func _DeviceProblems()
    Local $Code = "", $codemsg = "", $strComputer = "."
    #forceref $codemsg
    Local $bProblemsExist = False, $bDisabledExist = False
    Local $DEVobjWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
    Local $DEVcolItems = $DEVobjWMIService.ExecQuery("Select * from Win32_PnPEntity " & "WHERE ConfigManagerErrorCode <> 0")
    For $DEVobjItem In $DEVcolItems
        $Code = $DEVobjItem.name
        If $DEVobjItem.ConfigManagerErrorcode >= 1 And $DEVobjItem.ConfigManagerErrorcode <= 52 Then
            $bProblemsExist = True
        EndIf
        Return False
    Next
    If $bDisabledExist = False And $bProblemsExist = False Then
        Return True
    EndIf
EndFunc   ;==>_DeviceProblems
Edited by johnmcloud
Link to comment
Share on other sites

Is there any advantage to this?

i can set the icon as the negative as often thats what it will be

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $devicemgr
;~ Global $hIcon = -1 ; declare only ONE icon for Are Drivers Installed <<<<<<

Local $GUI_Start = GUICreate("Final Check", 300, 300, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
GUICtrlCreateLabel("Are Drivers Installed", 60, 60, 150, 25)
_Settings()
Local $hIcon = GUICtrlCreateIcon("shell32.dll", -110, 6, 60)
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
_Update() ; Update the gui with info
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
Local $RefreshButton = GUICtrlCreateButton(" Refresh List ", 60, 200, 130, 55)
_Settings()
;<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
GUISetState()

Local $nMsg = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $RefreshButton
            Sleep(200)
            _Update()
    EndSwitch
WEnd

Func _Update()
    $devicemgr = _DeviceProblems()
    If $devicemgr = True Then
        GUICtrlSetImage($hIcon, "shell32.dll", -111) ; if the control exist, change the icon
        ConsoleWrite('Device Manager Is ' & $devicemgr & @CRLF)
    Else
       GUICtrlSetImage($hIcon, "shell32.dll", -110) ; if the control exist, change the icon
        ConsoleWrite('Device Manager Is ' & $devicemgr & @CRLF)
    EndIf
EndFunc   ;==>_Update

Func _Settings()
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;~ GUICtrlSetDefBkColor(0xFF0000) ; For Checking Label Placements
    GUICtrlSetFont(-1, 11, 600, "", "Tahoma")
EndFunc   ;==>_Settings

Func _DeviceProblems()
    Local $Code = "", $codemsg = "", $strComputer = "."
    #forceref $codemsg
    Local $bProblemsExist = False, $bDisabledExist = False
    Local $DEVobjWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
    Local $DEVcolItems = $DEVobjWMIService.ExecQuery("Select * from Win32_PnPEntity " & "WHERE ConfigManagerErrorCode <> 0")
    For $DEVobjItem In $DEVcolItems
        $Code = $DEVobjItem.name
        If $DEVobjItem.ConfigManagerErrorcode >= 1 And $DEVobjItem.ConfigManagerErrorcode <= 52 Then
            $bProblemsExist = True
        EndIf
        Return False
    Next
    If $bDisabledExist = False And $bProblemsExist = False Then
        Return True
    EndIf
EndFunc   ;==>_DeviceProblems

Obviously i will need to personalize the icons for each check

Edited by Chimaera
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...