tW34k Posted August 28, 2009 Share Posted August 28, 2009 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 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 ) so that it shows the next image. However, it doesn't. That's why I thought I have to refresh it somehow, right? Anyways... I know I am really horrible at this so you don't have to tell me. I just want to have this little project for fun. Thanks, Pat. Link to comment Share on other sites More sharing options...
dantay9 Posted August 28, 2009 Share Posted August 28, 2009 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. Link to comment Share on other sites More sharing options...
tW34k Posted August 28, 2009 Author Share Posted August 28, 2009 (edited) 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? ). 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() Select Case $msg = $GUI_EVENT_CLOSE exitloop Case $msg = $mdb_next $mdb_page += 1 Case $msg = $mdb_prev MsgBox (0, "test" ,$mdb_page) EndSelect WEnd 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 ). 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: [1] test=Number 1 [2] 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. So, if anyone is so kind and actually understand my trouble here then please help me out. Thanks, Pat. 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. So! If there is another way of doing this, please tell me 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 August 28, 2009 by tW34k Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now