Jump to content

Recommended Posts

Posted

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.

Posted

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

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
Posted

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).

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

Posted

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

Posted

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.

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
Posted

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

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
  • Recently Browsing   0 members

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