fusion400 Posted September 11, 2010 Posted September 11, 2010 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)
Synct Posted September 11, 2010 Posted September 11, 2010 (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)WEndFunc jPos() $jPos = MouseGetPos() MsgBox(0, "Mouse x,y:", $jPos[0] & "," & $jPos[1]) EndFuncWhen you press Z a popup box will appear with your mouse position.Hope this helpedSources - coordinates program ? - AutoIt Forums Edited September 11, 2010 by Synct
fusion400 Posted September 11, 2010 Author Posted September 11, 2010 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.
Tvern Posted September 11, 2010 Posted September 11, 2010 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.
RoyS Posted September 13, 2010 Posted September 13, 2010 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
Motuatronic2010 Posted September 13, 2010 Posted September 13, 2010 hope it helps!!!!Display_Library_Functionsi will be in the same boat soon with a 3 screen display and a touchscreen for shortcuts and coding referances.
RoyS Posted September 15, 2010 Posted September 15, 2010 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
Motuatronic2010 Posted September 16, 2010 Posted September 16, 2010 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 whichone my Gui is on when it needs to be "re-centered".. More later as have time..Thank you again!RoySNo 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.
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