找回密码  加入

AUTOIT CN

搜索
查看: 103|回复: 3

[附代码]换电脑之前正常,现在无法运行了。不知道原因

[复制链接]
发表于 2019-9-7 00:39:21 | 显示全部楼层 |阅读模式
#NoTrayIcon
#Region ;**** 由 AccAu3Wrapper_GUI 创建指令 ****
#AccAu3Wrapper_Icon=C:\Users\Administrator\Desktop\封装工具\ooopic_1556873308.ico
#AccAu3Wrapper_Outfile=硬件信息收集.exe
#AccAu3Wrapper_Outfile_x64=硬件收集_x64.exe
#AccAu3Wrapper_Compile_Both=y
#AccAu3Wrapper_Res_Comment=信息收集
#AccAu3Wrapper_Res_Description=信息收集
#AccAu3Wrapper_Res_Fileversion=1.2.0.2
#AccAu3Wrapper_Res_Fileversion_AutoIncrement=y
#AccAu3Wrapper_Res_LegalCopyright=basc
#AccAu3Wrapper_Res_Language=2052
#AccAu3Wrapper_Res_requestedExecutionLevel=None
#EndRegion ;**** 由 AccAu3Wrapper_GUI 创建指令 ****
#include <string.au3>
#include <WinAPI.au3>
;~ ;-------------------------------------------------------------------------------------------------------------------------------------------
Global $edidvalue , $dissnid  , $width ,$height ,$dissize,$createweek ,$createyear ,$proid ,$proname ,$disothersn;, $midtemp ,$midtemp1
Global $ti,$ti1 ,$p1,$p2,$p3,$alltxt,$mb,$computerModel2
$edidvalue = _currdisplayEDID()
;If $edidvalue="" Then
;;    MsgBox(0,"错误","读取注册表出错!")
;   Exit
;EndIf

;显示器ID = 制造商 + 产品代码
$proname=StringMid ( $edidvalue, 19 ,4 ) ;制造商名称
;MsgBox(0,"",StringLen(_N2B(_hextodec($proname))))
$proname=_N2B(_hextodec($proname))
;$proname = "111010111010110"
$ti = StringLen($proname)
If $ti<15 Then
    $ti1 = 5 - (15 - $ti)
Else
    $ti1 = 5
EndIf
$p1 = StringMid($proname,1,$ti1)  ;第一个字符
$p2 = StringMid($proname,$ti1+1,5) ;第二个字符
$p3 = StringMid($proname,$ti1+1+5,5)  ;第三个字符
;$proname =  _bintochr(StringMid($pronametemp,1,$ti1)) & _bintochr(StringMid($pronametemp,$ti1+1,5)) &  _bintochr(StringMid($pronametemp,$ti1+1+5,5) )
;MsgBox(0,"",$proname)
Switch $ti1
    Case 4
        $p1 = "0" & $p1
    Case 3
        $p1 = "00" & $p1
    Case 2
        $p1 = "000" & $p1        
    Case 1
        $p1 = "0000" & $p1        
EndSwitch
$proname =  _bintochr($p1) & _bintochr($p2) &  _bintochr($p3) ;显示完整的标识 比如 AOC
;MsgBox(0,"",$proname)
$proid= StringMid ( $edidvalue, 25 ,2 ) &StringMid ( $edidvalue, 23 ,2 ) ;产品代码 高低互换  
;MsgBox(0,"",$proid)
$createweek=_hextodecfortwo( StringMid ( $edidvalue, 35 ,2 ) );制造周
$createyear=_hextodecfortwo(StringMid ( $edidvalue, 37 ,2 )) + 1990 ;制造年
;MsgBox(0,"",$createyear)
$width = _hextodecfortwo(StringMid ( $edidvalue, 45 ,2 ) ); 宽 单位cm
$height = _hextodecfortwo(StringMid ( $edidvalue, 47 ,2 )); 高
;显示器中间的斜线 = 两直角边平方和再开方(即平方根)  再除以2.54表示寸  1英寸=2.54cm
$dissize = StringMid(Sqrt($width*$width + $height*$height) / 2.54,1,4) & "寸" ;尺寸
$dissnid = _convertChrToString(227,$edidvalue) ;直接可以在227处读取序列号
$disothersn = _convertChrToString(191,$edidvalue) ;直接可以在191处读取序列号     机种名称信息 型号
$alltxt = "显示器ID:" & $proname & $proid & @CRLF & "型号:"& $disothersn & @CRLF & "第" & $createweek & "周 / " & $createyear & @CRLF & "序列号:" & $dissnid & @CRLF & $width &" cm × " & $height & " cm (" & $dissize & ")"
;MsgBox(0,"查看显示器参数",$alltxt) ;& @CRLF &

