Jump to content
_Vlad

Hiding many elements cause form flickering

Recommended Posts

Hello forum,

I want to create a program with multiple menus and many elements inside. The problem is my way of doing this and below I have an example of how I do these menus.

I know it's a bad way of doing them as using this method for more elements and menus cause big flickering.

 

Can someone please help me with some tips of optimizing this or tell me another way of creating that menus with many elements without cause flickering? From a long time ago I still try to solve this but without any results, just small improvements.

Many thanks for everyone.

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

Global $MENU_HOVER = ''
Global $MENU_SELECTED = ''
Global $COLOR_STANDARD = 0x94A5E9
Global $COLOR_HOVER = 0x8292d1
Global $COLOR_SELECTED = 0x7584bf

$MENU = GUICreate("Menu", 615, 437, -1, -1, -1, -1, 0)
GUISetFont(10, 400, 0, "Arial")
$MENU_1 = GUICtrlCreateLabel("Menu 1", 8, 24, 106, 28, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$MENU_2 = GUICtrlCreateLabel("Menu 2", 8, 56, 106, 28, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$MENU_3 = GUICtrlCreateLabel("Menu 3", 8, 88, 106, 28, BitOR($SS_CENTER, $SS_CENTERIMAGE))

;MENU 1 ELEMENTS
$MENU_1_ELEMENT_1 = GUICtrlCreateButton("Menu1 Button", 128, 24, 147, 25)

;MENU 2 ELEMENTS
$MENU_2_ELEMENT_1 = GUICtrlCreateButton("Menu2 Button", 128, 24, 147, 25)
$MENU_2_ELEMENT_2 = GUICtrlCreateLabel("Another element", 128, 64, 99, 20)

_Design()
_Hide_All()
GUISetState(@SW_SHOW, $MENU)

While 1
    $Cursor = GUIGetCursorInfo($MENU)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $MENU_1
            _Previous_Selected_Cancel()
            $MENU_SELECTED = 'Menu1'
            GUICtrlSetBkColor($MENU_1, $COLOR_SELECTED)
            _Show('Menu1')

        Case $MENU_2
            _Previous_Selected_Cancel()
            $MENU_SELECTED = 'Menu2'
            GUICtrlSetBkColor($MENU_2, $COLOR_SELECTED)
            _Show('Menu2')

        Case $MENU_3
            _Previous_Selected_Cancel()
            $MENU_SELECTED = 'Menu3'
            GUICtrlSetBkColor($MENU_3, $COLOR_SELECTED)
            _Show('Menu3')

    EndSwitch

    If $Cursor[4] = $MENU_1 Then
        If $MENU_HOVER <> 'Menu1' And $MENU_SELECTED <> 'Menu1' Then
            _Previous_Hover_Cancel()
            GUICtrlSetBkColor($MENU_1, $COLOR_HOVER)
            $MENU_HOVER = 'Menu1'
        EndIf
    ElseIf $Cursor[4] = $MENU_2 Then
        If $MENU_HOVER <> 'Menu2' And $MENU_SELECTED <> 'Menu2' Then
            _Previous_Hover_Cancel()
            GUICtrlSetBkColor($MENU_2, $COLOR_HOVER)
            $MENU_HOVER = 'Menu2'
        EndIf
    ElseIf $Cursor[4] = $MENU_3 Then
        If $MENU_HOVER <> 'Menu3' And $MENU_SELECTED <> 'Menu3' Then
            _Previous_Hover_Cancel()
            GUICtrlSetBkColor($MENU_3, $COLOR_HOVER)
            $MENU_HOVER = 'Menu3'
        EndIf
    Else
        _Previous_Hover_Cancel()
        $MENU_HOVER = 'Idle'
    EndIf

WEnd

Func _Design()
    GUICtrlSetColor($MENU_1, 0xFFFFFF)
    GUICtrlSetBkColor($MENU_1, $COLOR_STANDARD)
    GUICtrlSetCursor($MENU_1, 0)
    GUICtrlSetColor($MENU_2, 0xFFFFFF)
    GUICtrlSetBkColor($MENU_2, $COLOR_STANDARD)
    GUICtrlSetCursor($MENU_2, 0)
    GUICtrlSetColor($MENU_3, 0xFFFFFF)
    GUICtrlSetBkColor($MENU_3, $COLOR_STANDARD)
    GUICtrlSetCursor($MENU_3, 0)
EndFunc   ;==>_Design

Func _Hide_All()
    GUICtrlSetState($MENU_1_ELEMENT_1, $GUI_HIDE)
    GUICtrlSetState($MENU_2_ELEMENT_1, $GUI_HIDE)
    GUICtrlSetState($MENU_2_ELEMENT_2, $GUI_HIDE)
EndFunc   ;==>_Hide_All

Func _Show($MENU_SHOW)

    _Hide_All()

    If $MENU_SHOW = 'Menu1' Then
        GUICtrlSetState($MENU_1_ELEMENT_1, $GUI_SHOW)
    ElseIf $MENU_SHOW = 'Menu2' Then
        GUICtrlSetState($MENU_2_ELEMENT_1, $GUI_SHOW)
        GUICtrlSetState($MENU_2_ELEMENT_2, $GUI_SHOW)
    ElseIf $MENU_SHOW = 'Menu3' Then
    EndIf

EndFunc   ;==>_Show

Func _Previous_Hover_Cancel()

    If $MENU_HOVER = 'Menu1' Then
        If $MENU_SELECTED <> 'Menu1' Then GUICtrlSetBkColor($MENU_1, $COLOR_STANDARD)
    ElseIf $MENU_HOVER = 'Menu2' Then
        If $MENU_SELECTED <> 'Menu2' Then GUICtrlSetBkColor($MENU_2, $COLOR_STANDARD)
    ElseIf $MENU_HOVER = 'Menu3' Then
        If $MENU_SELECTED <> 'Menu3' Then GUICtrlSetBkColor($MENU_3, $COLOR_STANDARD)
    EndIf

EndFunc   ;==>_Previous_Hover_Cancel

Func _Previous_Selected_Cancel()
    If $MENU_SELECTED = 'Menu1' Then GUICtrlSetBkColor($MENU_1, $COLOR_STANDARD)
    If $MENU_SELECTED = 'Menu2' Then GUICtrlSetBkColor($MENU_2, $COLOR_STANDARD)
    If $MENU_SELECTED = 'Menu3' Then GUICtrlSetBkColor($MENU_3, $COLOR_STANDARD)
EndFunc   ;==>_Previous_Selected_Cancel

 


Quote
Destiny is a name often given in retrospect to choices that had dramatic consequences.  J.K. Rowling

 

Share this post


Link to post
Share on other sites

There is no flickering here cause it's just an example of how I work around with multiple menus and elements. Try to add to this 5 more menus and 100+ elements, it will go crazy. :( This is why I want to discover another method of doing these better and optimized.


Quote
Destiny is a name often given in retrospect to choices that had dramatic consequences.  J.K. Rowling

 

Share this post


Link to post
Share on other sites
1 minute ago, _Vlad said:

Try to add to this 5 more menus and 100+ elements, it will go crazy.

Could you upload an example of that kind of script so I can see what is the issue.

Share this post


Link to post
Share on other sites
8 minutes ago, _Vlad said:

Try to add to this 5 more menus and 100+ elements, it will go crazy. :( 

Please provide an example with e.g. 10 menus and 100+ elements. This saves us time to create it ourselves ;).

EDIT : Oh, @Nine was a bit faster :lol:.

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Share this post


Link to post
Share on other sites

Is the same thing as the example above just with more menus and elements.

The whole way I do this is wrong, that's the problem. I want to find another way to create menus and elements more stable.


Quote
Destiny is a name often given in retrospect to choices that had dramatic consequences.  J.K. Rowling

 

Share this post


Link to post
Share on other sites

If it's necessary, give me a few minutes I will upscale this.


Quote
Destiny is a name often given in retrospect to choices that had dramatic consequences.  J.K. Rowling

 

Share this post


Link to post
Share on other sites
3 minutes ago, _Vlad said:

If it's necessary, give me a few minutes I will upscale this.

Yes, that would at least give us an impression of how strong the flickering is.


Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Share this post


Link to post
Share on other sites

It's difficult to rebuild as an example as I have a big source code file, that I am not allowed to put here.

Let me put that problem different,

How would you build multiple menus with many elements, different than this?

I try to search different solutions for optimizing a form with many elements, that's all or some multiple methods of building it more stable.


Quote
Destiny is a name often given in retrospect to choices that had dramatic consequences.  J.K. Rowling

 

Share this post


Link to post
Share on other sites

Here is an example from @Melba23  :  creating-menus-using-arrays

Example from Melba23 :
https://www.autoitscript.com/forum/topic/136975-creating-menus-using-arrays/?do=findComment&comment=958203
#ce

#include <GUIConstantsEx.au3>

; Create an array to hold the menu items when created
Global $aMenuItems[1][2] = [[0]]

; Declare ini file
$sIni = @ScriptDir & "\Melba23.ini"

; Create GUI
$hGUI = GUICreate("Test", 500, 500)

; And start the menu creation process
_Fill_Menu(0, "MenuTitles")

GUISetState()

While 1

    ; Get the control ID
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            ; Loop through the array to see ifit is a menuitem controlID
            For $i = 1 To $aMenuItems[0][0]
                If $aMenuItems[$i][0] = $iMsg Then
                    ; It is!
                    MsgBox(0, "Menu", "You clicked " & @CRLF & $aMenuItems[$i][1])
                    ; No point in looking further
                    ExitLoop
                EndIf
            Next
    EndSwitch

WEnd



Func _Fill_Menu($hCID, $sText)

    ; Read next level down
    $aMenu = IniReadSection($sIni, $sText)
    If Not @error Then
        ; Now either create a further submenu or a menuitem
        For $i = 1 To $aMenu[0][0]
            Switch $aMenu[$i][0]
                Case "Item"
                    ; Increase the count of menuitems
                    $aMenuItems[0][0] += 1
                    ; Increase the array size by adding a new element
                    ReDim $aMenuItems[$aMenuItems[0][0] + 1][2]
                    ; Add the ControlID and text to the newly created array element
                    $aMenuItems[$aMenuItems[0][0]][0] = GUICtrlCreateMenuItem(StringReplace($aMenu[$i][1], "_", " "), $hCID)
                    $aMenuItems[$aMenuItems[0][0]][1] = StringReplace($aMenu[$i][1], "_", " ")
                Case "Menu"
                    ; Create menu
                    If $hCID Then
                        ; It is a submenu
                        $aMenu[$i][0] = GUICtrlCreateMenu(StringReplace($aMenu[$i][1], "_", " "), $hCID)
                    Else
                        ; It is a top level menu
                        $aMenu[$i][0] = GUICtrlCreateMenu(StringReplace($aMenu[$i][1], "_", " "))
                    EndIf
                    ; Fill menu - note this is a recursive call and we need to take care
                    _Fill_Menu($aMenu[$i][0], $aMenu[$i][1])
            EndSwitch
        Next
    EndIf

EndFunc

 

Melba23.ini


Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Share this post


Link to post
Share on other sites

Thanks for the answers but it seems my problem can't be re-created here as the source code file is too large.

I already know how to do this kind of menu, but it doesn't help me as now I work on a good looking interface and at this chapter probably I will go with GDI+.

 

Thank you one more time.

Have a good day!

Edited by _Vlad

Quote
Destiny is a name often given in retrospect to choices that had dramatic consequences.  J.K. Rowling

 

Share this post


Link to post
Share on other sites

it's simple, use GUICtrlCreateTab() and hide it  ;) 

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

;~ Global $MENU_HOVER = ''
;~ Global $MENU_SELECTED = ''
;~ Global $COLOR_STANDARD = 0x94A5E9
;~ Global $COLOR_HOVER = 0x8292d1
;~ Global $COLOR_SELECTED = 0x7584bf

Global $aLabels[18][5]
$aLabels[0][0] = UBound($aLabels) -1
SplashTextOn("..loading many things..", "..wait a sec..")
$MENU = GUICreate("Menu", 615, 437, -1, -1, -1, $WS_EX_COMPOSITED)
GUISetFont(10, 400, 0, "Arial")
For $n = 1 To $aLabels[0][0]
$aLabels[$n][0] = GUICtrlCreateButton("Menu " & $n, 8, 8 + (24 * ($n - 1)), 106, 23)
Next

$aLabels[0][1] = GUICtrlCreateTab(200,100,300,300)
GUICtrlSetState(-1, $GUI_HIDE)

For $n = 1 To $aLabels[0][0]
    $aLabels[$n][1] = GUICtrlCreateTabItem("Tab " & $n)
    For $m = 1 To 17 ; or whatever
        For $o = 1 To 5
            Switch Random(1, 5, 1)
                Case 1
                    GUICtrlCreateLabel("entry " & $n & " (" &$o & "," & $m & ")",100 + (85 * $o) , 8 + (24 * ($m - 1)), 70)
                Case 2
                    GUICtrlCreateButton("entry " & $n & " (" &$o & "," & $m & ")",100 + (85 * $o) , 8 + (24 * ($m - 1)), 70)
                Case 3
                    GUICtrlCreateInput("entry " & $n & " (" &$o & "," & $m & ")",100 + (85 * $o) , 8 + (24 * ($m - 1)), 70)
                Case 4
                    GUICtrlCreateCheckbox("entry " & $n & " (" &$o & "," & $m & ")",100 + (85 * $o) , 8 + (24 * ($m - 1)), 70)
                Case 5
                    GUICtrlCreateRadio("entry " & $n & " (" &$o & "," & $m & ")",100 + (85 * $o) , 8 + (24 * ($m - 1)), 70)
            EndSwitch
        Next
    Next
Next

GUISetState(@SW_SHOW, $MENU)

SplashOff()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case 0, -5, -6, -7, -8, -9, -10, -11
            ; save CPU
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
        Case Else
            For $n = 1 To $aLabels[0][0]
                If $nMsg = $aLabels[$n][0] Then
                    GUICtrlSetState($aLabels[$n][1], $GUI_SHOW)
                EndIf
            Next
    EndSwitch
WEnd

 

Edited by argumentum
added code

Share this post


Link to post
Share on other sites

Many thanks, @argumentum.

I will do some tests with that function and come later with an answer.

 

Have a nice day :) 


Quote
Destiny is a name often given in retrospect to choices that had dramatic consequences.  J.K. Rowling

 

Share this post


Link to post
Share on other sites

@argumentum I want to thank you. I tested that and helped me optimize.

This is a good solution.


Quote
Destiny is a name often given in retrospect to choices that had dramatic consequences.  J.K. Rowling

 

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Se7enstars
      New Modern Design UI in AutoIt in 118 line
      Please watch & like in Youtube: Link
      Full Source Code free: Link
       

    • By Fenzik
      Hello all!
      i'm searching here, cause i do'nt know where else to search..
      I'm developing some projects, mainly intended to help Blind users of computers.
       
      I'm also blind, so my guis are Ok for Screen readers, but i'm not sure, if they are good also for normal users..
       
      So I¨m searching here for somebody, interested in Autoit, which have no problem to help me a bit with designating my apps.
       
      My apps are written in Czech language, so i prefer somebody from Czech republic..
       
      If somebody want to help me, don't hesitate to contact me personaly, contacts and my projects are available on web in my profile.
       
      So thank you for potential help and i'm sorry if i missed some forum etiquette rule here.
       
      I'm not sure how it works here with searching for interested people and then contact them personaly.
       
      Fenzik
    • By GNGNUT
      Hi guys
      what i am trying to do is have My Gui LIve update Out of focus, so i can have this on a 2nd monitor streaming live updates while i continue to work on other screen, 
      i have been googling and looking at other threads about focus and stuff , but they do not seem to match what I'm after, 

      to be clear - i am not wanting to put focus on the GUI for it to auto update values, 
       
      if you have any positive feed back on the script while you read - i would be more then happy to accept - as im still building my Knowledge of this coding, 
      and stream line is always better Garbage code writing, 
       
      Kind regards 
      Gngnut
       
      #include <MemoryConstants.au3> #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $currentTime,$currentTimeValue,$v,$Label_Time,$Form1 Global $Label_C2_1,$Label_C2_2,$Label_C2_3,$Label_C2_4,$Label_C2_5,$Label_C2_6,$Label_C2_7 Global $Label_C3_1,$Label_C3_2,$Label_C3_3,$Label_C3_4,$Label_C3_5,$Label_C3_6,$Label_C3_7 ;~ Default Hight for boxs $Hight = 40 $lenght = 180 ;; As per nines comments moved out side of the While loop, AdlibRegister(UpdateTime,250) AdlibRegister(updateValues,500) AdlibRegister(Warning,250) hotkeyset ("{ESC}",Terminate) ;; <<< Used to Quit the programe $aMemStats = MemGetStats() MyGui() ;; running the GUI #Region ### START Koda GUI section ### Form= func MyGui() $ServerName=@ComputerName ; ### Change to your location of image $Image = "C:\Users\gngnut\OneDrive\Pictures\Computer.jpg" ; Creating the form With the Labels $Form1 = GUICreate("My System Status", 800, 750, 225, 173,BitOR($WS_SYSMENU,$WS_MAXIMIZEBOX,$WS_MINIMIZEBOX));$WS_POPUP)) $Pic1 = GUICtrlCreatePic($Image, 0, 0, 800, 750) ;;; #### Column 1 $Label_C1_1 = GUICtrlCreateLabel("Total load currently on RAM:", 71, 192, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C1_2 = GUICtrlCreateLabel("Total physical RAM:", 71, 248, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C1_3 = GUICtrlCreateLabel("Available physical RAM:", 71, 304, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C1_4 = GUICtrlCreateLabel("Total Page Size:", 71, 360, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C1_5 = GUICtrlCreateLabel("Available Page Size:", 71, 416, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C1_6 = GUICtrlCreateLabel("Total virtual Size:", 71, 472, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C1_7 = GUICtrlCreateLabel("Available virtual RAM:", 71, 528, 180, $Hight, BitOR($SS_CENTER,"")) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") ;;; #### Column 2 $Label_C2_1 = GUICtrlCreateLabel($aMemStats[$MEM_LOAD] & " %", 311, 192, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) $colour=0xFEF200 GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C2_2 = GUICtrlCreateLabel($aMemStats[$MEM_TOTALPHYSRAM] & ' Kb' , 311, 248, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C2_3 = GUICtrlCreateLabel($aMemStats[$MEM_AVAILPHYSRAM] & ' Kb', 311, 304, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C2_4 = GUICtrlCreateLabel($aMemStats[$MEM_TOTALPAGEFILE] & ' Kb', 311, 360, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C2_5 = GUICtrlCreateLabel($aMemStats[$MEM_AVAILPAGEFILE] & ' Kb', 311, 416, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C2_6 = GUICtrlCreateLabel($aMemStats[$MEM_TOTALVIRTUAL] & ' Kb' , 311, 472, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C2_7 = GUICtrlCreateLabel($aMemStats[$MEM_AVAILVIRTUAL] & ' Kb', 311, 528, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") ;;; #### Column 3 $Label_C3_2 = GUICtrlCreateLabel(Round($aMemStats[$MEM_TOTALPHYSRAM]/1024/1024, 2) & ' Gb', 551, 248, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C3_3 = GUICtrlCreateLabel(Round($aMemStats[$MEM_AVAILPHYSRAM]/1024/1024, 2) & ' Gb', 551, 304, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C3_4 = GUICtrlCreateLabel(Round($aMemStats[$MEM_TOTALPAGEFILE]/1024/1024, 2) & ' Gb', 551, 360, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C3_5 = GUICtrlCreateLabel(Round($aMemStats[$MEM_AVAILPAGEFILE]/1024/1024, 2) & ' Gb', 551, 416, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C3_6 = GUICtrlCreateLabel(Round($aMemStats[$MEM_TOTALVIRTUAL]/1024/1024, 2) & ' Gb', 551, 472, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_C3_7 = GUICtrlCreateLabel(Round($aMemStats[$MEM_AVAILVIRTUAL]/1024/1024, 2) & ' Gb', 551, 528, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_Server = GUICtrlCreateLabel($ServerName, 551, 600, 180, $Hight, BitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") $Label_Time = GUICtrlCreateLabel($currentTime , 71, 600, 180, $Hight, bitOR($SS_CENTER,$WS_BORDER,$SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFEF200) GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console") GUISetState(@SW_SHOWNORMAL) #EndRegion ### END Koda GUI section ### EndFunc While 1 Sleep(1000) ; sets a delay of 1 sec per 1000 WEnd ;; close down the Application func Terminate() exit EndFunc ;; Updating Time func UpdateTime() $currentTime = @HOUR&":"& @MIN &":"& @SEC ControlSetText($Form1,"",$Label_Time, $currentTime) EndFunc ;; currently changing the CPU % lable Func Warning() if $aMemStats[$MEM_LOAD] <=40 Then ; Green GUICtrlSetbkColor($Label_C2_1,0x2BFC0B) ElseIf $aMemStats[$MEM_LOAD] >40 and $aMemStats[$MEM_LOAD] <= 80 Then GUICtrlSetbkColor($Label_C2_1,0xFDBE01) Elseif $aMemStats[$MEM_LOAD] > 80 Then GUICtrlSetBkColor($Label_C2_1, 0xEE0C0C) EndIf EndFunc ;; Updating The Lable values of column 2 Only if the values change func updateValues() $aMemStats = MemGetStats() if GUICtrlRead($Label_C2_1) <> $aMemStats[$MEM_LOAD] Then ControlSetText($Form1,"",$Label_C2_1,$aMemStats[$MEM_LOAD]) endif If GUICtrlRead($Label_C2_2) <> $aMemStats[$MEM_TOTALPHYSRAM] & ' Kb' then ControlSetText($Form1,"",$Label_C2_2,$aMemStats[$MEM_TOTALPHYSRAM] & ' Kb') endif If GUICtrlRead($Label_C2_3) <> $aMemStats[$MEM_AVAILPHYSRAM] & ' Kb' then ControlSetText($Form1,"",$Label_C2_3,$aMemStats[$MEM_AVAILPHYSRAM] & ' Kb') endif If GUICtrlRead($Label_C2_4) <> $aMemStats[$MEM_TOTALPAGEFILE] & ' Kb' then ControlSetText($Form1,"",$Label_C2_4,$aMemStats[$MEM_TOTALPAGEFILE] & ' Kb') endif If GUICtrlRead($Label_C2_5) <> $aMemStats[$MEM_AVAILPAGEFILE] & ' Kb' then ControlSetText($Form1,"",$Label_C2_5,$aMemStats[$MEM_AVAILPAGEFILE] & ' Kb') endif If GUICtrlRead($Label_C2_6) <> $aMemStats[$MEM_TOTALVIRTUAL] & ' Kb' then ControlSetText($Form1,"",$Label_C2_6,$aMemStats[$MEM_TOTALVIRTUAL] & ' Kb') endif If GUICtrlRead($Label_C2_7) <> $aMemStats[$MEM_AVAILVIRTUAL] & ' Kb' then ControlSetText($Form1,"",$Label_C2_7,$aMemStats[$MEM_AVAILVIRTUAL] & ' Kb') endif EndFunc  
    • By jantograaf
      Hi all,
      I've been looking around the forum and testing different ways of getting a 'drop zone' to work in my script, but I can't seem to get any response from the event listener. Code compiles perfectly. Chaning the control from a label to an input- or edit-field doesn't change its behaviour, still no response when a file is dropped on there...
      It might just be that I am overlooking a simple detail, so I'm hoping for an extra pair of eyes here or there who can spot why this isn't working as it should. 
      I have another 3500+ lines script where I have basically the same bit of code, and it seems to work in there without problems.
      So, here it goes:
      Global $DD_GUI = GUICreate("DicomDrop",200,200,-1,-1,BitOR($WS_SYSMENU,$WS_POPUP),$WS_EX_ACCEPTFILES) GUISetBkColor(0x030303,$DD_GUI) $DD_GUI_DRAGLABEL = GUICtrlCreateLabel("",0,0,32,32,-1, $GUI_WS_EX_PARENTDRAG) $DD_GUI_DRAGIMAGE = GUICtrlCreateIcon(@ScriptFullPath,201,0,0,32,32) $DD_GUI_TITLELABEL = GUICtrlCreateLabel("DicomDrop",50,10,100,20,$SS_CENTER) GUICtrlSetFont($DD_GUI_TITLELABEL,8,$FW_SEMIBOLD,$GUI_FONTNORMAL,"Verdana") GUICtrlSetColor($DD_GUI_TITLELABEL,0xFFFFFF) $DD_GUI_CLOSE = GUICtrlCreateButton("X",174,4,24,24,$BS_FLAT) GUICtrlSetBkColor($DD_GUI_CLOSE,0x030303) GUICtrlSetColor($DD_GUI_CLOSE,0xFFFFFF) Global $DD_GUI_DROPZONE = GUICtrlCreateLabel("",10,42,180,148) GUICtrlSetState(-1,8) GUICtrlSetBkColor($DD_GUI_DROPZONE,0x181818) GUISetState(@SW_SHOW,$DD_GUI) Local $DD_MSG = 0 While 1 $DD_MSG = GUIGetMsg() Select Case $DD_MSG = $GUI_EVENT_CLOSE ConsoleWrite(@CRLF & "Debug -- Closed by GUI_EVENT_CLOSE") DD_EXIT() Case $DD_MSG = $GUI_EVENT_DROPPED If @GUI_DropId = $DD_GUI_DROPZONE Then Local $DroppedFile = @GUI_DragFile GUIDelete() ConsoleWrite(@CRLF & "Debug -- Dropped file : " & $DroppedFile) EndIf Case $DD_MSG = $DD_GUI_CLOSE ConsoleWrite(@CRLF & "Debug -- Closed by DD_GUI_CLOSEIMAGE") DD_EXIT() EndSelect WEnd Func DD_EXIT() GUIDelete($DD_GUI) Exit EndFunc If anyone has any idea whatsoever, please let me know 🙂
      Thanks in advance and kind regards,
      Jan
    • By matwachich
      Hi AutoIters!
      Here is my new UDF about GUIs: it's an enhanced mixture of Advanced InputBox (deprecated) and KODA Parser (deprecated), with additional functions.
      What you can do with it:
      Parse KODA files and directly create GUIs (_GUIUtils_CreateFromKODA) Parse a simple JSON form definition to simply create advanced InputBoxes with any amount/type of input controls (_GUIUtils_CreateFromJSON) Created GUIs are returned as Scripting.Dictionary objects, and you have helper functions to access GUIs controls by their names (_GUIUtils_HWnd, _GUIUtils_CtrlID, _GUIUtils_HCtrl ...) A function that can make a GUI created from KODA/JSON (defined by it's $oForm object) and make it a modal InputDialogBox (just like InputBox, but returns all entered data as Scripting.Dictionary object) Functions are documented, and there are some examples.
      Consider this UDF as beta, but since I'm currently using it in a small commercial project, it should become production ready in near future.
      To always get the latest code version, get it from Github (more up to date than this topic).
      Update 04/02/2020:
      New simple application example Fixed focused control handling in _GUIUtils_InputDialog Reset input values before returning from _GUIUtils_InputDialog Fixed CloseOnEsc in _GUIUtils_InputDialog Fixed Input not reset Fixed all ListBox items are selected Project now on GitHub https://github.com/matwachich/autoit-guiutils/
      Update 05/02/2020:
      Support for nodate for Date and Time input controls (pass null value) New handling of focused control _GUIUtils_InputDialog: Now, you can specify the focused control in $oInitialData by setting "controlName:focus" = True Updated documentation of _GUIUtils_InputDialog Update 07/02/2020:
      Bug corrected when setting Data input control Added: abillity to read a single input control New functions (_GUIUtils_GetInputs, _GUIUtils_WriteInputs), documentation completion. Readme file and screenshots on Github Page  
      GUIUtils.zip
×
×
  • Create New...