Jump to content

GUI Graphics


argv1
 Share

Recommended Posts

Hi,

I got some control lights, that should show if the program can run without any problems

ATM the script will run a check once I hit the "Go" Button. But if would be nice, if the script can do this more often, i.e. every 3 minutes.

Here is my current script

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Crypter", 222, 208, 192, 124)
$Input1 = GUICtrlCreateInput("", 16, 48, 185, 21, $ES_NUMBER) ;== only digits
$Input2 = GUICtrlCreateInput("", 16, 88, 185, 21)
$ButtonGo = GUICtrlCreateButton("Go", 48, 128, 113, 41)

        $Light1 = GUICtrlCreateGraphic(5, 5, 31, 32)
            GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0xFFCC33) ;== gelb
            GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        $Light2 = GUICtrlCreateGraphic(35, 5, 31, 32)
            GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0xFFCC33) ;== gelb
            GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        $Light3 = GUICtrlCreateGraphic(65, 5, 31, 32)
            GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0xFFCC33) ;== gelb
            GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        $Light4 = GUICtrlCreateGraphic(95, 5, 31, 32)
            GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0xFFCC33) ;== gelb
            GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        $Light5 = GUICtrlCreateGraphic(125, 5, 31, 32)
            GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0xFFCC33) ;== gelb
            GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)

GUISetState(@SW_SHOW)

$dateinamensteil1 = "test"
$dateinamensteil3 = ".enc"

While 1
        Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ButtonGo
            if lights() Then
                Foobar()
            EndIf
    EndSwitch
WEnd

