Jump to content
Sign in to follow this  
Edifice

Guiupdate

Recommended Posts

Edifice

Sorry to shower you guys with questions, but I just hit so many dead ends during the last couple of learning auto-it-days and your answers are just great! :)

#Include <Date.au3>
#Include <GuiStatusBar.au3>
#include <GuiConstantsEx.au3>

Dim $progress = 0

; GUI
GuiCreate("Windows Update Cleanup", 500, 100)

; PROGRESS
GUICtrlCreateLabel("Progress...",65, 40, 400, 20, 1)
GuiCtrlCreateProgress(65, 10, 400, 20)
GuiCtrlSetData(-1, $progress)
GUISetState(@SW_SHOW)

After drawing this lovely little GUI-Window i used GuiCtrlSetData(-1, $progress) to update the progressbar, and it works flawlessly, but I know it's not the right way to go, as you would then only be able to update one GUI-item in the entire window (this being the last one created).

My question is then, how do I update several GUI-thingy's?

Share this post


Link to post
Share on other sites
youknowwho4eva

I'm lost as to what you want to do that it's not doing?


Giggity

Share this post


Link to post
Share on other sites
Authenticity

Use the returned control ID and then use it...

Share this post


Link to post
Share on other sites
SpookMeister

Assign variables to hold the Control ID's of the GUI items you are creating, then you can later reference them

#Include <Date.au3>
#Include <GuiStatusBar.au3>
#include <GuiConstantsEx.au3>

Dim $progress = 0

; GUI
GuiCreate("Windows Update Cleanup", 500, 100)

; PROGRESS
$label=GUICtrlCreateLabel("Progress...",65, 40, 400, 20, 1)
$prog=GuiCtrlCreateProgress(65, 10, 400, 20)
GuiCtrlSetData($prog, 25)
GUISetState(@SW_SHOW)

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
Edifice

A bit lower down I used

While $progress < 10
    ; Increase the count by one
        $progress = $progress + 1 
        GuiCtrlSetData(-1, $progress)
        Sleep(50)
    Wend

To update the progressbar, but the funny thing is that if I draw the label after the progressbar, the $progress goes into the label instead.

Share this post


Link to post
Share on other sites
Melba23

Edifice,

Using -1 in GUICtrlSetData (or any other similar function) is shorthand for the last control created.

If you want to reference any other controls then you need to assign a variable to hold the Control ID when it is created:

$hLabel = GUICtrlCreateLabel(......)

and then use that variable to reference the control later on:

GUICtrlSetData($hLabel, ....)

You can now address as many controls as Autoit can manage (65532 to save you the trouble of looking it up!)

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
Edifice

Now just a bonus question.

How do I set my window as "Always on top"?

Share this post


Link to post
Share on other sites
Authenticity

Use GuiCreate('Text', 200, 185, 10, 100, -1, $WS_EX_TOPMOST)

$WS_EX_TOPMOST is defined in WindowsConstants.au3

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.