Func _currdisplayEDID() ;取得edid值
Local $objWMIService,$Items ,$Info , $reg ,$redid
$objWMIService = ObjGet("winmgmts:\\.\root\cimv2")
$Items = $objWMIService.ExecQuery("SELECT * FROM Win32_DesktopMonitor")
    For $Info In $Items
        $reg = $Info.PNPDeviceID
    Next
    $redid = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\" & $reg &"\Device Parameters", "edid")
    Return $redid
EndFunc

;把多个字符 连在一起组成字符串
Func _convertChrToString($inputint,$tedid)
    Local $txt ,$i,$j,$tmp
    $txt=""
    $j=$inputint
    For $i=1 To 14
        $tmp=StringMid ( $tedid, $j ,2)
        $txt = $txt & String(Chr(_hextodecfortwo($tmp)))
        $j = $j +2
    Next
    Return $txt
EndFunc
;把字符串形的16进制[四位的十六进制]转为10进制
Func _hextodec($instring)
    Local $strtemp
    $strtemp = StringUpper($instring)
    Return _hextemp(StringMid($strtemp,1,1))*16*16*16 + _hextemp(StringMid($strtemp,2,1))*16*16 + _hextemp(StringMid($strtemp,3,1))*16 + _hextemp(StringMid($strtemp,4,1))
EndFunc
Func _hextemp($ichr)
    Local $uperstr
    $uperstr = asc(StringUpper($ichr))
    If $uperstr< 58 Then
        $uperstr = $uperstr -48
    Else
        $uperstr =$uperstr - 55
    EndIf
    Return $uperstr
EndFunc
;原理BitAND 用来按位"与"运算,之后将这些得到的 0 1 等相连
;BitShift 用来按位"移"运算,这里它的作用是用作右移一位则相当于除以2结果没带小数点
;十进制转二进制 ,直接网上代码 转sky123
Func _N2B($iN)
     Local $sB = ""
Local $iN2 = $iN
    While $iN
        $sB = BitAND($iN , 1) & $sB
        $iN = BitShift($iN, 1)
    WEnd
    Return $sB
EndFunc   ;==>_N2B
;直接查表返回
Func _bintochr($inbin)
    Local $i
    Local $table[26] = ["00001","00010","00011","00100","00101","00110","00111","01000","01001","01010","01011","01100","01101","01110","01111","10000","10001","10010","10011","10100","10101","10110","10111","11000","11001","11010"]
    Local $tablechr[26] = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
    For $i = 0 To 25
        If $table[$i] = $inbin Then
            ExitLoop
            ;MsgBox(0,"",$i)
        EndIf   
    Next
    Return $tablechr[$i]
EndFunc





;把 字符串的十六进制转为对应的ascii码 比如 "41"表示A 转为 65
Func _hextodecfortwo($strhex)
    Local $rvar,$temp,$one,$two
    ;Local $hextodec[6] = ["A","B","C","D","E","F"]
    $temp = StringUpper($strhex)
    If StringLen($temp)<>2 Then
        $rvar = 0
        Return $rvar
    EndIf   
    $one = Asc(StringMid($temp,1,1))
    $two = Asc(StringMid($temp,2,1))
    If $one< 58 Then
        $one = $one -48
    Else
        $one =$one - 55
    EndIf
    If $two< 58 Then
        $two = $two -48
    Else
        $two =$two - 55
    EndIf
        ;MsgBox(0,"",$two)
    $rvar = $one*16 + $two
    Return $rvar
EndFunc
;~ ;-------------------------------------------------------------------------------------------------------------------------------------------
Dim $bios = 0, $cpu = 0, $cdrom = 0, $board = 0, $display = 0, $sound = 0, $network = 0, $monitor = 0, $harddisk = 0, $all_Hard = 0, $Memory = 0, $MemorySpeed = 0, $Windows_System = 0, $sip = 0, $MAC = 0
$sip = @IPAddress1
If $sip = "0.0.0.0" Then $sip = @IPAddress2
$MAC = _GetMAC($sip)
;;;;;;;Run("cmd /c" & 'net use \\192.168.0.170 /d /y', "", @SW_HIDE)
;;;;;;;;;;;;Run("cmd /c" & 'net use \\192.168.0.170\1 qQ75179928 /user:administrator', "", @SW_HIDE)
While 1
Local $ID = InputBox("请输入使用者工号", "方便统计请输入工号,如您使用多台电脑请在工号后添加-1,比如1234-1  1234-2递增添加,如该机器目前无人使用,请输入部门组长科长工号后面加00以便区分位置","","",300,200)
If @error = 1 Then
  Exit
