Sign in to follow this  
Followers 0
PickPocketz

Interacting with Multiple Controls

2 posts in this topic

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)
GUISetBkColor(0x000000)
$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)
GUISetState()
GUICreate($title & " Vars:", 200, 400, @DesktopWidth - 205, 0)
$mProdX = GUICtrlCreateLabel("X Change: ", 5, 5, 190, 20)
$mProdY = GUICtrlCreateLabel("Y Change: ", 5, 25, 190, 20)
GUISetState()
While 1
$msg = GUIGetMsg()
$uArray = UBound($Array)

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

WEnd
Func drag_screen()
$ii = 0
For $i = 0 To $uArray - 1 Step 1
  $_mouse = MouseGetPos()
  $mArray[0] = $_mouse[0]
  $mArray[2] = $_mouse[1]
 
  Sleep(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])
 
Do
 
  GUICtrlSetPos($Array[$i], $_Array[0] + $mArray[4], $_Array[1] + $mArray[5])
  $ii += 1
 
Until $ii = $uArray - 1
 
  $ii = 0
 
Next
EndFunc
Func end()
Exit
EndFunc

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

  • Similar Content

    • 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:
      https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateTab.htm
      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  
    • Jefrey
      By Jefrey
      Hi all!
      I've made this small UDF to emulate multithreading for AutoIt3.
      As we know, AU3 is singlethread and multithreading is only possible through direct ASM. This UDF provides a multithreading emulation through running multiple instances of your script. It also provides an easy way for sending and receiving messages between threads (temporary files are used).
      Example:
      Example 2:
      Docs:
      Download:
      Github ZIP
      Fork me on Github