Jump to content
Sign in to follow this  

Refreshing the GUI

Recommended Posts


Alright, I've got a problem.

Say, I've got some "ini" files which the script reads to show the output for some information.

However, lets say I want to go to the next section in the ".ini" when I press a button, how would I do that?

I've tried for so long now and I cannot figure it out :D

The GUI doesn't seem to read the value for the next section and replace it with the information from the old section in the ".ini".

So I thought I might have to refresh the GUI somehow, or is there anything else I should do?

To make it easier with an example, take this:

I have two images in a folder, named "1.jpg" and "2.jpg".

I have a gui which shows the image "1.jpg" by default when I run the GUI.

Also under the image on the gui, there is a button. When I press that, I want it to show the next number, "2.jpg".

So lets say I have GuiCtrlCreatePic("data\monsterdb\img\"&$mdb_page&".jpg", 215, 10, 350, 200)

where $mdb_page = 1

So when I press the button, it adds +1 to the $mdb_page variable (how do I do that? Using $mdb_page = +1 didn't work :D) so that it shows the next image.

However, it doesn't.

That's why I thought I have to refresh it somehow, right?


I know I am really horrible at this so you don't have to tell me. :D

I just want to have this little project for fun.



Share this post

Link to post
Share on other sites

The more you learn, the more fun AutoIt can be.

First off, to add a number to a value, you have two options, the latter one being the quickest and easiest:

$x = $x + 1
$x += 1

These both give you the same result. Your next question was how to "refresh" an image. Unless you are using GDI+, which you aren't, there is no reason to refresh an image. I think you meant how to change an image. You need this.

$mdb_page = 1
$Picture = GuiCtrlCreatePic("data\monsterdb\img\"&$mdb_page&".jpg", 215, 10, 350, 200)
$mdb_page = 2 ;or $mdb_page += 1
GuiCtrlSetImage($Picture, "data\monsterdb\img\"&$mdb_page&".jpg")

If you need a more in depth explanation, go to the help file. If you still have questions, come back and tell us what you have tried.

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post

Link to post
Share on other sites

Thank you sir for your help.

However, I seem not to be fully understandable, which I can tell now as I wrote this 2 am last night (aren't all used to code at night? :D).

Let us give this code you gave me a shot.

$mdb_page = 1
$Picture = GuiCtrlCreatePic("data\monsterdb\img\"&$mdb_page&".jpg", 215, 10, 350, 200)
$mdb_page = 2 ;or $mdb_page += 1
GuiCtrlSetImage($Picture, "data\monsterdb\img\"&$mdb_page&".jpg")

Ok, now this code below is taken from my gui script.

While 1
        $msg = GUIGetMsg()
            Case $msg = $GUI_EVENT_CLOSE
            Case $msg = $mdb_next
                $mdb_page += 1
            Case $msg = $mdb_prev   
                MsgBox  (0, "test" ,$mdb_page)

Don't mind the MsgBox, it's just for testing.

As you can tell, whenever I press the "next" button (which is located on my GUI) the $mdb_page will count +1. Now that is working thanks to you (though I should have known how to do that :D).

However, I also have an image, a picture in my gui and it's named $mdb_page.jpg.

So therefore I use:

GuiCtrlCreatePic("data\monsterdb\img\"&$mdb_page&".jpg", 215, 10, 350, 200)

So when I run my script which opens the GUI, the image "data\monsterdb\img\1.jpg" is being showed.

Though, now I want to press the next button so that the next image (2.jpg) can be shown.

So I press the "next" button, and check if the count has gotten +1 by using the MsgBox which it has, but the image is still 1.jpg.

That's why I need something to "refresh" or "re-read" the script each time that button being pressed.

Do you get me?

I also have this trouble with "IniRead", as the script needs to "re-read" the "IniRead" lines to spit out some information.

Basically, I have a ini file located in "data\monsterdb\ini\mdb.ini", with two sections.

It look like this:


test=Number 1


test=number 2

So when I press the button, I also want the script to show the output of the next section in my INI file (this is also used with $mdb_page).

I use this in my script:

$mdb_test = IniRead ("data\monsterdb\ini\mdb.ini", $mdb_page, "test", "value not found") ; Her blir $mdb_page 1+N hvor N er nummer pages som går.

However, when I push my button the output is still from the [1] section.

That's why I also need the script to "re-read" this whenever I push the button.

I've looked in the help file but I really don't know what I am looking after to be honest. :D

So, if anyone is so kind and actually understand my trouble here then please help me out.



Super edit:

Alright, so I guess I just have to put this in under my $Msg = $mdb_next section which tells the script what to do when I press the button.

Though, it will look really bad as I have a million of lines to be read. :D

So! If there is another way of doing this, please tell me :D

Second super edit:

Or maybe I can have it as a function and just put the function name there. I'll try.

Ok, so I found out a way of doing this.

I am using the GuiCtrlSet commands, though it is going to look messy.

Maybe later when I got some more progress I can post it here in case anyone can make it a little unmessier (that's not a word).

Edited by tW34k

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