Jump to content
algiuxas

How to move all controls fast?

Recommended Posts

Hello, I need help, I have created couple small pictures(about 200) in one GUI, I need to move them fast about 1-5 pixels every picture somehow. There are only pictures in GUI, no other controls. I tried this, but it's too slow:

Global Const $AC_SRC_ALPHA = 1

For $ii = 0 To $size
    For $iii = 0 To $size
        GUICtrlSetPos(_ArrayGet($data, $ii, $iii, 1), ControlGetPos($GUI, "", _ArrayGet($data, $ii, $iii, 1))[0] + 2, ControlGetPos($GUI, "", _ArrayGet($data, $ii, $iii, 1))[1] + 2)
    Next
Next

Func _ArrayGet(ByRef $aArray, $i1, $i2 = 0, $i3 = 0, $i4 = 0, $i5 = 0, $i6 = 0, $i7 = 0, $i8 = 0, $i9 = 0, $i10 = 0, $i11 = 0, $i12 = 0, $i13 = 0, $i14 = 0, $i15 = 0, $i16 = 0, $i17 = 0, $i18 = 0, $i19 = 0, $i20 = 0)
    ;Function made by ProgAndy

    Local $iDims = UBound($aArray, 0)
    #forceref $i1, $i2, $i3, $i4, $i5, $i6, $i7, $i8, $i9, $i10, $i11, $i12, $i13, $i14, $i15, $i16, $i17, $i18, $i19, $i20
    Local $NULL
    If Not IsArray($aArray) Then Return SetError(1, 1, $NULL)
    Local $sAccess = "$aArray"
    For $i = 1 To $iDims

        Local $iIndex = Int(Eval("i" & $i))
        If $iIndex >= UBound($aArray, $i) Then Return SetError(3, $i, $NULL)
        $sAccess &= '[' & $iIndex & ']'
    Next
    If @NumParams - 1 > $iDims Then
        For $i = $iDims - 1 To @NumParams

            $sAccess &= ", $i" & $i

        Next
        Local $vResult = Execute("_ArrayGet(" & $sAccess & ")")
        If @error Then SetError(@error, @extended + $iDims)
        Return $vResult

    Else
        Return Execute($sAccess)



    EndIf



EndFunc   ;==>_ArrayGet

I didn't wrote all script, becouse it's huge. It took about 1200 - 1600 milisecounds, I need that pictures would move much faster. It's possible to make it much faster, that it would took about 2-10 milisecounds? Thanks.

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites

algiuxas,

Welcome to the AutoIt forums.

When you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.

Now off to look at the code itself.

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

algiuxas,

This simplifies the data storage and runs much faster on my machine - how about yours?

HotKeySet("{ESC}", "_Exit")

Global $aData[200][3]

$hGUI = GUICreate("Test", 500, 500)

For $ii = 0 To 19
    For $iii = 0 To 9
        $iIndex = ($ii * 10) + $iii
        $iX = 10 + ($ii * 10)
        $iY = 10 + ($iii * 10)
        $aData[$iIndex][0] = GUICtrlCreateLabel("", $iX, $iY, 8, 8)
        GUICtrlSetBkColor($aData[$iIndex][0], 0xFF0000)
        $aData[$iIndex][1] = $iX

        $aData[$iIndex][2] = $iY

    Next
Next

GUISetState()

For $j = 0 To 100

    $nBegin = TimerInit()
    For $i = 0 To 199
        $iX = $aData[$i][1] + 2
        $iY = $aData[$i][2] + 2
        GUICtrlSetPos($aData[$i][0], $iX, $iY)
        $aData[$i][1] = $iX

        $aData[$i][2] = $iY

    Next
    ConsoleWrite(TimerDiff($nBegin) & @CRLF)

Next

Func _Exit()
    Exit
EndFunc

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

How about using something like this in the loop (not sure in which include the function is in the current au3 release though :whistle:)?

Local $hWinPosInfo
For $j = 0 To 100
    $nBegin = TimerInit()
    $hWinPosInfo = _WinAPI_BeginDeferWindowPos(200)
    For $i = 0 To 199
        $iX = $aData[$i][1] + 2
        $iY = $aData[$i][2] + 2
        _WinAPI_DeferWindowPos($hWinPosInfo, $aData[$i][3], $HWND_TOP, $iX, $iY, 0, 0, BitOR($SWP_NOSIZE, $SWP_NOACTIVATE))
        $aData[$i][1] = $iX
        $aData[$i][2] = $iY
    Next
    _WinAPI_EndDeferWindowPos($hWinPosInfo)
    ConsoleWrite(TimerDiff($nBegin) & @CRLF)
Next

 

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

  • Similar Content

    • By nacerbaaziz
      hello sirs, please i created a tool witch get the focused control in a window and play a audio file linked with this controls
      e.g buttons, checkBoxes, radios, comboboxes, and others
      i know that their is a function that give us the control focus but it return the classNN
      i want to get the class name to use it with a switch and
      because their are more than class e.g button tbutton timagebutton tnewButton...
      please can any one help me to get the class name not the classnn
      thanks in advance
    • By nacerbaaziz
      Hello my friends
      Can we create a single context menu on more than one item?
      For example, a context menu includes standardized options on more than one control, such as buttons or check boxes
      to Create a context menu on one item am using this function
      GUICtrlCreateContextMenu ($ HWND)
      How to link it with more than one element please?
      or if we can't do that, please give me a solution
      so i tried to add an context menus to all the controls but the script will be long, for that if their are any solutions i hope to give it to me
      thanks in advanced
    • By TheAutomator
      Is there a (simple) way to make your script using a picture-control to resize the gui?
      This would be useful for a transparant pop-up window with a custom made theme using picture controls:
      $Form = GUICreate('', 301, 173, 5, 5, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUICtrlCreatePic(@scriptdir & "\resize_win.bmp", 0, 73, 20, 51) ; some api call or code telling the os to use this picture as a resize border GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) GUISetState(@SW_SHOW) While True if GUIGetMsg() = $GUI_EVENT_CLOSE then Exit WEnd  
      EDIT: to make it more clear what i wanna do, if you go with the mouse arrow over the border of a re-sizable window the arrow changes to a "resize" arrow, you click and drag the border and then the window size adjusts to the mouse position until you release the mouse button.
      I want my picture control to be used the same way as the resize border to resize my window.
    • By ur
      An application is there which is created using vc++,mostly mfc.
       
      DOn't know the details completely.
       
      WHen I try to automate the control clicks for testing the UI.
      THe below control is not detected.
      As you can see, during UI operations I can click the elements one by one.
      But all the elements is selected as a whole set, when I use the Windowinfo tool.

       
      How to click this using AutoIT.?
       
      Please suggest.
×
×
  • Create New...