magace Posted March 19, 2013 Share Posted March 19, 2013 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) Link to comment Share on other sites More sharing options...
Blue_Drache Posted March 19, 2013 Share Posted March 19, 2013 https://www.purplemath.com/modules/midpoint.htm Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 19, 2013 Moderators Share Posted March 19, 2013 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
magace Posted March 19, 2013 Author Share Posted March 19, 2013 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! Link to comment Share on other sites More sharing options...
Blue_Drache Posted March 19, 2013 Share Posted March 19, 2013 (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 March 19, 2013 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now