Jump to content
• Sign Up

# How recover the \$x and \$y values of \$xy to get coordinates

## Recommended Posts

Posted (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:

```Func 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 by Melba23
Added code tags

#### Share this post

##### Share on other sites

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

##### Share on other sites
Posted (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 by Melba23
Removed big quote

#### Share this post

##### Share on other sites

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:

```#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 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

##### Share on other sites

Ok thank you . I will check the calculations

## 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

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...