Sign in to follow this  
Followers 0
unknown12

Looping through all images?

18 posts in this topic

Is there anyway to detect the amount of images within a GUI, then loop through them all?

I've got my image tiling sorted, but no idea what to do now to change the images with out restarting the application.

Cheers.

Share this post


Link to post
Share on other sites



:whistle:

You have created an application tiling the images and don't know how to reference them? I think you better post some code..:P

Share this post


Link to post
Share on other sites

lol, true :whistle:

Heres some code anyway:

;; Get the size of the jpg.
        $jpg_size = _ImageGetSize($taskbar_image)
        $image_horizontal = $desktop_width/$jpg_size[0]
        $image_horizontal = Ceiling($image_horizontal-1)
        
        $image_vertical = $taskbar_height/$jpg_size[1]
        $image_vertical = Ceiling($image_vertical-1)
        
        ;; Start to tile it horizontally, then vertically.
        $horizontal = 0
        $vertical = 1
        $img_num = 0
        While $horizontal <= $image_horizontal
            $offset_hori = $horizontal*$jpg_size[0]
            $img_hori = GUICtrlCreatePic($taskbar_image,$offset_hori,0,$jpg_size[0],$jpg_size[1])
            
            $img_num = $img_num+1
            
            If $image_vertical > 0 Then
            While $vertical <= $image_vertical
                $offset_vert = $vertical*$jpg_size[1]
                $img_vert = GUICtrlCreatePic($taskbar_image,$offset_hori,$offset_vert,$jpg_size[0],$jpg_size[1])
                $vertical = $vertical + 1
                $img_num = $img_num+1
            WEnd
            EndIf
            
            $vertical = 1
            $horizontal = $horizontal + 1
        WEnd

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Can you provide some code ??

Edit: Memo to me remember to refresh the browser while using tabs

Edited by Shevilie

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

How about a limiter on the horizontal?

If $horizontal=16 then $vertical += 1

EDIT: I do believe I missed the entire point, but cut me some slack it's 5:30 am :whistle:

Edited by Slaiochi

Share this post


Link to post
Share on other sites

How about a limiter on the horizontal?

If $horizontal=16 then $vertical += 1

EDIT: I do believe I missed the entire point, but cut me some slack it's 5:30 am :P

Haha :whistle:

The tiling works fine, its just changing all of the images I'm having trouble with. I know how i'd do it in php, but autoIT doesn't work like that. I'd do

$img_hori[$img_num] = createtheimage

And then loop through them with a while loop when the tiles are all done, but autoIT doesn't support having a variable within a variable name (afaik).

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Eval

Return the value of the variable defined by an string.

Eval ( string )

Dim $a_b = 12
$s = Eval("a" & "_" & "b")  ; $s is set to 12

$s =Eval("c")  ; $s = "" and @error = 1
Edited by Shevilie

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

Thanks, but I can't see how that would help in this situation?

Share this post


Link to post
Share on other sites

but autoIT doesn't support having a variable within a variable name (afaik).


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

Might be better to load them into arrays, like pic[0] = "blahwhateverimage.jpg"

then for i = 0 to 30

loadimage ("pic")

I know i didn't even use correct syntax, but again, it's early

Share this post


Link to post
Share on other sites

Can't do that. They're all the same picture, and I'd have to have a variable within the variable name. I still don't see how eval would help, because $a_b would need to be $a_$b.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Haha :(

The tiling works fine, its just changing all of the images I'm having trouble with. I know how i'd do it in php, but autoIT doesn't work like that. I'd do

$img_hori[$img_num] = createtheimage

And then loop through them with a while loop when the tiles are all done, but autoIT doesn't support having a variable within a variable name (afaik).

Yes it does.. :shocked: I use it all the time..

AutoIt and PHP are both built on C..

Edited by Manadar

Share this post


Link to post
Share on other sites

Yes it does.. :shocked: I use it all the time..

AutoIt and PHP are both built on C..

Can you give an example? It didn't work when i tried it :(

Share this post


Link to post
Share on other sites

Hope this helps you...

Dim $Button[5][5]

GUICreate("Test GUI", 250, 250)

For $x = 0 to 4
    For $y = 0 to 4
        $Button[$x][$y] = GUICtrlCreateButton("( " &$x&","&$y&" )",$x*50,$y*50,50,50)
    Next
Next

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    If $nMsg = -3 Then ExitLoop
    
    For $x = 0 to 4
        For $y = 0 to 4
            If $nMsg = $Button[$x][$Y] Then
                MsgBox(0x40, "Test Data", "$x = " & $x & @CRLF & _
                "$y = " & $y & @CRLF & _ 
                "$Button[$x][$y] = " & $Button[$x][$Y])
            EndIf
        Next
    Next
WEnd

Share this post


Link to post
Share on other sites

Cheers, works perfect!

Didn't know that it had to be declared at the top (Dim $Button[5][5])

Share this post


Link to post
Share on other sites

One more question, is it possible to delete GUI controls?

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  
Followers 0