EndIf
If $ID = "" Then
  MsgBox(0, "提示", "为方便登记电脑使用情况请输入工号,谢谢")
Else
  ExitLoop
EndIf
WEnd
Func _GetMAC($sip)
Local $MAC, $MACSize
Local $i, $s, $r, $iIP
$MAC = DllStructCreate("byte[6]")
$MACSize = DllStructCreate("int")
DllStructSetData($MACSize, 1, 6)
$r = DllCall("Ws2_32.dll", "int", "inet_addr", "str", $sip)
$iIP = $r[0]
$r = DllCall("iphlpapi.dll", "int", "SendARP", "int", $iIP, "int", 0, "ptr", DllStructGetPtr($MAC), "ptr", DllStructGetPtr($MACSize))
$s = ""
For $i = 0 To 5
  If $i Then $s = $s & "-"
  $s = $s & Hex(DllStructGetData($MAC, 1, $i + 1), 2)
Next
Return $s
EndFunc   ;==>_GetMAC
Func info()
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$colBios = $objWMIService.ExecQuery("Select * from Win32_BIOS")
$colBoard = $objWMIService.ExecQuery("Select * FROM Win32_BaseBoard")
$colSettings = $objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
$colMemory = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
$colMemorySpeed = $objWMIService.execQuery("select * from Win32_PhysicalMemory")
$colCPU = $objWMIService.ExecQuery("Select * from CIM_Processor")
$colVideoinfo = $objWMIService.ExecQuery("Select * from Win32_VideoController")
$colSound = $objWMIService.ExecQuery("Select * from Win32_SoundDevice")
$colMouse = $objWMIService.ExecQuery("Select * from Win32_PointingDevice")
$colMonitor = $objWMIService.ExecQuery("Select * from Win32_DesktopMonitor")
$colNIC = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapter Where Netconnectionstatus = 2")
$colharddisk = $objWMIService.execQuery("select * from win32_diskdrive")
$colcdrom = $objWMIService.execQuery("select * from win32_CDROMDrive")




$strComputer = "."
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
$xh = ''
$colChassis = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For $objChassis In $colChassis
        For $objItem In $objChassis.ChassisTypes
              ;  Switch $objItem
;                       Case 1
  ;                              $xh = "Other"
   ;                     Case 2
    ;                            $xh = "Unknown"
     ;                   Case 3
      ;                          $xh = "台式机";"Desktop"
       ;                 Case 4
        ;                        $xh = "Low Profile Desktop"
              ;          Case 5
         ;                       $xh = "Pizza Box"
          ;              Case 6
           ;                     $xh = "Mini Tower"
            ;            Case 7
             ;                   $xh = "Tower"
                ;        Case 8
               ;                 $xh = "Portable"
                 ;       Case 9
                  ;              $xh = "Laptop"
                   ;     Case 10
                    ;            $xh = "笔记本";"Notebook"
                 ;       Case 11
                     ;           $xh = "Handheld"
                      ;  Case 12
                       ;         $xh = "Docking Station"
         ;               Case 13
          ;                      $xh = "All-in-One"
           ;             Case 14
                                $xh = "Sub-Notebook"
            ;            Case 15
             ;                   $xh = "Space Saving"
              ;          Case 16
               ;                 $xh = "Lunch Box"
                ;        Case 17
                 ;               $xh = "Main System Chassis"
            ;            Case 18
                                $xh = "Expansion Chassis"
             ;           Case 19
              ;                  $xh = "Sub-Chassis"
               ;         Case 20
                ;                $xh = "Bus Expansion Chassis"
              ;          Case 21
               ;                 $xh = "Peripheral Chassis"
                ;;        Case 22
                 ;               $xh = "Storage Chassis"
                 ;       Case 23
                 ;               $xh = "Rack Mount Chassis"
                 ;       Case 24
                 ;               $xh = "Sealed-Case PC"
                 ;       Case Else
                  ;              $xh = "Unknown"
                ;EndSwitch
;                MsgBox(0, 0, "Chassis Type: " & $xh)
        Next
Next
;$info&="计算机类型:"&$xh&
$mb=''
$colBoard = $objWMIService.ExecQuery("SELECT * FROM Win32_BaseBoard")
For $object In $colBoard
        $mb = $object.Product
