Author Topic: How to get the min/max coordinates of currents monitor(s)?  (Read 1812 times)

0 Members and 1 Guest are viewing this topic.

Peter2

  • Swamp Rat
  • Posts: 650
How to get the min/max coordinates of currents monitor(s)?
« on: December 18, 2013, 02:57:19 AM »
Due to dual/triple monitors and changing of cables and/or monitors I have sometimes the problem that the stored position of a dialogue does not correspond to the current monitor configuration.

So: How to get the min/max coordinates of currents monitor(s) - entire monitors, not only the Acad-windows? There must be a result between approx. -2000 and +4000 (for x-axis) ....

Peter
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

ronjonp

  • Needs a day job
  • Posts: 7526
Re: How to get the min/max coordinates of currents monitor(s)?
« Reply #1 on: December 18, 2013, 09:13:17 AM »
You could use WMI like so:
Code: [Select]
(defun c:foo (/ _wmi out)
  (defun _wmi (device / o out wmi)
    (vl-load-com)
    (and
      (setq wmi (vlax-create-object "WbemScripting.SWbemLocator"))
      (setq o (vlax-invoke (vlax-invoke wmi 'connectserver "." "\\root\\cimv2") 'execquery device))
      (and wmi (vlax-release-object wmi))
      (vlax-for i o (setq out (cons i out)))
    )
    out
  )
  (foreach m (_wmi "Select * from Win32_DesktopMonitor")
    (vlax-for p (vlax-get m 'properties_)
      (if (wcmatch (vlax-get p 'name) "ScreenWidth,ScreenHeight")
(setq out (cons (list (vlax-get p 'name) (vlax-get p 'value)) out))
      )
    )
  )
  (alert (vl-princ-to-string out))
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: How to get the min/max coordinates of currents monitor(s)?
« Reply #2 on: December 18, 2013, 04:02:56 PM »
Very good Ron  :-)

ronjonp

  • Needs a day job
  • Posts: 7526
Re: How to get the min/max coordinates of currents monitor(s)?
« Reply #3 on: December 18, 2013, 04:05:49 PM »
Very good Ron  :)


I get one every once in a while  ;D

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Peter2

  • Swamp Rat
  • Posts: 650
Re: How to get the min/max coordinates of currents monitor(s)?
« Reply #4 on: December 20, 2013, 06:21:38 AM »
You could use WMI like so:..
Thanks, ronjonp

fine   :-)
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23