Jump to content

programming for two monitors..


Recommended Posts

Posted

This will seem silly but, how can you find out how many monitors a user has without looking over your cubicle wall? We do a lot of things in excel as well as autocad. I'm just trying to combine the two.

Posted
This will seem silly but' date=' how can you find out how many monitors a user has without looking over your cubicle wall? We do a lot of things in excel as well as autocad. I'm just trying to combine the two.[/quote']

 

Send out a group email and ask?

Posted

I'm trying to make a lisp for everyone that will work after I leave this place. I do not plan to stay at this job very long. I could just make a settings option so the user selects number of monitors.. I'd like to avoid it if I could

Posted

If you can't ask, and you can't go around and look...I don't know what to tell you.

 

When you say everyone, do you mean everyone in the country or just at that company?

Posted

If I understand you right you are looking to find programmatically if a workstation has one or two displays.

Here you can find a VBS code that lists the serial number of attached monitor(s) - scroll to the bottom of page. You can adapt this code to just return True of False.

 

Regards,

Mircea

Posted (edited)

After investigating the VBA code from above link there is my attempt to translate it into AutoLISP:

 

(defun CountMonitors( / regPath listMonitors device id theType IsMonitor displayCount )
;registry path that store registred monitors (in use or discontinued)
(setq regPath "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\DISPLAY\\")

;gather all registred "display" devices (monitors or other)
(setq listMonitors (vl-registry-descendents regPath))
(setq device       (car listMonitors))
(setq displayCount 0)

;parse "display" devices
(foreach device listMonitors
 (setq id (vl-registry-descendents (strcat regPath device)))             ;get product ID for this device
 (if id
  (progn
   (setq device  (strcat regPath device "\\" (car id))
         theType (vl-registry-read device "HardwareID"))                 ;list entries under hardware ID
   (if (not (listp theType)) (setq theType (list theType)))              ;not sure if above key return always a list !!!

   (setq IsMonitor nil)
   (foreach val theType                                                  ;check if device is a monitor
    (if (and (equal (type val) 'STR)
             (wcmatch val "Monitor\\*"))
     (setq IsMonitor T)
    )
   )

   ;if device is a monitor check if is attached (should have a sub-key named "Control")
   (if IsMonitor
    (if (member "Control"
                (vl-registry-descendents device))
     (setq displayCount (1+ displayCount))                               ;count current monitor
    )
   )
  )
 )
)

(if (> displayCount 0)
 (alert (strcat "Your workstation have " (itoa displayCount) " monitor" (if (= displayCount 1) "" "s") "!"))
 (alert "Unable to detect monitor on this workstation!")
)

displayCount                                                             ;return number of monitors on workstation
)

 

Unfortunately, I cannot test this on a workstation with 2 monitors until Monday.

 

Regards,

Mircea

Edited by MSasu
Small corrections to code

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...