Func lights()
;==$Kontrolllampe1
    If FileExists("C:\test\test.doc") Then
        GUICtrlSetGraphic($Light1, $GUI_GR_COLOR, 0x000000, 0x00FF00) ;== grün
        GUICtrlSetGraphic($Light1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic ($Light1, $GUI_GR_REFRESH)
        $Kontrolle1 = 1
    Else
        GUICtrlSetGraphic($Light1, $GUI_GR_COLOR, 0x000000, 0xFF0000) ;== rot
        GUICtrlSetGraphic($Light1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic ($Light1, $GUI_GR_REFRESH)
        $Kontrolle1 = 0
    EndIf

;==$Kontrolllampe2
    If GUICtrlRead($Input1) THEN
        GUICtrlSetGraphic($Light2, $GUI_GR_COLOR, 0x000000, 0x00FF00) ;== grün
        GUICtrlSetGraphic($Light2, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic ($Light2, $GUI_GR_REFRESH)
        $Kontrolle2 = 1
    Else
        GUICtrlSetGraphic($Light2, $GUI_GR_COLOR, 0x000000, 0xFF0000) ;== rot
        GUICtrlSetGraphic($Light2, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic ($Light2, $GUI_GR_REFRESH)
        $Kontrolle2 = 0
    EndIf

;==$Kontrolllampe3
    If FileExists(@ScriptDir & "\" & $dateinamensteil1 & $Input1 & $dateinamensteil3) THEN
        GUICtrlSetGraphic($Light3, $GUI_GR_COLOR, 0x000000, 0x00FF00) ;== grün
        GUICtrlSetGraphic($Light3, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic ($Light3, $GUI_GR_REFRESH)
        $Kontrolle3 = 1
    Else
        GUICtrlSetGraphic($Light3, $GUI_GR_COLOR, 0x000000, 0xFF0000) ;== rot
        GUICtrlSetGraphic($Light3, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic ($Light3, $GUI_GR_REFRESH)
        $Kontrolle3 = 0
    EndIf

;==$Kontrolllampe4
    If GUICtrlRead($Input2) THEN
        GUICtrlSetGraphic($Light4, $GUI_GR_COLOR, 0x000000, 0x00FF00) ;== grün
        GUICtrlSetGraphic($Light4, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic ($Light4, $GUI_GR_REFRESH)
        $Kontrolle4 = 1
    Else
        GUICtrlSetGraphic($Light4, $GUI_GR_COLOR, 0x000000, 0xFF0000) ;== rot
        GUICtrlSetGraphic($Light4, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic ($Light4, $GUI_GR_REFRESH)
        $Kontrolle4 = 0
    EndIf

;==$Kontrolllampe5
    If FileExists("C:\Program Files\Test.exe") THEN
        GUICtrlSetGraphic($Light5, $GUI_GR_COLOR, 0x000000, 0x00FF00) ;== grün
        GUICtrlSetGraphic($Light5, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic ($Light5, $GUI_GR_REFRESH)
        $Kontrolle5 = 1
    Else
        GUICtrlSetGraphic($Light5, $GUI_GR_COLOR, 0x000000, 0xFF0000) ;== rot
        GUICtrlSetGraphic($Light5, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic ($Light5, $GUI_GR_REFRESH)
        $Kontrolle5 = 0
    EndIf

    If $Kontrolle1 + $Kontrolle2 + $Kontrolle3 + $Kontrolle4 + $Kontrolle5 = 5 Then ; wenn alle Kontrolllampen grün dann sende 1 zurück ansonsten 0
        Return 1
    Else
        Return 0
    EndIf
EndFunc


Func Foobar()
...
EndFunc

 

Edited by argv1
Link to comment
Share on other sites

You can use a timer in the main While 1 loop to check if it's been 3 minutes

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Crypter", 222, 208, 192, 124)
$Input1 = GUICtrlCreateInput("", 16, 48, 185, 21, $ES_NUMBER) ;== only digits
$Input2 = GUICtrlCreateInput("", 16, 88, 185, 21)
$ButtonGo = GUICtrlCreateButton("Go", 48, 128, 113, 41)

$Light1 = GUICtrlCreateGraphic(5, 5, 31, 32)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0xFFCC33) ;== gelb
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
$Light2 = GUICtrlCreateGraphic(35, 5, 31, 32)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0xFFCC33) ;== gelb
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
$Light3 = GUICtrlCreateGraphic(65, 5, 31, 32)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0xFFCC33) ;== gelb
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
$Light4 = GUICtrlCreateGraphic(95, 5, 31, 32)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0xFFCC33) ;== gelb
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
$Light5 = GUICtrlCreateGraphic(125, 5, 31, 32)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0xFFCC33) ;== gelb
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)

GUISetState(@SW_SHOW)

$dateinamensteil1 = "test"
$dateinamensteil3 = ".enc"

#Region: Variables used to trigger the lights() function periodically
Global $iTimeBetweenChecks = 180000 ; This is time in milliseconds (3 [minutes] * 60 [seconds in a minute] * 1000 [milliseconds in a second])
Global $iLightsTimer = TimerInit()
#EndRegion

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ButtonGo
            If lights() Then
                Foobar()
            EndIf
        #Region: Code to check if lights() needs to be called
    Case Else
            ; Just a tooltip displaying when the lights() function will be called
            ToolTip("Time until lights() triggers: " & Int(($iTimeBetweenChecks - TimerDiff($iLightsTimer)) / 1000, 2) & " seconds", 0, 0)
            If (TimerDiff($iLightsTimer) >= $iTimeBetweenChecks) Then
                If (lights()) Then
                    Foobar()
                EndIf
                $iLightsTimer = TimerInit()
            EndIf
        #EndRegion
    EndSwitch
WEnd

Func lights()
    Local $Kontrolllampe = 0
    ;==$Kontrolllampe1
    If FileExists("C:\test\test.doc") Then
        GUICtrlSetGraphic($Light1, $GUI_GR_COLOR, 0x000000, 0x00FF00) ;== grün
        GUICtrlSetGraphic($Light1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic($Light1, $GUI_GR_REFRESH)
        $Kontrolllampe += 1
    Else
        GUICtrlSetGraphic($Light1, $GUI_GR_COLOR, 0x000000, 0xFF0000) ;== rot
        GUICtrlSetGraphic($Light1, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic($Light1, $GUI_GR_REFRESH)
    EndIf

    ;==$Kontrolllampe2
    If GUICtrlRead($Input1) Then
        GUICtrlSetGraphic($Light2, $GUI_GR_COLOR, 0x000000, 0x00FF00) ;== grün
        GUICtrlSetGraphic($Light2, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic($Light2, $GUI_GR_REFRESH)
        $Kontrolllampe += 1
    Else
        GUICtrlSetGraphic($Light2, $GUI_GR_COLOR, 0x000000, 0xFF0000) ;== rot
        GUICtrlSetGraphic($Light2, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic($Light2, $GUI_GR_REFRESH)
    EndIf

    ;==$Kontrolllampe3
    If FileExists(@ScriptDir & "\" & $dateinamensteil1 & $Input1 & $dateinamensteil3) Then
        GUICtrlSetGraphic($Light3, $GUI_GR_COLOR, 0x000000, 0x00FF00) ;== grün
        GUICtrlSetGraphic($Light3, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic($Light3, $GUI_GR_REFRESH)
        $Kontrolllampe += 1
    Else
        GUICtrlSetGraphic($Light3, $GUI_GR_COLOR, 0x000000, 0xFF0000) ;== rot
        GUICtrlSetGraphic($Light3, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic($Light3, $GUI_GR_REFRESH)
    EndIf

    ;==$Kontrolllampe4
    If GUICtrlRead($Input2) Then
        GUICtrlSetGraphic($Light4, $GUI_GR_COLOR, 0x000000, 0x00FF00) ;== grün
        GUICtrlSetGraphic($Light4, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic($Light4, $GUI_GR_REFRESH)
        $Kontrolllampe += 1
    Else
        GUICtrlSetGraphic($Light4, $GUI_GR_COLOR, 0x000000, 0xFF0000) ;== rot
        GUICtrlSetGraphic($Light4, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic($Light4, $GUI_GR_REFRESH)
    EndIf

    ;==$Kontrolllampe5
    If FileExists("C:\Program Files\Test.exe") Then
        GUICtrlSetGraphic($Light5, $GUI_GR_COLOR, 0x000000, 0x00FF00) ;== grün
        GUICtrlSetGraphic($Light5, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic($Light5, $GUI_GR_REFRESH)
        $Kontrolllampe += 1
    Else
        GUICtrlSetGraphic($Light5, $GUI_GR_COLOR, 0x000000, 0xFF0000) ;== rot
        GUICtrlSetGraphic($Light5, $GUI_GR_ELLIPSE, 6, 8, 20, 19)
        GUICtrlSetGraphic($Light5, $GUI_GR_REFRESH)
    EndIf

    If $Kontrolllampe = 5 Then ; wenn alle Kontrolllampen grün dann sende 1 zurück ansonsten 0
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>lights


Func Foobar()

EndFunc   ;==>Foobar

 

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