Bibopp Posted April 13, 2019 Share Posted April 13, 2019 (edited) Hello, I’m looking to recover the $x and $y values of $xy to get coordinates. I’ve tried everything a bit but it doesn’t give me anything. Can you help me, please? Here is an example with StringSplit: expandcollapse popupFunc FromNostoScreenCoords($_x, $_y) $aCurrentLoc = 37.25;GetCurrentPosMem($x, $y) ; $aCurrentLoc = 37.25 $CurrentLoc = StringSplit($aCurrentLoc, ".") MsgBox($MB_SYSTEMMODAL, "CurrentLoc", $CurrentLoc) ;; // = nothing Why ? $xd = $_x - $CurrentLoc[1] $yd = $_y - $CurrentLoc[2] $w = -0.515 * $xd + -0.514 * $yd + -0.686 $x = (-1.682 * $xd + 1.683 * $yd + 0) / $w $y = (-1.54 * $xd + -1.539 * $yd + 2.307) / $w $Z = (-0.515 * $xd + -0.514 * $yd + -0.686) / $w $x = ($x + 1) / 2 * 800 $y = (1 - $y) / 2 * 600 ;; Handle out of screen scenarios While $x >= 800 Or $y >= 600 Or $x <= 0 Or $y <= 0 $xd = $xd / 2 $yd = $yd / 2 $w = -0.515 * $xd + -0.514 * $yd + -0.686 $x = (-1.682 * $xd + 1.683 * $yd + 0) / $w $y = (-1.54 * $xd + -1.539 * $yd + 2.307) / $w $Z = (-0.515 * $xd + -0.514 * $yd + -0.686) / $w $x = ($x + 1) / 2 * 800 $y = (1 - $y) / 2 * 600 WEnd Dim $return[2] $return[0] = $x $return[1] = $y Return $return MsgBox($MB_SYSTEMMODAL, "FromNostoScreenCoords", $return) ; ; // = nothing Why ? EndFunc ;==>FromNostoScreenCoords Edited April 13, 2019 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 13, 2019 Moderators Share Posted April 13, 2019 Bibopp, Your MsgBoxes show nothing because you are attempting to show an array - which is what is returned by StringSplit in $CurrentLoc and explicitly defined by you when declaring $return. If you want to display an array then you need to uses, unsurprisingly, _ArrayDisplay. 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...
Bibopp Posted April 13, 2019 Author Share Posted April 13, 2019 (edited) 20 minutes ago, Melba23 said: If you want to display an array then you need to uses, unsurprisingly, _ArrayDisplay. yes it is true thank you . but anyway my return and empty Edited April 13, 2019 by Melba23 Removed big quote Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 13, 2019 Moderators Share Posted April 13, 2019 Bibopp, When you reply in future, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily. Thanks in advance for your cooperation. I get an ArrayDisplay dialog when I run your first posted script, but I never see the second as you never escape from your While loop - as this modified version shows: expandcollapse popup#include <Array.au3> FromNostoScreenCoords(1, 1) Func FromNostoScreenCoords($_x, $_y) $aCurrentLoc = 37.25 ;GetCurrentPosMem($x, $y) ; $aCurrentLoc = 37.25 $CurrentLoc = StringSplit($aCurrentLoc, ".") ;MsgBox($MB_SYSTEMMODAL, "CurrentLoc", $CurrentLoc) ;; // = nothing Why ? _ArrayDisplay($CurrentLoc, "1", Default, 8) $xd = $_x - $CurrentLoc[1] $yd = $_y - $CurrentLoc[2] $w = -0.515 * $xd + -0.514 * $yd + -0.686 $x = (-1.682 * $xd + 1.683 * $yd + 0) / $w $y = (-1.54 * $xd + -1.539 * $yd + 2.307) / $w $Z = (-0.515 * $xd + -0.514 * $yd + -0.686) / $w $x = ($x + 1) / 2 * 800 $y = (1 - $y) / 2 * 600 ConsoleWrite($x & " ~ " & $y & @CRLF) ;; Handle out of screen scenarios While $x >= 800 Or $y >= 600 Or $x <= 0 Or $y <= 0 $xd = $xd / 2 $yd = $yd / 2 $w = -0.515 * $xd + -0.514 * $yd + -0.686 $x = (-1.682 * $xd + 1.683 * $yd + 0) / $w $y = (-1.54 * $xd + -1.539 * $yd + 2.307) / $w $Z = (-0.515 * $xd + -0.514 * $yd + -0.686) / $w $x = ($x + 1) / 2 * 800 $y = (1 - $y) / 2 * 600 ConsoleWrite($x & " ~ " & $y & @CRLF) ; As you can see these values mean you will never escape the loop! <<<<<<<<<<<<<<<< Sleep(500) WEnd Dim $return[2] $return[0] = $x $return[1] = $y ;Return $return ; Move to after the next line or that line will never be executed <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;MsgBox($MB_SYSTEMMODAL, "FromNostoScreenCoords", $return) ; ; // = nothing Why ? _ArrayDisplay($return, "2", Default, 8) Return $return EndFunc ;==>FromNostoScreenCoords You need to look at the "out of screen" calculations as they are obviously not working as you intend. 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...
Bibopp Posted April 13, 2019 Author Share Posted April 13, 2019 Ok thank you . I will check the calculations 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