Hallo liebe Scripter,
heute mal ein hoffe ich doch eher kleineres Problem. Ich bekomme es irgendwie, trotz Adlib Registering nicht hin, einen Farbwechsel des Labels zu realisieren. Grundsätzlich geht es ja, aber nur wenn ich das Script neu starte, also er soll bei nicht Aktivierung rot sein, ansonsten weiss. Den Farbwert scheint er nicht zu aktualisieren. was mache ich falsch?
Schaut so aus:
AutoIt
; includes ---------------------------------------------------------------------
#include-once
#include "Services.au3"
#include <GDIPlus.au3>
#include <GuiCtrlSetOnHover_UDF.au3>
#include <StaticConstants.au3>
#include <String.au3>
#include <WinApi.au3>
#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <StringConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <date.au3>
#include <EditConstants.au3>
#include <Array.au3>
#include <Constants.au3>
; opt --------------------------------------------------------------------------
Opt('MustDeclareVars', 1)
;declaration ------------------------------------------------------------------
;GUI Variables
Global $ActiveCheck, $result
Global $ARRAY_COLOR_TOP_MIN[3] = [36, 65, 142]
Global $ARRAY_COLOR_TOP_MAX[3] = [11, 42, 122]
Global $RBOX_EVENT_CLOSE = 1
Global $ROUNDES = 20, $LastHwnd = 0
Global $LastHwnd
Global $GUIBKCOLOR = 0x738599
Global $SubBack = 0xEAF0E2
;System Variables
Global $acLabel
Global $ac = ""
;AdLibRegistering;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AdlibRegister('CheckAcState', 3000)
; processing --------------------------------------------------------------------------------------------------
Global $hGui = RBoxCreate("Test", 840, 610)
;FunctionCalls---------------------------------------------------------------------------------------------------------------------------------------------------
CheckAcState()
_createLabels()
;Main Logic--------------------------------------------------------------------------------------------------------------------------------------------------
While True
CheckX($hGui, $RBOX_EVENT_CLOSE, "GuiCtrlSetColor(" & $RBOX_EVENT_CLOSE & ",0xA3A3A3)", "GuiCtrlSetColor(" & $RBOX_EVENT_CLOSE & ",0x555555)")
local $gMsg = GUIGetMsg()
Switch $gMsg
Case $GUI_EVENT_CLOSE, $RBOX_EVENT_CLOSE
GUIDelete($hGui)
AdlibUnRegister('CheckAcState')
Exit
EndSwitch
WEnd
;-------------------------------------------------------------------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------------------------------------------------------------------
Func _createLabels()
$ACLabel = GUICtrlCreateLabel($ac, 600, 560, 250, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 11, 800) ; bold
GUICtrlSetColor(-1, $col) ; red
EndFunc
;-------------------------------------------------------------------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------------------------------------------------------------------
; AktivierungsStatus----------------------------------------------------------------------------------------------------------------------------------------------
Func CheckAcState()
global $col
_IfWinActivated()
if _IfWinActivated() = "True" Then
$ac = "Der PC ist dauerhaft aktiviert"
global $col = "0xFFFFFF"
GUICtrlSetData($acLabel, $ac)
Else
$ac = "Der PC ist nicht aktiviert !!!"
global $col = "0xF00404"
GUICtrlSetData($acLabel, $ac)
EndIf
EndFunc;==> $ac
Func _IfWinActivated()
Local $sCommand, $iPID, $sData
$sCommand = @ComSpec & ' /c WMIC /NAMESPACE:\\root\CIMV2 PATH SoftwareLicensingProduct WHERE LicenseStatus=1 GET Description, LicenseStatus|findstr "Operating System"'
$iPID = Run($sCommand, @ScriptDir, @SW_HIDE, 0x2)
ProcessWaitClose($iPID)
$sData = StringStripWS(StdoutRead($iPID), $STR_STRIPTRAILING)
Return StringRight($sData, 1) == '1'
EndFunc ;==>_IfWinActivated
;-------------------------------------------------------------------------------------------------------------------------------------------------
;GUI STYLE--------------------------------------------------------------------------------------------------------------------------------------------------
Func RBoxCreate($Title, $width, $height, $left = -1, $top = -1, $show = 1)
Local $GUI = GUICreate($Title, $width, $height, $left, $top, $WS_POPUP)
;GUICtrlCreatePic('C:\Windows\Temp\hg.jpg', 0, 25, 920, 660)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetBkColor($GUIBKCOLOR, $GUI)
;_GuiRoundCorners($GUI,0,0,$ROUNDES,$ROUNDES)
$RBOX_EVENT_CLOSE = GUICtrlCreateLabel('X', $width - 20, 3, 25, 25)
GUICtrlSetCursor($RBOX_EVENT_CLOSE, 0)
GUICtrlSetBkColor($RBOX_EVENT_CLOSE, -2)
GUICtrlSetFont($RBOX_EVENT_CLOSE, 15, 800)
GUICtrlSetColor($RBOX_EVENT_CLOSE, 0x555555)
$Title &= " "
Local $hTitle = GUICtrlCreateLabel($Title, 0, 0, $width - 20, 26, $SS_CENTER, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont($hTitle, 17, 400, 0, "Consolas")
GUICtrlSetBkColor($hTitle, -2)
Local $Graphic = GUICtrlCreateGraphic(0, 0, $width, 25)
GUICtrlSetState($Graphic, $Gui_DISABLE)
;GradientFill($Graphic, 0, 0, $width, 25, $ARRAY_COLOR_TOP_MIN, $ARRAY_COLOR_TOP_MAX)
If $show = 1 Then GUISetState(@SW_SHOW, $GUI)
Return $GUI
EndFunc
Func CheckX($hGui, $CtrlID, $sCMD, $eCMD)
Local $cGui = GUIGetCursorInfo($hGui)
If Not IsArray($cGui) Then
Return 0
EndIf
If $LastHwnd <> $cGui[4] And $cGui[4] = $CtrlID Then Return Execute($sCMD) + Assign("LastHwnd", $cGui[4])
If $LastHwnd <> $cGui[4] Then Return Execute($eCMD) + Assign("LastHwnd", $cGui[4])
EndFunc
;-------------------------------------------------------------------------------------------------------------------------------------------------
Alles anzeigen
Was mache ich falsch, Danke schon mal
lg
Chris