TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Peter2 on December 18, 2013, 02:57:19 AM

Title: How to get the min/max coordinates of currents monitor(s)?
Post by: Peter2 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
Title: Re: How to get the min/max coordinates of currents monitor(s)?
Post by: ronjonp 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))
)
Title: Re: How to get the min/max coordinates of currents monitor(s)?
Post by: Lee Mac on December 18, 2013, 04:02:56 PM
Very good Ron  :-)
Title: Re: How to get the min/max coordinates of currents monitor(s)?
Post by: ronjonp on December 18, 2013, 04:05:49 PM
Very good Ron  :)


I get one every once in a while  ;D
Title: Re: How to get the min/max coordinates of currents monitor(s)?
Post by: Peter2 on December 20, 2013, 06:21:38 AM
You could use WMI like so:..
Thanks, ronjonp

fine   :-)