找回密码
 加入
搜索
查看: 3029|回复: 5

[AU3基础] [已解决]请教一个信息输出的问题--还有点问题

[复制链接]
发表于 2010-4-15 18:12:32 | 显示全部楼层 |阅读模式
本帖最后由 waxy 于 2010-4-27 21:20 编辑

向各位兄弟请教一下,突发奇想不知道有没有办法可以把“三恨”前辈那个“硬件信息工具”修改一下,在看到硬件信息清单的同时在后台
生成一个信息报告(TxT 或INI文件)放到指定的目录(比如D:\info),请兄弟们指点一下谢了。
afan版主我按你的提示在你在每个 GUICtrlSetData($xx, $xxx)
下面加上$infotxt &= GuiCtrlRead($xx-1) & ':' & $xxx & @CRLF
找不到输出的.TXT文件,于是我又在GUICtrlSetData($xx, $xxx) 后面加了一行$infotxt=fileopen("HW_info.txt",1)
只能在当前目录生成一个空的HW_info.txt文件,程序抓到硬件信息也没写到文本中去,把$infotxt &=  GuiCtrlRead($cpu-1) & ':' & $colCPU & @CRLF
改为$infotxt &=  GuiCtrlRead($cpu-1) & ':' & $colCPU &FileWriteLine($infotxt,"") & @CRLF 也没用。
麻烦再指点一下。
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Program Files\autoit3\Aut2Exe\Icons\windows.ico
#AutoIt3Wrapper_Compression=3
#AutoIt3Wrapper_Res_Comment=简单的硬件信息查看工具
#AutoIt3Wrapper_Res_Description=硬件信息查看工具
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=叁恨居士
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstants.au3>
#include <Misc.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1)

_Singleton("Hardware_info")

Global $hGui,$bios,$board,$cpu,$display,$sound,$network,$mem,$os


SplashImageOn("logo","Splash.jpg",425,200,-1,-1,1)

