Sign in to follow this  
Followers 0
fusion400

How do i get Primary and Secondary screen coordinates.

8 posts in this topic

Hello i use this code to get screenshots of both primary and secondary monitor is it possible to get the

coordinates directly from autoit in an easy way?

The first screen is 1920x1200 and the secondary is 1360x768 in size

So i have to manually enter coordinates into script which is not optimal if other monitor with different

resolution gets connected in the future.

_ScreenCapture_Capture(@ScriptDir & $datornamn & ".jpg", 0, 0, 1920, 1200)

_ScreenCapture_Capture(@ScriptDir & $datornamn & "-2.jpg", 1920, 0, 3280, 768)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I dont know about using autoit to get the coords (except through the macro recorder it comes with) But Personally I use a program called mzoom which shows you the coordinates of your current mouse position. I use the trial version and it works fine. Not saying you can't with autoit, just giving you another option until we get a better answer.

Edit::

HotKeySet("z","jPos")

While 1

Sleep(100)

WEnd

Func jPos()

$jPos = MouseGetPos()

MsgBox(0, "Mouse x,y:", $jPos[0] & "," & $jPos[1])

EndFunc

When you press Z a popup box will appear with your mouse position.

Hope this helped

Sources - coordinates program ? - AutoIt Forums

Edited by Synct

Share this post


Link to post
Share on other sites

I dont know about using autoit to get the coords (except through the macro recorder it comes with) But Personally I use a program called mzoom which shows you the coordinates of your current mouse position. I use the trial version and it works fine. Not saying you can't with autoit, just giving you another option until we get a better answer.

Edit::

HotKeySet("z","jPos")

While 1

Sleep(100)

WEnd

Func jPos()

$jPos = MouseGetPos()

MsgBox(0, "Mouse x,y:", $jPos[0] & "," & $jPos[1])

EndFunc

When you press Z a popup box will appear with your mouse position.

Hope this helped

Sources - coordinates program ? - AutoIt Forums

Ok what i wanted was just a simple way to get current screen resolutions of both screens and then calculate the correct coordinates to capture screenshots of both monitors.

This should be done without any kind of user interaction.

There must be some way to get coordinates for primary and secondary displays.

Share this post


Link to post
Share on other sites

For the primary monitor you can use @DesktopWidth and @DesktopHeight, but I don't know of such functions for the secondary monitor. All I can offer is this quick hack:

Func _GetResolution()
    Local $resolution[3]
    Local $pos0 = MouseGetPos()
    MouseMove(10000,0,0) 
    Local $pos1 = MouseGetPos()
    MouseMove(10000,10000,0)
    Local $pos2 = MouseGetPos()
    MouseMove($pos0[0],$pos0[1],0)
    $resolution[0] = $pos2[0] + 1 - @DesktopWidth
    $resolution[1] = $pos2[1] + 1 - $pos1[1]
    $resolution[2] = $pos1[1]
    Return $resolution
EndFunc

It returns an array with the heigth, width and vertical offset of the second monitor, but it's a pretty horrible way to get the data and I really hope someone will respond with a nice dll call or something that will replace it.

The function also assumes the desktop is extended to the right. It's the most common setup, but far from the only one.

Share this post


Link to post
Share on other sites

Thank you for raising this Question..

Interesting.. I was looking for a way to center a Gui in another monitor....

1st, the macros @DeskTopHeight and Width do not account for the tool bar in the main window..

They only give the main monitor screen size not the real usable DeskTop sizes..

But GuiCreate("",-1,-1) does center and does take into account for toolbar width/height, but only on my primary monitor..

Further,

if my main gui is in another monitor,and ask for a MsgBox, the MsgBox it is centered on monitor holding my Gui

so there must be a way if could know the internals used by MsgBox,

Hope someone who knows more about this will answer the questions raised..

How do we center on any monitor, accounting for the toolbar in the main monitor, and for the screen on other monitors..

Thanks in advance,

RoyS

Share this post


Link to post
Share on other sites

hope it helps!!!!

Display_Library_Functions

i will be in the same boat soon with a 3 screen display and a touchscreen for shortcuts and coding referances.

Share this post


Link to post
Share on other sites

Motuatronic2010,

Thanks for the ziped library, looks like may be good resource for

getting the values of all monitors .. not sure I will be able to

put this together with a program to center in working area on any

monitor, but may be able to do so if can determine 1st which

one my Gui is on when it needs to be "re-centered"..

More later as have time..

Thank you again!

RoyS

Share this post


Link to post
Share on other sites

Motuatronic2010,

Thanks for the ziped library, looks like may be good resource for

getting the values of all monitors .. not sure I will be able to

put this together with a program to center in working area on any

monitor, but may be able to do so if can determine 1st which

one my Gui is on when it needs to be "re-centered"..

More later as have time..

Thank you again!

RoyS

No problem RoyS,

I had a look into Hermano's Display_Library_Functions and tested a bit and its seemed all good. i think theres much more in the user32.dll that can be of used for display info and control. so in the near future i plan to work on adding more to the library example to show a bit more display control for multi display users and possibly touch screen control, like sending info to a selected window on a specific monitor by a press on the touchscreen. i could not find much more on this and i feel more and more people are going to be wanting it as more people are starting to use multi displays.

also those incredible multi touch 3d screens are availible now and easily creating custom setups with autoit would be such a bonus.

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