Next
;$info&="主板型号:"&$mb&
$computerModel = $objWMIService.ExecQuery("Select * from Win32_ComputerSystemProduct")
For $objItem in $computerModel
        $computerModel2 = $objItem.vendor & $objItem.name & "(" & $objItem.IdentifyingNumber & ")"
Next
;$info&="电脑型号:"&$computerModel2&
;MsgBox(0,'检测结果:',$info)

For $object In $colBios
  $bios = StringMid($object.Caption, 1)
  ExitLoop
Next
For $object In $colcdrom
  $cdrom = StringMid($object.Caption, 1)
  ExitLoop
Next
For $object In $colMonitor
  $monitor = StringMid($object.Caption, 1)
  ExitLoop
Next
For $object In $colBoard
  $board = $object.Product
  ExitLoop
Next
For $object In $colCPU
  $cpu = StringStripWS($object.Name, 1)
  ExitLoop
Next
For $object In $colVideoinfo
  $display = StringStripWS($object.Description, 1)
  ExitLoop
Next
For $object In $colSound
  $sound = StringStripWS($object.Description, 1)
  ExitLoop
Next
For $object In $colNIC
  $network = StringStripWS($object.name, 1)
  ExitLoop
Next
For $objOperatingSystem In $colSettings
  $Windows_System = $objOperatingSystem.Caption & " Build " & $objOperatingSystem.BuildNumber & " Sp " & $objOperatingSystem.ServicePackMajorVersion & "." & $objOperatingSystem.ServicePackMinorVersion
  ExitLoop
Next
For $object In $colMemory
  $Memory = String(Int(Number($object.TotalPhysicalMemory) / (1024 * 1024))) & " MB"
  ExitLoop
Next
For $object In $colMemorySpeed
  $MemorySpeed = "DDR " & StringMid($object.Speed, 1)
  ExitLoop
Next
Dim $all_Hard
For $object In $colharddisk
  $all_Hard = $all_Hard & ";" & StringMid($object.Caption, 1)
Next
$all_Hard = StringMid($all_Hard, 2)
$harddisk = $all_Hard
EndFunc   ;==>info
Const $IOCTL_STORAGE_BASE = 0x2D
Const $IOCTL_STORAGE_QUERY_PROPERTY = _MakeCtrlCode($IOCTL_STORAGE_BASE, 0x500)
Const $DFP_RECEIVE_DRIVE_DATA = 0x7C088
Const $tagSTORAGEPROPERTYQUERY = "int PropertyId;int QueryType;byte AdditionalParams"
Const $tagSTORAGEDEVICEDESCRIPTOR = "ulong Version;ulong Size;byte DeviceType;" & _
                        "byte DeviceTypeModifier;byte RemovableMedia;" & _
                        "byte CommandQueueing;ulong VendorIdOffset;" & _
                        "ulong ProductIdOffset;ulong ProductRevisionOffset;" & _
                        "ulong SerialNumberOffset;int BusType;" & _
                        "ulong RawPropertiesLength;byte RawDeviceProperties"
Const $tagDRIVERSTATUS = "byte DriverError;byte IDEStatus;byte Reserved1[2];dword Reserved2[2]"
Const $tagIDEREGS = "byte Features;byte SectorCount;byte SectorNumber;byte CylLow;" & _
                        "byte CylHigh;byte DriveHead;byte Command;byte Reserved"
Const $tagSENDCMDOUTPARAMS = "dword Size;" & $tagDRIVERSTATUS
Const $tagSENDCMDINPARAMS = "dword Size;" & $tagIDEREGS & ";byte DriveNumber;" & _
                        "byte Reserved1[3];dword Reserved2[4];byte Buffer"
$sPhysDisk = "\\.\PhysicalDrive0"
$hDisk = _WinAPI_CreateFile($sPhysDisk, 2, 6, 6, 1)
If $hDisk = -1 Then
        Exit(ConsoleWrite("_WinAPI_CreateFile fails, error code: " & _WinAPI_GetLastError() & @CRLF))
EndIf
$tSCIP = DllStructCreate($tagSENDCMDINPARAMS)
$tSCOP = DllStructCreate($tagSENDCMDOUTPARAMS & ";char Buffer[1024]")
$tQuery = DllStructCreate($tagSTORAGEPROPERTYQUERY)
$tDescr = DllStructCreate($tagSTORAGEDEVICEDESCRIPTOR)
DllStructSetData($tQuery, "PropertyId", 0)
DllStructSetData($tQuery, "QueryType", 0)
$iResult = _DeviceIoControl($hDisk, $IOCTL_STORAGE_QUERY_PROPERTY, _
                $tQuery, DllStructGetSize($tQuery), _
                $tDescr, DllStructGetSize($tDescr))
