Sign in to follow this  
Followers 0
magace

Help get center between two points

5 posts in this topic

Hello I need to find the center of two points I am using this to get my first position:

Local $pos1 = MouseGetPos() ;CENTER OF AUTOSN

And This to get my second position:

Local $pos2 = MouseGetPos() ;CENTER OF SN

Here is where it would need to get the center:

Local $pos3 = $pos1 (what ever formula to get center) $pos2 ;I need help here

My code:

Local $pos1 = MouseGetPos() ;CENTER OF AUTOSN
_GDIPlus_Startup()
$hImageA =_GDIPlus_ImageLoadFromFile($fileJ) ;this is the SN
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)
$x = 0
$y = 0
$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0) ;Zero will search against your active screen
If $result > 0 Then
   ToolTip("FOUND SN",0,0)
   $go4 = 4
MouseMove($x, $y)
Local $pos2 = MouseGetPos() ;CENTER OF SN
_GDIPlus_ImageDispose($hImageA)
    _GDIPlus_Shutdown()
 Else
 ToolTip("CANT FIND SN",0,0)
  SLEEP(200)
  _GDIPlus_ImageDispose($hImageA)
       _GDIPlus_Shutdown()
EndIf
Local $pos3 = $pos1 (what ever formula to get center) $pos2    ;I need help here
mouseclick("Left",$pos3[0],$pos3[1],2)                         ;Should click center
sleep(200)
SEND("^c")
sleep(200)
Global $text2 = ClipGet() 
sleep(200)

Share this post


Link to post
Share on other sites

https://www.purplemath.com/modules/midpoint.htm


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

magace,

For each axis, add the 2 coordinate values for the known points and divide the result by 2 - you may want to Int the result. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

magace,

For each axis, add the 2 coordinate values for the known points and divide the result by 2 - you may want to Int the result. ;)

M23

Thanks this worked great!!

Local $pos = $pos1[0] + $pos2[0]

Local $poss = $pos1[1] + $pos2[1]

Local $pos4 = $pos * .5 ;I need help here

Local $pos44 = $poss * .5

mouseclick("Left",$pos4,$pos44,2)

IDK If it was the best way to do it but it works!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Do it all at once. Remember to properly encase the addition in parenthesis otherwise standard order of operations will mess up your calculations.

Local $pos = Int(($pos1[0]+$pos2[0]) / 2)
Local $poss = Int(($pos1[1]+$pos2[1]) / 2)
MouseClick("Primary",$pos, $poss,2)
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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