Jump to content
Sign in to follow this  

Interacting with Multiple Controls

Recommended Posts


I'm working on a new project that is going to immitate a RPG I play online. It's a pretty simple Isometric/Tile Based project and I am trying to figure out how to target all the controls on the screen (mainly pic controls) so that when I click and drag they all will move in the same fashion. I know I could go through and specifically pick on each control but I was looking for a way to grab them all in a general manner without pointing out each variable name. I figure I could put them all in an array and some how loop through the array but If there is a quicker means to this I would love to know how. I've searched through the forum but I think the words I search are just too general. Any help?

Share this post

Link to post
Share on other sites

Well I've set it up using an array but I'm having timing problems. While moving the mouse the controls don't follow through correctly...

Here is an example of my script:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
HotKeySet("{ESC}", "end")
Const $title = "_Project"
$wX = @DesktopWidth / 3
$wY = @DesktopHeight / 3
Dim $Array[3]
Dim $mArray[6]
GUICreate($title, $wX, $wY, 0, 0)
$Array[0] = GUICtrlCreatePic(@ScriptDir & "ball_red_01.jpg", 50, 100, 30, 30)
$Array[1] = GUICtrlCreatePic(@ScriptDir & "ball_red_01.jpg", 100, 100, 30, 30)
$Array[2] = GUICtrlCreatePic(@ScriptDir & "ball_red_01.jpg", 150, 100, 30, 30)
GUICreate($title & " Vars:", 200, 400, @DesktopWidth - 205, 0)
$mProdX = GUICtrlCreateLabel("X Change: ", 5, 5, 190, 20)
$mProdY = GUICtrlCreateLabel("Y Change: ", 5, 25, 190, 20)
While 1
$msg = GUIGetMsg()
$uArray = UBound($Array)

case $msg = $GUI_EVENT_CLOSE
case _IsPressed(01)
case _isPressed(20)
  MsgBox(2, $title, $uArray, 10)

Func drag_screen()
$ii = 0
For $i = 0 To $uArray - 1 Step 1
  $_mouse = MouseGetPos()
  $mArray[0] = $_mouse[0]
  $mArray[2] = $_mouse[1]
  $_mouse = MouseGetPos()
  $mArray[1] = $_mouse[0]
  $mArray[3] = $_mouse[1]

  $mArray[4] = $mArray[0] - $mArray[1]
  $mArray[5] = $mArray[2] - $mArray[3]
  GUICtrlSetData($mProdX, "X Change: " & $mArray[4])
  GUICtrlSetData($mProdY, "Y Change: " & $mArray[5])
  $_Array = ControlGetPos($title, "", $Array[$i])
  GUICtrlSetPos($Array[$i], $_Array[0] + $mArray[4], $_Array[1] + $mArray[5])
  $ii += 1
Until $ii = $uArray - 1
  $ii = 0
Func end()

Ofcourse you will have to fit in your own pictures and change the directory if you wish to run it.

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  

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      I have a query please
      It is about windows file explorer
      If i design a tool in autoit language to delete files for example
      and i  added it in the context menu in File Explorer
      If i right-click on any file And you choose the tool, it will be get the path of the selected file or folder
      The problem here is
      If i select a set of files or folders
      it only detect the first one
      The code that i  used is
      if $CMDLine[0] = 0 then
      msgBox(16, "error", "you don't selecte any files")
      for $i = 1 to $CMDLine[0]
      msgBox(0, "files", $CMDLine[$i]
    • Miliardsto
      By Miliardsto
      Im creating a tab
      Global $Tab1 = GUICtrlCreateTab(30, 30, 600, 420, $TCS_BUTTONS, -1) And what we see in the function reference:
      GUICtrlCreateTab ( left, top [, width [, height [, style = -1 [, exStyle = -1]]]] ) ok in 5 arg I got $TCS_BUTTONS
      But How can I use multiple args like this below
      Global $Tab1 = GUICtrlCreateTab(30, 30, 600, 420, [$TCS_BUTTONS, $TCS_MULTILINE], -1)  
    • XinYoung
      By XinYoung
      Hello all,
      I've been working on 4 standalone scripts. They each have their own GUI and are now independent .exe's. But instead of having 4 separate icons on my computer, is it possible to put them all together into one .exe?
      What I want is one interface with tabs. Each script's GUI would be on their own respective tab. Is this possible?
      The different scripts don't need to communicate with one another. I just want them all in one .exe.
      I can't find this anywhere... Any help would be greatly appreciated. Thank you!
    • kawliga751
      By kawliga751
      I am trying to script the opening of multiple tabs in IE with each tab having a separate login/password. I have been able to make a successful script that will open 3 separate IE sessions with the correct webpage and login or a script that will open 3 tabs in one session (which I want) but will not login. I have tried _IECreate, IEAttach etc. This is the script I am currently using . 
      #include <IE.au3> Const $navOpenInNewTab = 0x0800 Dim $oIE = _IECreate('http://asag.xxxxxxx.com/AAAA/index.htm') ;$o_IE.Navigate2('http://asag.xxxxxxx.com/apps/yyyyyyy/LogInSAG/login.asp', $navOpenInNewTab) ;$o_IE.Navigate2('http://asag.xxxxxxx.com/apps/yyyyyyy/LogInSAG/login.asp', $navOpenInNewTab) Call ("YYYYYYYSignIn") Func YYYYYYYSignIn () Local $username = _IEGetObjByName ($oIE,"uname") Local $password = _IEGetObjByName ($oIE,"pword") $oIE.Navigate2('http://asag.xxxxxxx.com/apps/xxxxxxx/LogInSAG/login.asp',2048) _IEFormElementSetValue ($username, "xxxxxxx") _IEFormElementSetValue ($password, "xxxxxxx") Send('{Enter}') EndFunc Call ("xxxxxxxSignIn") Func xxxxxxxSignIn () __IENavigate($oIE, "https://soa1gui.xxxxxxx.biz/gateway/NFServlet;jsessionid=1E3B8F6520DE0A1EC914A8ABB7E86341?NFH_MessageId=&NFH_Page=%2fpages%2fsearch%2fsearch.jsp", 1, 0x800) Local $domain = _IEGetObjByName ($oIE,"NF_CustomerID") Local $User_Name = _IEGetObjByName ($oIE,"NF_UserName") Local $Password = _IEGetObjByName ($oIE,"NF_Password") _IEFormElementSetValue ($domain, xxxxxxx") _IEFormElementSetValue ($User_Name, "xxxxxxx") _IEFormElementSetValue ($Password, "xxxxxxx") ;Send('{Enter}') EndFunc  
    • Phoenixx177
      By Phoenixx177
      I've tried to wrap my head around it but just can't imagine how to embed 2 IE browsers in the same GUI.
      Here's what I'm doing so far.
      #include <GuiConstantsEx.au3> #include <windowsconstants.au3> #include <IE.au3> Global $oIE = _IECreateEmbedded() ; Create a simple GUI for our output Global $hGUI = GUICreate("Embedded Web control Test", 1280, 580, (@DesktopWidth - 1280) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN, $WS_MAXIMIZEBOX)) Global $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 1100, 500) _IENavigate($oIE, "http://xxxxxxxxxx.com") Global $o_doc = _IEDocGetObj($oIE) $o_doc.DocumentElement.ScrollTop = 140 $o_doc.DocumentElement.ScrollLeft = 170 GUISetState() While GUIGetMsg() <> -3 WEnd