If $iResult = 0 Then
        Exit(ConsoleWrite("_DeviceIoControl fails, error code: " & @error & @CRLF))
EndIf
If DllStructGetData($tDescr, "BusType") = 2 Then
        DllStructSetData($tSCIP, "Command", 0xA1)
Else
        DllStructSetData($tSCIP, "Command", 0xEC)
EndIf
$iResult = _DeviceIoControl($hDisk, $DFP_RECEIVE_DRIVE_DATA, _
                $tSCIP, DllStructGetSize($tSCIP), _
                $tSCOP, DllStructGetSize($tSCOP))
If $iResult = 0 Then
        Exit(ConsoleWrite("_DeviceIoControl fails, error code: " & @error & @CRLF))
EndIf
Dim $sSerialNum
For $i = 21 to 40 Step 2
        $sSerialNum &= DllStructGetData($tSCOP, "Buffer", $i + 1)
        $sSerialNum &= DllStructGetData($tSCOP, "Buffer", $i)
Next
$sSerialNum = StringReplace($sSerialNum, " ", "")
;;Msgbox(0, "", $sPhysDisk & "'s serial number: " & $sSerialNum)  硬盘序列号
$tSCIP = 0
$tSCOP = 0
$tQuery = 0
$tDescr = 0
_WinAPI_CloseHandle($hDisk)
Func _MakeCtrlCode($iDevType, $iFunction, $iMethod = 0, $iAccess = 0)
        Return bitOR(bitShift($iDevType,-16),bitShift($iAccess, -14),bitShift($iFunction, -2), $iMethod)
EndFunc        ;==>_MakeCtrlCode
Func _DeviceIoControl($hDevice, $iCtrlCode, $pIn, $iIn, $pOut, $iOut, $pOverlapped = 0)
        Local $iResult
        If IsDllStruct($pIn) Then $pIn = DllStructGetPtr($pIn)
        If IsDllStruct($pOut) Then $pOut = DllStructGetPtr($pOut)
        If IsDllStruct($pOverlapped) Then $pOverlapped = DllStructGetPtr($pOverLapped)
        $iResult = DllCall("Kernel32.dll", "int", "DeviceIoControl", "ptr", $hDevice, _
                        "dword", $iCtrlCode, "ptr", $pIn, "dword", $iIn, _
                        "ptr", $pOut, "dword", $iOut, "int*", 0, "ptr", $pOverlapped)
        Return SetError(_WinAPI_GetLastError(), $iResult[7], $iResult[0])
EndFunc        ;==>_DeviceIoControl
$user = @UserName
$name = @ComputerName
;$desc = RegRead("HKLM\SYSTEM\ControlSet001\Services\lanmanserver\parameters", "srvcomment")
info()
Dim $All_info;                                       此处可有@TAB  $desc                       
$All_info = $All_info & ($ID) & @TAB & ($name)& @TAB&($user) & @TAB & ($mb) & @TAB& ($computerModel2) & @TAB & ($bios) & @TAB & ($cpu) & @TAB & ($display)& @TAB & ($harddisk)& @TAB &($sSerialNum) & @TAB & ($Memory) & @TAB & ($MemorySpeed) & @TAB & ($network) & @TAB & ($sound) & @TAB & ($Windows_System)& @TAB & ($cdrom) & @TAB & ($monitor)&"_"& $proname & $proid & @TAB & ($sip) & @TAB & ($MAC) & @CRLF
FileWrite("\\127.0.0.1\test.xls", $All_info)
MsgBox("0", "提示", "运行结束,感谢支持!")

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?加入

x
 楼主| 发表于 2019-9-7 00:42:06 | 显示全部楼层
硬件信息收集工具,直接进程,,
发表于 2019-9-8 15:53:04 | 显示全部楼层
Const $IOCTL_STORAGE_QUERY_PROPERTY = _MakeCtrlCode($IOCTL_STORAGE_BASE, 0x500)

364行报错,未声明变量。。删除这行貌似也能运行。。请自查这行的作用把
发表于 2019-9-9 00:48:13 | 显示全部楼层
win-7 64bit   autoit 版本:3.3.14.2  運行沒報錯,不過好像少一些東西,所以沒輸出什麼東西。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|小黑屋|手机版|AUTOIT CN ( Autoit8.com )谷歌 百度

GMT+8, 2019-9-21 06:49 , Processed in 0.093751 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表