Page 1 of 1 1
Topic Options
#199670 - 2010-08-26 07:11 PM Make FUNCTION result a variable
Mike72677 Offline
Fresh Scripter

Registered: 2004-06-17
Posts: 32
Loc: PA
I found someone's script to pull monitor information. It outputs the results to the screen, but I'm trying to get it to output the values to variables. I added $MSN = MonitorSN() and $MMN = MonitorModel() to the end of the script and it works if I use kix32.exe, but I get an error when wkix32.exe gets to those lines. Can someone help? Thanks!


 Code:
Break ON

$=SetOption("Explicit","ON")
$=SetOption("WrapAtEOL","ON")
$=SetOption("ASCII","ON")

; MonitorSN()

?

; MonitorModel()


; get $

FUNCTION MonitorSN(OPTIONAL $computer)
   Dim $sEDID,$ioffset,$sblock,$c,$s,$iIndex,$sMonitor
   $iIndex=0
   $sMonitor=EnumKey("HKLM\SYSTEM\CurrentControlSet\Enum\Display",$iIndex)

   While Not @ERROR

   $sMonitor="HKLM\SYSTEM\CurrentControlSet\Enum\Display\"+$sMonitor+"\"+EnumKey("HKLM\SYSTEM\CurrentControlSet\Enum\Display\"+$sMonitor,0)

      If KeyExist($sMonitor+"\Control")
         If Instr(ReadValue($sMonitor,"HardwareID"),"Monitor\")=1
            $sEDID = ReadValue($sMonitor+"\Device Parameters","EDID")
            For $iOffset=54 To 108 Step 18
               $sBlock=SubStr($sEDID,$iOffset*2+1,18*2)
               If Left($sBlock,8)="000000ff"
                  $s = SubStr($sBlock,9)
                  While $s
                     $c=Execute("Exit &"+Left($s,2))
                     If $c=10
                        Exit 0
                     EndIf
                     If $c
                        $MonitorSN=$MonitorSN+Chr($c)
                     EndIf
                     $s=SubStr($s,3)
                  Loop
               EndIf
            Next
         EndIf
      EndIf

      $iIndex=$iIndex+1

      $sMonitor=EnumKey("HKLM\SYSTEM\CurrentControlSet\Enum\Display",$iIndex)

   Loop

ENDFUNCTION

FUNCTION MonitorModel(OPTIONAL $computer)
   Dim $sEDID,$ioffset,$sblock,$c,$s,$iIndex,$sMonitor
   $iIndex=0
   $sMonitor=EnumKey("HKLM\SYSTEM\CurrentControlSet\Enum\Display",$iIndex)
   While Not @ERROR
      

$sMonitor="HKLM\SYSTEM\CurrentControlSet\Enum\Display\"+$sMonitor+"\"+EnumKey("HKLM\SYSTEM\CurrentControlSet\Enum\Display\"+$sMonitor,0)

      If KeyExist($sMonitor+"\Control")
         If Instr(ReadValue($sMonitor,"HardwareID"),"Monitor\")=1
            $sEDID = ReadValue($sMonitor+"\Device Parameters","EDID")
            For $iOffset=54 To 108 Step 18
               $sBlock=SubStr($sEDID,$iOffset*2+1,18*2)
               If Left($sBlock,8)="000000fc"
                  $s = SubStr($sBlock,9)
                  While $s
                     $c=Execute("Exit &"+Left($s,2))
                     If $c=10
                        Exit 0
                     EndIf
                     If $c
                        $MonitorModel=$MonitorModel+Chr($c)
                     EndIf
                     $s=SubStr($s,3)
                  Loop
               EndIf
            Next
         EndIf
      EndIf

      $iIndex=$iIndex+1

      $sMonitor=EnumKey("HKLM\SYSTEM\CurrentControlSet\Enum\Display",$iIndex)

   Loop

ENDFUNCTION

$MSN = MonitorSN()
$MMN = MonitorModel()





Edited by Richard H. (2010-08-27 08:54 AM)
Edit Reason: Added code tags

Top
#199672 - 2010-08-26 09:43 PM Re: Make FUNCTION result a variable [Re: Mike72677]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
and what kind of error you might be getting there?

also, try to use [-code] tags.
_________________________
!

download KiXnet

Top
#199673 - 2010-08-26 09:44 PM Re: Make FUNCTION result a variable [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
go see manual for $=SetOption("Explicit","ON")
_________________________
!

download KiXnet

Top
#199675 - 2010-08-26 09:51 PM Re: Make FUNCTION result a variable [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you have edited the udf's, haven't you?
cause ain't getting anything back from them.
_________________________
!

download KiXnet

Top
#199679 - 2010-08-27 09:03 AM Re: Make FUNCTION result a variable [Re: Lonkero]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Hey, I recognise that code!

I've just run it (after adding a couple of lines to DIM $MSN and $MMN and then display them) and it works for me:
 Originally Posted By: Command Prompt
Monitor serial #: DR47477G0D8S
Monitor model : DELL2407WFPHC

Top
#199684 - 2010-08-27 05:43 PM Re: Make FUNCTION result a variable [Re: Richard H.]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
on my vista I get nothing.
_________________________
!

download KiXnet

Top
#199686 - 2010-08-28 02:02 PM Re: Make FUNCTION result a variable [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh, this might have been the thing that doesn't show anything if you have generic drivers installed. doh.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 320 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.203 seconds in which 0.135 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org