$hGui=GUICreate ("                       硬件信息查看器",450,400,-1,-1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_hGuiMsg")


GUICtrlCreateGroup ("信息选项", 10, 10, 430, 360)

GUICtrlCreateButton("C  P  U",25,40,80,30)
$cpu=GUICtrlCreateInput("",120,40,270,30,$ES_READONLY)

GUICtrlCreateButton("B I O S",25,80,80,30)
$bios=GUICtrlCreateInput("",120,80,270,30,$ES_READONLY)


GUICtrlCreateButton("主    板",25,120,80,30)
$board=GUICtrlCreateInput("",120,120,270,30,$ES_READONLY)


GUICtrlCreateButton("显    卡",25,160,80,30)
$display=GUICtrlCreateInput("",120,160,270,30,$ES_READONLY)

GUICtrlCreateButton("声    卡",25,200,80,30)
$sound=GUICtrlCreateInput("",120,200,270,30,$ES_READONLY)

GUICtrlCreateButton("网    卡",25,240,80,30)
$network=GUICtrlCreateInput("",120,240,270,30,$ES_READONLY)

GUICtrlCreateButton("内    存",25,280,80,30)
$mem=GUICtrlCreateInput("",120,280,270,30,$ES_READONLY)

GUICtrlCreateButton("操作系统",25,320,80,30)
$os=GUICtrlCreateInput("",120,320,270,30,$ES_AUTOHSCROLL+$ES_READONLY)

GUICtrlCreateGroup ("",-99,-99,1,1) 
GUICtrlCreateLabel("Autoit 中文论坛 www.autoitx.com 倾情奉献",15,370,300,30)
GUICtrlCreateLabel("Make By Sanhen",350,370,100,30)

                

GUISetState()

info()
SplashOff()
While 1
        
Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', @AutoItPID)
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
DllCall("kernel32.dll" , 'int', 'CloseHandle', 'int', $ai_Handle[0])
Sleep(1000) 

Wend

Func _hGuiMsg()
  Switch @GUI_CTRLID 
          
            Case  $GUI_EVENT_CLOSE
                         Exit                                                        
        Case $GUI_EVENT_MINIMIZE
                guisetstate(@SW_MINIMIZE)
        Case $GUI_EVENT_RESTORE
                guisetstate(@SW_RESTORE)
                EndSwitch
                
EndFunc  ;==>_hGuiMsg()
        
Func info()
      
Global $objWMIService,$colBios,$colBoard,$colSettings,$colMemory,$colCPU,$colVideoinfo,$colSound ,$colNIC 

Local $object,$objOperatingSystem
$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")
$colCPU = $objWMIService.ExecQuery("Select * from CIM_Processor")
$colVideoinfo = $objWMIService.ExecQuery("Select * from Win32_VideoController")
$colSound = $objWMIService.ExecQuery("Select * from Win32_SoundDevice")
$colNIC = $objWMIservice.ExecQuery("Select * from Win32_NetworkAdapter WHERE Netconnectionstatus = 2")

For $object in $colCPU
        GUICtrlSetData($cpu, StringStripWS($object.Name,1))
Next
        
For $object in $colBios
        GUICtrlSetData($bios,StringMid($object.Caption,1))
Next



For $object in $colBoard
        GUICtrlSetData($board,$object.Product)
        
Next




For $object in $colVideoinfo
        GUICtrlSetData($display, StringStripWS($object.Description ,1))
  
Next

For $object in $colSound
        GUICtrlSetData($sound, StringStripWS($object.Description ,1))
  Next

For $object in $colNIC
        GUICtrlSetData($network, StringStripWS($object.name ,1))
  
Next


For $objOperatingSystem in $colSettings

GUICtrlSetData($os,$objOperatingSystem.Caption & " Build " & $objOperatingSystem.BuildNumber & " Sp " & $objOperatingSystem.ServicePackMajorVersion & "." & $objOperatingSystem.ServicePackMinorVersion )

Next
for $object  in $colMemory
        GUICtrlSetData($mem,String(Int(Number($object.TotalPhysicalMemory) / (1024 * 1024))) & " Mb")
Next

EndFunc  ;==>Info()
发表于 2010-4-15 19:23:26 | 显示全部楼层
这个是 sanhen 前辈很久前的东东(看第8行)~
19行改为
Global $hGui,$bios,$board,$cpu,$display,$sound,$network,$mem,$os,$infotxt
你在每个
GUICtrlSetData($xx, $xxx)
下面加上一行
$infotxt &= GuiCtrlRead($xx-1) & ':' & $xxx & @CRLF

$infotxt就是你要的
 楼主| 发表于 2010-4-16 08:56:20 | 显示全部楼层
谢谢版主的解答!也感谢提醒,已把源码的出处改为“三恨”前辈了。
 楼主| 发表于 2010-4-16 10:59:18 | 显示全部楼层
兄弟们,有时间帮我看看啊。
发表于 2010-4-16 11:32:55 | 显示全部楼层
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Icon=C:\Program Files\autoit3\Aut2Exe\Icons\windows.ico
#AutoIt3Wrapper_Compression=3
#AutoIt3Wrapper_Res_Comment=简单的硬件信息查看工具
#AutoIt3Wrapper_Res_Description=硬件信息查看工具
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=叁恨居士
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstants.au3>
#include <Misc.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1)

_Singleton("Hardware_info")

Global $hGui, $bios, $board, $cpu, $display, $sound, $network, $mem, $os, $infotxt
SplashImageOn("logo", "Splash.jpg", 425, 200, -1, -1, 1)

$hGui = GUICreate("                       硬件信息查看器", 450, 400, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_hGuiMsg")
GUICtrlCreateGroup("信息选项", 10, 10, 430, 360)
GUICtrlCreateButton("C  P  U", 25, 40, 80, 30)
$cpu = GUICtrlCreateInput("", 120, 40, 270, 30, $ES_READONLY)
GUICtrlCreateButton("B I O S", 25, 80, 80, 30)
$bios = GUICtrlCreateInput("", 120, 80, 270, 30, $ES_READONLY)
GUICtrlCreateButton("主    板", 25, 120, 80, 30)
$board = GUICtrlCreateInput("", 120, 120, 270, 30, $ES_READONLY)
GUICtrlCreateButton("显    卡", 25, 160, 80, 30)
$display = GUICtrlCreateInput("", 120, 160, 270, 30, $ES_READONLY)
GUICtrlCreateButton("声    卡", 25, 200, 80, 30)
$sound = GUICtrlCreateInput("", 120, 200, 270, 30, $ES_READONLY)
GUICtrlCreateButton("网    卡", 25, 240, 80, 30)
$network = GUICtrlCreateInput("", 120, 240, 270, 30, $ES_READONLY)
GUICtrlCreateButton("内    存", 25, 280, 80, 30)
$mem = GUICtrlCreateInput("", 120, 280, 270, 30, $ES_READONLY)
GUICtrlCreateButton("操作系统", 25, 320, 80, 30)
$os = GUICtrlCreateInput("", 120, 320, 270, 30, $ES_AUTOHSCROLL + $ES_READONLY)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateLabel("Autoit 中文论坛 www.autoitx.com 倾情奉献", 15, 370, 300, 30)
GUICtrlCreateLabel("Make By Sanhen", 350, 370, 100, 30)

GUISetState()

info()
SplashOff()
While 1
        Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', @AutoItPID)
        Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
        DllCall("kernel32.dll", 'int', 'CloseHandle', 'int', $ai_Handle[0])
        Sleep(1000)
WEnd

Func _hGuiMsg()
        Switch @GUI_CtrlId
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $GUI_EVENT_MINIMIZE
                        GUISetState(@SW_MINIMIZE)
                Case $GUI_EVENT_RESTORE
                        GUISetState(@SW_RESTORE)
        EndSwitch

EndFunc   ;==>_hGuiMsg

Func info()
        Global $objWMIService, $colBios, $colBoard, $colSettings, $colMemory, $colCPU, $colVideoinfo, $colSound, $colNIC
        Local $object, $objOperatingSystem
        $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")
        $colCPU = $objWMIService.ExecQuery("Select * from CIM_Processor")
        $colVideoinfo = $objWMIService.ExecQuery("Select * from Win32_VideoController")
        $colSound = $objWMIService.ExecQuery("Select * from Win32_SoundDevice")
        $colNIC = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapter WHERE Netconnectionstatus = 2")
        For $object In $colCPU
                GUICtrlSetData($cpu, StringStripWS($object.Name, 1))
                $infotxt &= GUICtrlRead($cpu - 1) & ':' & StringStripWS($object.Name, 1) & @CRLF
        Next
        For $object In $colBios
                GUICtrlSetData($bios, StringMid($object.Caption, 1))
                $infotxt &= GUICtrlRead($bios - 1) & ':' & StringMid($object.Caption, 1) & @CRLF
        Next
        For $object In $colBoard
                GUICtrlSetData($board, $object.Product)
                $infotxt &= GUICtrlRead($board - 1) & ':' & $object.Product & @CRLF
        Next
        For $object In $colVideoinfo
                GUICtrlSetData($display, StringStripWS($object.Description, 1))
                $infotxt &= GUICtrlRead($display - 1) & ':' & StringStripWS($object.Description, 1) & @CRLF
        Next
        For $object In $colSound
                GUICtrlSetData($sound, StringStripWS($object.Description, 1))
                $infotxt &= GUICtrlRead($sound - 1) & ':' & StringStripWS($object.Description, 1) & @CRLF
        Next
        For $object In $colNIC
                GUICtrlSetData($network, StringStripWS($object.name, 1))
                $infotxt &= GUICtrlRead($network - 1) & ':' & StringStripWS($object.name, 1) & @CRLF
        Next
        For $objOperatingSystem In $colSettings
                GUICtrlSetData($os, $objOperatingSystem.Caption & " Build " & $objOperatingSystem.BuildNumber & " Sp " & $objOperatingSystem.ServicePackMajorVersion & "." & $objOperatingSystem.ServicePackMinorVersion)
                $infotxt &= GUICtrlRead($os - 1) & ':' & $objOperatingSystem.Caption & " Build " & $objOperatingSystem.BuildNumber & " Sp " & $objOperatingSystem.ServicePackMajorVersion & "." & $objOperatingSystem.ServicePackMinorVersion & @CRLF
        Next
        For $object In $colMemory
                GUICtrlSetData($mem, String(Int(Number($object.TotalPhysicalMemory) / (1024 * 1024))) & " Mb")
                $infotxt &= GUICtrlRead($mem - 1) & ':' & String(Int(Number($object.TotalPhysicalMemory) / (1024 * 1024))) & " Mb" & @CRLF
        Next
        FileDelete('info.txt')
        FileWrite('info.txt', $infotxt)
EndFunc   ;==>info
将在脚本文件夹生成一个“info.txt”
发表于 2010-4-16 17:16:37 | 显示全部楼层
顺便提醒一下,WMI在WINPE下无效.
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-10 02:21 , Processed in 0.082638 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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