Jump to content

Looping through all images?


Recommended Posts

: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

Link to comment
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
Link to comment
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).

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...