continyu Posted December 17, 2011 Share Posted December 17, 2011 Hi, I'm creating a new script to determine if computers are staying with same monitors. I've founded a script which gets information about monitors serial number and name from registry with edid. BUT it only works when i restart my pc after changing monitors. (because registry doesn't get refreshed when computer is open.) So I need to get active monitor's serial number. without restarting comp. i was thinking to get all devices name from device manager. but i don't know how to do that. also i don't know how to get monitors serial number from device manager. sorry if i couldn't explained it clearly. please ask any questions about my problems. Link to comment Share on other sites More sharing options...
kylomas Posted December 17, 2011 Share Posted December 17, 2011 (edited) continyu, A brief search on Google ("wmi" & "monitor") gives all the info you need.. Good Luck, kylomas Edit: a forum search also turns up many examples... Edited December 17, 2011 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
continyu Posted December 17, 2011 Author Share Posted December 17, 2011 Sadly i couldn't find any autoit examples with wmi. also at forums i've only found examples with registry not wmi... Link to comment Share on other sites More sharing options...
kylomas Posted December 17, 2011 Share Posted December 17, 2011 continyu, When I search on "wmi" and "monitor" I get 109 hits, the second of which looks like exactly what you want... kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
continyu Posted December 17, 2011 Author Share Posted December 17, 2011 if you can give me some of the links i can tell you if they are the one i'm looking for or not. but the results from "wmi" "montior" query didn't gave me what i'm looking for. also if there is a way for getting all active device names / serial numbers to a txt file it would be good to. Link to comment Share on other sites More sharing options...
MilesAhead Posted December 17, 2011 Share Posted December 17, 2011 (edited) You could try calling EnvUpdate ( ) a few times maybe with some Sleep() in between before checking the registry value. Might be a quick and dirty fix. Edited December 17, 2011 by MilesAhead My Freeware Page Link to comment Share on other sites More sharing options...
continyu Posted December 17, 2011 Author Share Posted December 17, 2011 You could try calling EnvUpdate ( ) a few times maybe with some Sleep() in between before checking the registry value.Might be a quick and dirty fix.Thank you for your answer. i will try it when i get a chance.i'm still trying to get all device names and/or serial numbers without opening and reading it from device manager. which is a bad solution. Link to comment Share on other sites More sharing options...
MilesAhead Posted December 18, 2011 Share Posted December 18, 2011 Supposedly this VBscript utility does it and includes source code:http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=59528&lngWId=1 My Freeware Page Link to comment Share on other sites More sharing options...
continyu Posted December 18, 2011 Author Share Posted December 18, 2011 Supposedly this VBscript utility does it and includes source code:http://www.planet-source-code.com/vb/scr...ts/ShowCode.asp?txtCodeId=5952i'm not good at vb but as i understand from source it's getting edid info from registry too...also i don't know vb enough to port it to autoit. Link to comment Share on other sites More sharing options...
MilesAhead Posted December 18, 2011 Share Posted December 18, 2011 VB isn't my strength either. But I can tell you &H denotes hex numbers like 0x does in AutoIt and c/c++ I would run it and see if it works before spending a lot of time. I think it's from 2006 so it may not work in Vista/W7. I don't know. My Freeware Page Link to comment Share on other sites More sharing options...
norry Posted January 20, 2012 Share Posted January 20, 2012 I also struggled with using the registry to get the monitor information because as you point out this isn't updated when a new monitor is added/removed only on first PC boot. Came across a way using WMI that works and I don't believe has been posted in the forum. expandcollapse popupConsoleWrite(_MonitorInfo()) Func _MonitorInfo() Local $WMIWmiMonitorID Local $sManufacturerName, $sSerialNumberID, $YearOfManufacture, $WeekOfManufacture, $sUserFriendlyName Local $i Local $sMonitorInfo Local $strcomputer = "." Local $objWMIServiceWMI = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strcomputer & "\root\WMI") If IsObj($objWMIServiceWMI) = 1 Then $WMIWmiMonitorID = $objWMIServiceWMI.ExecQuery("SELECT * FROM WmiMonitorID WHERE Active='True'") For $objComputer In $WMIWmiMonitorID $WeekOfManufacture = $objComputer.WeekOfManufacture $YearOfManufacture = $objComputer.YearOfManufacture For $i = 0 To UBound($objComputer.UserFriendlyName) - 1 $sUserFriendlyName = $objComputer.UserFriendlyName($i) If StringLen($sUserFriendlyName) <> 0 Then $sMonitorInfo = $sMonitorInfo & String(Chr($sUserFriendlyName)) EndIf Next $sMonitorInfo = $sMonitorInfo & " Manufacturer: " For $i = 0 To UBound($objComputer.ManufacturerName) - 1 $sManufacturerName = $objComputer.ManufacturerName($i) If StringLen($sManufacturerName) <> 0 Then ;Returns a character corresponding to an ASCII code. $sMonitorInfo = $sMonitorInfo & String(Chr($sManufacturerName)) EndIf Next $sMonitorInfo = $sMonitorInfo & " ProductCode: " For $i = 0 To UBound($objComputer.ProductCodeID) - 1 $sProductCodeID = $objComputer.ProductCodeID($i) If StringLen($sProductCodeID) <> 0 Then $sMonitorInfo = $sMonitorInfo & String(Chr($sProductCodeID)) EndIf Next $sMonitorInfo = $sMonitorInfo & " Serial: " For $i = 0 To UBound($objComputer.SerialNumberID) - 1 $sSerialNumberID = $objComputer.SerialNumberID($i) If StringLen($sSerialNumberID) <> 0 Then $sMonitorInfo = $sMonitorInfo & String(Chr($sSerialNumberID)) EndIf Next $sMonitorInfo = $sMonitorInfo & " Built: " & $WeekOfManufacture & "/" & $YearOfManufacture $sMonitorInfo = $sMonitorInfo & @CRLF Next Else $sMonitorInfo = "Error: Not an Object" & @CRLF EndIf Return $sMonitorInfo EndFunc ;==>_MonitorInfo Link to comment Share on other sites More sharing options...
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