Jump to content
amphoric

Stop Label Flashing/Flickering

Recommended Posts

amphoric

Good Morning,

I am in the process of writing some simple script, although upon selecting 'Not in List' from my drop down it is meant to show a label.... this works although it flashes like crazy!! How can I stop this?

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <EditConstants.au3>
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <EditConstants.au3>

Opt("GUIOnEventMode", 1)

Opt("GUIResizeMode", $GUI_DOCKAUTO+$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
Opt("GUIResizeMode", $GUI_DOCKAUTO+$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
Opt("GUIResizeMode", $GUI_DOCKAUTO+$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
Opt("GUIResizeMode", $GUI_DOCKAUTO+$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
Opt("GUIResizeMode", $GUI_DOCKAUTO+$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)


#Region ### START Koda GUI section ### Form=H:\!! Applications\User Location Popup\Layout.kxf
$Form1 = GUICreate("Your Asset Location", 514, 255, -1, -1, BitOr($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW, $WS_EX_COMPOSITED))
GUISetBkColor(0xFFFFFF)
$Pic1 = GUICtrlCreatePic("Images\image.jpg", 328, 160, 161, 34)
$Pic2 = GUICtrlCreatePic("Images\image1.jpg", 16, 16, 212, 28)
$Label1 = GUICtrlCreateLabel("Your Asset Location", 256, 16, 236, 33)
GUICtrlSetFont(-1, 17, 800, 0, "MS Sans Serif")
$Combo1 = GUICtrlCreateCombo("", 264, 70, 241, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE))
$Label2 = GUICtrlCreateLabel("Please select your current location:", 8, 72, 247, 20, $SS_CENTER)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Finish", 376, 216, 75, 25)
$Checkbox1 = GUICtrlCreateCheckbox("I have ensured that my selection is correct.", 40, 224, 281, 17)
$Label3 = GUICtrlCreateLabel("This is a one time request for your location", 24, 160, 253, 20)
GUICtrlSetColor(-1, 0xFF0000)
$Label4 = GUICtrlCreateLabel("please ensure the accuracy of your submition.", 16, 176, 275, 20)
GUICtrlSetColor(-1, 0xFF0000)
$ManLocation = GUICtrlCreateLabel("Please enter your location:", 67, 112, 189, 20, BitOr($SS_CENTER, $WS_EX_COMPOSITED))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetState(-1, $GUI_HIDE)
$ManLocInput = GUICtrlCreateInput("", 264, 109, 241, 24)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


; Get the sections of LOACTIONS in the ini file
Global $aSections = IniReadSectionNames("Locations.ini")
; If the IniReadSectionNames succeeded, conver the array to a string with each item separated by a | (pipe) and set the default selected item to $aSections[1]
If (Not @Error) Then GUICtrlSetData($Combo1, _ArraytoString($aSections, "|", 1), $aSections[1])



While 1
    $nMsg = GUIGetMsg()

;If Reg Exists - EXIT
if Not RegRead ("HKLM\SOFTWARE\location", "Location") =  "" Then
    Exit
EndIf

;EXIT - If Admin Account
$string = @UserName
$searchstring1 = "TSS"
$searchstring2 = "SDESK"
$searchstring3 = "DESK"
$searchstring4 = "PROBADMIN"
$searchstring5 = "ENGADMIN"
If StringInStr($string, $searchstring1) Or StringInStr($string, $searchstring2) Or StringInStr($string, $searchstring3) Or StringInStr($string, $searchstring4) Or StringInStr($string, $searchstring5) Then
    Exit
EndIf


if GUICtrlRead($Combo1) = "Not In List" Then
    GUICtrlSetState($ManLocation, $GUI_SHOW)
Else
    GUICtrlSetState($ManLocation, $GUI_HIDE)
EndIf


;Set Chackbox & Button GUI_SHOW
if Not GUICtrlRead($Combo1) = "" Then
If Not ControlCommand($Form1, "", $Checkbox1, "IsEnabled") Then GUICtrlSetState($Checkbox1, $GUI_ENABLE)
    Else
        If ControlCommand($Form1, "", $Checkbox1, "IsEnabled") Then GUICtrlSetState($Checkbox1, $GUI_DISABLE)
    EndIf


;Set Button Focus
If GUICtrlRead($Checkbox1) = 1 Then
    If Not ControlCommand($Form1, "", $Button1, "IsEnabled") Then GUICtrlSetState($Button1, $GUI_ENABLE)
    Else
        If ControlCommand($Form1, "", $Button1, "IsEnabled") Then GUICtrlSetState($Button1, $GUI_DISABLE)
    EndIf


    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit


        ;OK Button Function - Write to reg
        Case $Button1
            RegDelete("HKLM\SOFTWARE\Location", "Location")
            RegDelete("HKLM64\SOFTWARE\Location", "Location")
            RegDelete("HKLM\SOFTWARE\Location", "LocationLog")
            RegDelete("HKLM64\SOFTWARE\Location", "LocationLog")

            RegWrite("HKLM\SOFTWARE\Location", "Location", "REG_SZ", GUICtrlRead($Combo1))
            RegWrite("HKLM64\SOFTWARE\Location", "Location", "REG_SZ", GUICtrlRead($Combo1))
            RegWrite("HKLM\SOFTWARE\Location", "LocationLog", "REG_SZ", @MDAY & "-" & @MON & "-" & @YEAR)
            RegWrite("HKLM64\SOFTWARE\Location", "LocationLog", "REG_SZ", @MDAY & "-" & @MON & "-" & @YEAR)
            MsgBox($MB_SYSTEMMODAL, "Thank You", "Thank you for your time.")

    EndSwitch
WEnd

Cheers

Share this post


Link to post
Share on other sites
232showtime

I ran your script and dont see any flickering label.


ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Share this post


Link to post
Share on other sites
amphoric

its the label that appears when you select 'Not In List' from the drop down.

 

Cheers

Share this post


Link to post
Share on other sites
Melba23

amphoric,

I would write the script something like this:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <EditConstants.au3>
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <EditConstants.au3>

;Opt("GUIOnEventMode", 1) ; You are using MessageLoop mode - not OnEvent

; Do these checks forst - no need to call them within the idle loop

;If Reg Exists - EXIT
If Not RegRead("HKLM\SOFTWARE\location", "Location") = "" Then
    Exit
EndIf

;EXIT - If Admin Account
$string = @UserName
; Create an array of the possible strings
Global $aAdmin[] = ["TSS", "SDESK", "DESK", "PROBADMIN", "ENGADMIN"]
; And loop through it
For $i = 0 To UBound($aAdmin) - 1
    If StringInStr($string, $aAdmin[$i]) Then
        Exit
    EndIf
Next

; Now create GUI
$Form1 = GUICreate("Your Asset Location", 514, 255, -1, -1, BitOR($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW, $WS_EX_COMPOSITED))

$Label1 = GUICtrlCreateLabel("Your Asset Location", 256, 16, 236, 33)
$Combo1 = GUICtrlCreateCombo("", 264, 70, 241, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
$Label2 = GUICtrlCreateLabel("Please select your current location:", 8, 72, 247, 20, $SS_CENTER)
$Button1 = GUICtrlCreateButton("Finish", 376, 216, 75, 25)
GUICtrlSetState(-1, $GUI_DISABLE)
$Checkbox1 = GUICtrlCreateCheckbox("I have ensured that my selection is correct.", 40, 224, 281, 17)
$Label3 = GUICtrlCreateLabel("This is a one time request for your location", 24, 160, 253, 20)
$Label4 = GUICtrlCreateLabel("please ensure the accuracy of your submition.", 16, 176, 275, 20)
$ManLocation = GUICtrlCreateLabel("Please enter your location:", 67, 112, 189, 20, BitOR($SS_CENTER, $WS_EX_COMPOSITED))
GUICtrlSetState(-1, $GUI_HIDE)
$ManLocInput = GUICtrlCreateInput("", 264, 109, 241, 24)
GUICtrlSetState(-1, $GUI_HIDE)

GUISetState(@SW_SHOW)

; Get the sections of LOCATIONS in the ini file
Global $aSections = IniReadSectionNames("Locations.ini")
; If the IniReadSectionNames succeeded, conver the array to a string with each item separated by a | (pipe) and set the default selected item to $aSections[1]
If (Not @error) Then
    GUICtrlSetData($Combo1, _ArrayToString($aSections, "|", 1), $aSections[1])
Else
    GUICtrlSetData($Combo1, "Fred|Not In List") ; Just for testing becasue I do not have an ini file
EndIf

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Combo1 ; I fthe combo is actioned
            Switch GUICtrlRead($Combo1)
                Case "Not In List" ; Show the manual input controls
                    GUICtrlSetState($ManLocation, $GUI_SHOW)
                    GUICtrlSetState($ManLocInput, $GUI_SHOW)
                Case Else ; Hide them
                    GUICtrlSetState($ManLocation, $GUI_HIDE)
                    GUICtrlSetState($ManLocInput, $GUI_HIDE)
            EndSwitch

        Case $Checkbox1 ; if the checkbox is actioned
            If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
                GUICtrlSetState($Button1, $GUI_ENABLE) ; Enable button
            Else
                GUICtrlSetState($Button1, $GUI_DISABLE) ; Disable button
            EndIf

            ;OK Button Function - Write to reg
        Case $Button1
            #cs
                RegDelete("HKLM\SOFTWARE\Location", "Location")
                RegDelete("HKLM64\SOFTWARE\Location", "Location")
                RegDelete("HKLM\SOFTWARE\Location", "LocationLog")
                RegDelete("HKLM64\SOFTWARE\Location", "LocationLog")

                RegWrite("HKLM\SOFTWARE\Location", "Location", "REG_SZ", GUICtrlRead($Combo1))
                RegWrite("HKLM64\SOFTWARE\Location", "Location", "REG_SZ", GUICtrlRead($Combo1))
                RegWrite("HKLM\SOFTWARE\Location", "LocationLog", "REG_SZ", @MDAY & "-" & @MON & "-" & @YEAR)
                RegWrite("HKLM64\SOFTWARE\Location", "LocationLog", "REG_SZ", @MDAY & "-" & @MON & "-" & @YEAR)
            #ce
            MsgBox($MB_SYSTEMMODAL, "Thank You", "Thank you for your time.")

            ExitLoop ; You need to exit the script at some point

    EndSwitch
WEnd

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
amphoric

Melba23 that's works perfectly!!! Thank you so much :)

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

×