The code below, changes a picture RANDOMLY every 5 seconds.
The problem is that every time this happens A NEW GUI is generated with a new picture.
Please help me to understand how the GUI will stay the same and NOT re-generate and INSTEAD just the
picture changes.
Help is greatly appreciated. Thank you in advance!!
^8::
#Persistent
loop, C:\Users\hp\Pictures\positive stuff\*.JPG,0,1
tot++
redo:
Random, select, 1, %tot%
Loop, C:\Users\hp\Pictures\positive stuff\*.JPG
IfEqual, A_Index, %select%, Setenv, file, %A_LoopFileFullPath%
Gui, russ:destroy
Gui, russ: +LastFound +Owner
Gui, russ:Color, Black
Gui, russ:Add, Picture, x0 y0 w1300 h770 vPic, %file%
Gui, russ:Show, x150 y910 w1300 h770, gui name
sleep 5000
goto redo
return
return
Making a picture change RANDOMLY IN A GUI
-
- Posts: 15
- Joined: 29 May 2017, 20:31
Re: Making a picture change RANDOMLY IN A GUI
Use GuiControl to update an existing control.
What I would do is first create your GUI. Then enter in a loop to use just the GuiControl command and the Sleep 5000. Or, slightly preferably, SetTimer on a 5 second intersection.
What I would do is first create your GUI. Then enter in a loop to use just the GuiControl command and the Sleep 5000. Or, slightly preferably, SetTimer on a 5 second intersection.
-
- Posts: 15
- Joined: 29 May 2017, 20:31
Re: Making a picture change RANDOMLY IN A GUI
Hello Exaskryz, I have being playing with this for awhile. Just getting various errors.
Is it possible that you could show me a SMALL EXAMPLE so I can compare my mishaps with your small sample.
I do understand if your are tooo busy.
Thank you for the post.
Cheers
Is it possible that you could show me a SMALL EXAMPLE so I can compare my mishaps with your small sample.
I do understand if your are tooo busy.
Thank you for the post.
Cheers
Re: Making a picture change RANDOMLY IN A GUI
One thing I forgot in the loop is you'd want to repeat your Random command too.
You'll notice that I put a "blank" command in the first parameter of GuiControl. I still put the name prefix and the colon to specify which GUI I was working on (unnecessary if Russ is the default GUI, however, I have a habit of including my names always). Also notice that I used the name of the variable in the second parameter of GuiControl.
Code: Select all
Gui, Russ:Add, Picture, vPic, Tulips.jpg
Gui, Russ:Show
Sleep 2000
GuiControl, Russ:, Pic, Roses.jpg
You'll notice that I put a "blank" command in the first parameter of GuiControl. I still put the name prefix and the colon to specify which GUI I was working on (unnecessary if Russ is the default GUI, however, I have a habit of including my names always). Also notice that I used the name of the variable in the second parameter of GuiControl.
Re: Making a picture change RANDOMLY IN A GUI
Btw the #persistent directive is unecessary in your script:
source: GUIAny script that uses the GUI command anywhere is automatically persistent (even if the GUI command is never actually executed).
source: HotkeysOnce a script has at least one hotkey, it becomes persistent, meaning that ExitApp rather than Exit should be used to terminate it.
Who is online
Users browsing this forum: No registered users and 358 guests