两个监视器的编程。。
这看起来很愚蠢,但是,你怎么知道一个用户有多少个监视器而不看你的隔间墙呢?我们在excel和autocad中做了很多事情。我只是想把两者结合起来。 我正在努力为我离开这个地方后将要工作的每个人做一个Lisp程序的口吃。我不打算做这份工作很长时间。我可以只做一个设置选项,让用户选择监视器的数量。。如果可以的话,我想避免 如果你不能问,你不能四处看看。。。我不知道该告诉你什么。当你说“每个人”时,你是指这个国家的每个人还是只指那个公司的每个人? 如果我理解正确的话,您希望通过编程找到工作站是否有一个或两个显示器。
在这里,您可以找到列出所连接监视器序列号的VBS代码-滚动到页面底部。您可以调整此代码以仅返回True或False。
当做
米尔恰 在研究了上面链接中的VBA代码后,我尝试将其转换为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
)
不幸的是,直到星期一,我才能在有两个监视器的工作站上测试这一点。
当做
米尔恰
页:
[1]