DirtyJohny Posted November 18, 2020 Author Posted November 18, 2020 1 minute ago, GokAy said: Кстати, вы как будто дважды объявляете $ iKabina: Глобальные $ iKabina , $ iType , $ iKabina , $ iModel , $ iSerialNum , $ iInv Fixed,but not working... I think i use not correct line... expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <Constants.au3> #include <Array.au3> #RequireAdmin #NoTrayIcon ;Все что написано, посде ';' явлется комментарием и ни как не влияет на работу скрипта. Global $iKabina, $iType, $iModel, $iSerialNum, $iInv ;объявляем переменные, которые будут использоваться в цикле Global $rKabina, $rType, $rModel, $rSerialNum, $rInv, $Main, $iConnect, $hFile, $sInfo, $CopyBtn, $fFile = @ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt" $Main = GUICreate('Инвентаризация', 315, 352) ;рисуем главное окно GUISetBkColor(0x02101B) $iKabina = GUICtrlCreateInput('', 20, 30, 272, 21) $iType = GUICtrlCreateInput('', 20, 75, 272, 21) $iModel = GUICtrlCreateInput('', 20, 120, 272, 21) $iSerialNum = GUICtrlCreateInput('', 20, 165, 272, 21) $iInv = GUICtrlCreateInput('', 20, 210, 272, 21) GUISetFont(10, 800, 0, 'Tahoma'); Устанавливает шрифт по умолчанию для последующих элементов GUI-окна. $iConnect = GUICtrlCreateButton('Передать', 23, 305, 267, 33, $BS_DEFPUSHBUTTON) ;создаем кнопку подключения GUICtrlSetDefColor(0xDEDEDE); Устанавливает цвет текста по умолчанию для последующих элементов GUI-окна. GUICtrlCreateLabel('Кабинет', 20, 10, 150, 17) GUICtrlCreateLabel('Тип', 20, 55, 150, 17) GUICtrlCreateLabel('Модель', 20, 100, 150, 17) GUICtrlCreateLabel('Серийный номер', 20, 145, 150, 17) GUICtrlCreateLabel('Инвентарник', 20, 190, 150, 17) WinSetTrans($Main, '', 0) GUISetState(@SW_SHOW) For $i = 0 To 230 Step 9 Sleep(10) WinSetTrans($Main, '', $i) ;Прозрачность 0-255 Next $hFile = FileOpen(@ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt", 1) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iConnect $rKabina = GUICtrlRead($iKabina) $rType = GUICtrlRead($iType) $rModel = GUICtrlRead($iModel) $rSerialNum = GUICtrlRead($iSerialNum) $rInv = GUICtrlRead($iInv) Select Case (Not StringStripWS($rKabina, 8)) MsgBox(16 + 8192 + 262144, 'Error', 'Поле Кабинет - пустое') Case (Not StringStripWS($rType, 8)) MsgBox(16 + 8192 + 262144, 'Error', 'Поле Тип - пустое') Case (Not StringStripWS($rModel, 8)) MsgBox(16 + 8192 + 262144, 'Error', 'Поле Модель - пустое') Case (Not StringStripWS($rSerialNum, 8)) MsgBox(16 + 8192 + 262144, 'Error', 'Поле Серийный номер - пустое') Case (Not StringStripWS($rInv, 8)) MsgBox(16 + 8192 + 262144, 'Error', 'Поле Инвентарник - пустое') Case $hFile = -1 MsgBox(4096, 'Ошибка', 'Невозможно открыть файл.') Case Else _hide() ;отключает все элементы ввода и кнопку $sInfo = '======================================================================================' & @CRLF & _ '[МЕСТОПОЛОЖЕНИЕ:]' & @CRLF & _ @TAB & 'Дата: ................... ' & @MDAY & '.' & @MON & '.' & @YEAR & ' ' & @CRLF & _ @TAB & 'Кабинет: ................ ' & $rKabina & @CRLF & _ @TAB & 'Тип: .................... ' & $rType & @CRLF & _ @TAB & 'Модель: ................. ' & $rModel & @CRLF & _ @TAB & 'Серийный номер: ......... ' & $rSerialNum & @CRLF & _ @TAB & 'Инвентарный номер: ...... ' & $rInv & @CRLF & _ @TAB & 'Учетная запись: ......... ' & @UserName & @CRLF & @CRLF $sInfo &= _InfoPC() FileWrite($hFile, $sInfo) FileClose($hFile) _show() ;включает все элементы ввода и кнопку _ShowOtchot() EndSelect EndSwitch WEnd Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) Local $ObjProcessor = $ObjService.ExecQuery('SELECT * FROM Win32_Processor', 'WQL', 0x30) Local $ObjMemory = $ObjService.ExecQuery('SELECT * FROM Win32_PhysicalMemory') Local $ObjNet = $ObjService.ExecQuery('SELECT * FROM Win32_NetworkAdapter', 'WQL', 0x30) Local $ObjGraph = $ObjService.ExecQuery('SELECT * FROM Win32_VideoController', 'WQL', 0x30) Local $ObjDrive = $ObjService.ExecQuery('SELECT * FROM Win32_DiskDrive', 'WQL', 0x30) Local $ObjCDDrive = $ObjService.ExecQuery('SELECT * FROM Win32_CDROMDrive', 'WQL', 0x30) Local $ObjRam = $ObjService.ExecQuery('SELECT * FROM Win32_ComputerSystem') Local $sNameComput = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\DataStore\Machine\0', 'szTargetName') Local $sProduct = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ProductName') Local $sBuild = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ReleaseId') Local $sItemM, $sInfo = '[КОНФИГУРАЦИЯ:]' & @CRLF & @TAB & 'Имя компьютера: ......... ' & $sNameComput & @CRLF & _ @TAB & 'Операционная система: ... ' & $sProduct & ' ' & $sBuild & ' ' & '(' & @OSArch & ')' & @CRLF Local $aDisplayInfo = Display_Info() if not $aDisplayInfo = "" then $sInfo &= @TAB & 'UserFriendlyName: ........' & $aDisplayInfo[0] & @CRLF $sInfo &= @TAB & 'SerialNumberId: ........' & $aDisplayInfo[1] & @CRLF endif If IsObj($ObjService) Then For $objItemP In $ObjProcessor $sInfo &= @TAB & 'Процессор: .............. ' & $objItemP.Name & @CRLF Next For $objItemMB In $ObjMB $sInfo &= @TAB & 'Материнская плата: ...... ' & $objItemMB.Product & @CRLF Next For $ObjItemM In $ObjMemory $sItemM = $objItemM.Speed Next For $objItemR In $ObjRam $sInfo &= @TAB & 'RAM: .................... ' & Round($objItemR.TotalPhysicalMemory / 1024 / 1024 ^ 2, 0) & ' GB | ' & $ObjMemory.Count & ' pieces | ' & $sItemM & ' Mhz' & @CRLF Next For $ObjItemG In $ObjGraph $sInfo &= @TAB & 'Видеокарта: ............. ' & $ObjItemG.Name & ' | RAM: ' & $ObjItemG.AdapterRAM / 1024 ^ 2 & ' Mb' & @CRLF Next For $ObjItemD In $ObjDrive $sInfo &= @TAB & 'Жесткие диск: ........... ' & $ObjItemD.Model & ' | Size: ' & Round($ObjItemD.Size / 1024 / 1024 / 1024) & ' Gb' & @CRLF Next For $ObjItemCD In $ObjCDDrive $sInfo &= @TAB & 'Дисковод: ............... ' & $ObjItemCD.Name & @CRLF Next For $ObjItemN In $ObjNet If $ObjItemN.PhysicalAdapter = True Then $sInfo &= @TAB & 'Сетевой адаптер: ........ ' & $ObjItemN.Name & @CRLF EndIf Next Local $aDisplayInfo = Display_Info() if not $aDisplayInfo = "" then $sInfo &= @TAB & 'UserFriendlyName: ........' & $aDisplayInfo[0] & @CRLF $sInfo &= @TAB & 'SerialNumberId: ........' & $aDisplayInfo[1] & @CRLF endif EndIf $sInfo &= @CRLF Return $sInfo EndFunc ;==>_InfoPC Func _hide() ;функция. отключает элементы ввода и кнопку, пока работает скрипт GUICtrlSetState($iConnect, $GUI_disable) GUICtrlSetState($iKabina, $GUI_disable) GUICtrlSetState($iType, $GUI_disable) GUICtrlSetState($iModel, $GUI_disable) GUICtrlSetState($iSerialNum, $GUI_disable) GUICtrlSetState($iInv, $GUI_disable) EndFunc ;==>_hide Func _show() ;функция. включает элементы ввода и кнопку, когда скрипт отработал GUICtrlSetState($iConnect, $GUI_enable) GUICtrlSetState($iKabina, $GUI_enable) GUICtrlSetState($iType, $GUI_enable) GUICtrlSetState($iModel, $GUI_enable) GUICtrlSetState($iSerialNum, $GUI_enable) GUICtrlSetState($iInv, $GUI_enable) EndFunc ;==>_show Opt("MustDeclareVars",1) Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next $lss=Null $sls=Null $sInfo &= @CRLF EndFunc Func _ShowOtchot() $Form1 = GUICreate("Отчёт", 482, 438, Default, Default, Default, 0x00000080, $Main) GUISetBkColor(0x02101B) $Edit1 = GUICtrlCreateEdit("", 0, 0, 482, 385) GUICtrlSetData(-1, FileRead($fFile)) $CopyBtn = GUICtrlCreateButton("Копировать", 194, 400, 99, 25, $BS_DEFPUSHBUTTON) For $i = 0 To 230 Step 9 Sleep(10) WinSetTrans($Form1, '', $i) ;Прозрачность 0-255 Next GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $CopyBtn ClipPut(GUICtrlRead($Edit1)) DirCreate (@ScriptDir & "\COPY") FileCopy(@ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt", @ScriptDir & "\COPY", 1) MsgBox(64, "Статус", 'Скопировано', Default, $Main) Case -3 GUIDelete($Form1) WinActivate($Main) ExitLoop EndSwitch WEnd EndFunc Func Display_Info() Local $oComErr, $oWmi, $oInstances $oComErr = ObjEvent("AutoIt.Error", comm_error_handler) #forceref $oComErr ;Get WMI object $oWmi = ObjGet("winmgmts:\root\WMI") If Not IsObj($oWmi) Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to create WMI object") ;Select object instances $oInstances = $oWmi.ExecQuery("SELECT * FROM WMIMonitorID") If $oInstances.Count = 0 Then Exit MsgBox($MB_ICONWARNING,"Warning","No objects found") ; Changed part Local $aReturn[2] ; change number if you want to return more info ;Display instance properties For $oInstance in $oInstances With $oInstance ConsoleWrite(@CRLF) If IsArray(.UserFriendlyName) Then $aReturn[0] = StringFormat("UserFriendlyName = %s", convert_uint16_array_to_string(.UserFriendlyName)) If IsArray(.SerialNumberId) Then $aReturn[1] = StringFormat("SerialNumberId = %s", convert_uint16_array_to_string(.SerialNumberId)) EndWith Next Return $aReturn EndFunc Func convert_uint16_array_to_string($aBytes) Local $s = "" For $i in $aBytes If $i <> 0 Then $s &= Chr($i) Next Return $s EndFunc Func comm_error_handler($oComError) ConsoleWrite(@CRLF) ConsoleWrite(StringFormat("Script Line = %s", $oComError.ScriptLine) & @CRLF) ConsoleWrite(StringFormat("Win Err Desc = %s", StringStripWS($oComError.WinDescription, $STR_STRIPTRAILING)) & @CRLF) ConsoleWrite(StringFormat("Error Number = %i (0x%x)", $oComError.Number, $oComError.Number) & @CRLF) ConsoleWrite(StringFormat("Error Desc = %s", $oComError.Description) & @CRLF) Exit EndFunc
GokAy Posted November 18, 2020 Posted November 18, 2020 (edited) I have already added that part, just use the script from my earlier post (https://www.autoitscript.com/forum/topic/204409-wmi-in-autoit-moved/?do=findComment&comment=1468948). I can't test your script as I don't have the language pack. Everything is ?????? Edited November 18, 2020 by GokAy DirtyJohny 1
DirtyJohny Posted November 18, 2020 Author Posted November 18, 2020 8 minutes ago, GokAy said: Я уже добавил эту часть, просто используйте сценарий из моей предыдущей публикации. Я не могу протестировать ваш сценарий, так как у меня нет языкового пакета. Все ?????? expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <Constants.au3> #include <Array.au3> #RequireAdmin #NoTrayIcon ;Все что написано, посде ';' явлется комментарием и ни как не влияет на работу скрипта. Global $iKabina, $iType, $iModel, $iSerialNum, $iInv ;объявляем переменные, которые будут использоваться в цикле Global $rKabina, $rType, $rModel, $rSerialNum, $rInv, $Main, $iConnect, $hFile, $sInfo, $CopyBtn, $fFile = @ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt" $Main = GUICreate('Inventarisation', 315, 352) ;рисуем главное окно GUISetBkColor(0x02101B) $iKabina = GUICtrlCreateInput('', 20, 30, 272, 21) $iType = GUICtrlCreateInput('', 20, 75, 272, 21) $iModel = GUICtrlCreateInput('', 20, 120, 272, 21) $iSerialNum = GUICtrlCreateInput('', 20, 165, 272, 21) $iInv = GUICtrlCreateInput('', 20, 210, 272, 21) GUISetFont(10, 800, 0, 'Tahoma'); Устанавливает шрифт по умолчанию для последующих элементов GUI-окна. $iConnect = GUICtrlCreateButton('Send', 23, 305, 267, 33, $BS_DEFPUSHBUTTON) ;создаем кнопку подключения GUICtrlSetDefColor(0xDEDEDE); Устанавливает цвет текста по умолчанию для последующих элементов GUI-окна. GUICtrlCreateLabel('Cabinet', 20, 10, 150, 17) GUICtrlCreateLabel('Type', 20, 55, 150, 17) GUICtrlCreateLabel('Model', 20, 100, 150, 17) GUICtrlCreateLabel('Сerial number PC', 20, 145, 150, 17) GUICtrlCreateLabel('Inventarisation number', 20, 190, 150, 17) WinSetTrans($Main, '', 0) GUISetState(@SW_SHOW) For $i = 0 To 230 Step 9 Sleep(10) WinSetTrans($Main, '', $i) ;Прозрачность 0-255 Next $hFile = FileOpen(@ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt", 1) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iConnect $rKabina = GUICtrlRead($iKabina) $rType = GUICtrlRead($iType) $rModel = GUICtrlRead($iModel) $rSerialNum = GUICtrlRead($iSerialNum) $rInv = GUICtrlRead($iInv) Select Case (Not StringStripWS($rKabina, 8)) MsgBox(16 + 8192 + 262144, 'Error', 'Поле Кабинет - пустое') Case (Not StringStripWS($rType, 8)) MsgBox(16 + 8192 + 262144, 'Error', 'Поле Тип - пустое') Case (Not StringStripWS($rModel, 8)) MsgBox(16 + 8192 + 262144, 'Error', 'Поле Модель - пустое') Case (Not StringStripWS($rSerialNum, 8)) MsgBox(16 + 8192 + 262144, 'Error', 'Поле Серийный номер - пустое') Case (Not StringStripWS($rInv, 8)) MsgBox(16 + 8192 + 262144, 'Error', 'Поле Инвентарник - пустое') Case $hFile = -1 MsgBox(4096, 'Ошибка', 'Невозможно открыть файл.') Case Else _hide() ;отключает все элементы ввода и кнопку $sInfo = '======================================================================================' & @CRLF & _ '[МЕСТОПОЛОЖЕНИЕ:]' & @CRLF & _ @TAB & 'Date: ................... ' & @MDAY & '.' & @MON & '.' & @YEAR & ' ' & @CRLF & _ @TAB & 'Cabinet: ................ ' & $rKabina & @CRLF & _ @TAB & 'Type: .................... ' & $rType & @CRLF & _ @TAB & 'Model: ................. ' & $rModel & @CRLF & _ @TAB & 'Сerial number PC: ......... ' & $rSerialNum & @CRLF & _ @TAB & 'Inventarisation number: ...... ' & $rInv & @CRLF & _ @TAB & 'Current User: ......... ' & @UserName & @CRLF & @CRLF $sInfo &= _InfoPC() FileWrite($hFile, $sInfo) FileClose($hFile) _show() ;включает все элементы ввода и кнопку _ShowOtchot() EndSelect EndSwitch WEnd Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) Local $ObjProcessor = $ObjService.ExecQuery('SELECT * FROM Win32_Processor', 'WQL', 0x30) Local $ObjMemory = $ObjService.ExecQuery('SELECT * FROM Win32_PhysicalMemory') Local $ObjNet = $ObjService.ExecQuery('SELECT * FROM Win32_NetworkAdapter', 'WQL', 0x30) Local $ObjGraph = $ObjService.ExecQuery('SELECT * FROM Win32_VideoController', 'WQL', 0x30) Local $ObjDrive = $ObjService.ExecQuery('SELECT * FROM Win32_DiskDrive', 'WQL', 0x30) Local $ObjCDDrive = $ObjService.ExecQuery('SELECT * FROM Win32_CDROMDrive', 'WQL', 0x30) Local $ObjRam = $ObjService.ExecQuery('SELECT * FROM Win32_ComputerSystem') Local $sNameComput = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\DataStore\Machine\0', 'szTargetName') Local $sProduct = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ProductName') Local $sBuild = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ReleaseId') Local $sItemM, $sInfo = '[Configuration:]' & @CRLF & @TAB & 'Computer name: ......... ' & $sNameComput & @CRLF & _ @TAB & 'Operating system: ... ' & $sProduct & ' ' & $sBuild & ' ' & '(' & @OSArch & ')' & @CRLF Local $aDisplayInfo = Display_Info() if not $aDisplayInfo = "" then $sInfo &= @TAB & 'UserFriendlyName: ........' & $aDisplayInfo[0] & @CRLF $sInfo &= @TAB & 'SerialNumberId: ........' & $aDisplayInfo[1] & @CRLF endif If IsObj($ObjService) Then For $objItemP In $ObjProcessor $sInfo &= @TAB & 'Processor: .............. ' & $objItemP.Name & @CRLF Next For $objItemMB In $ObjMB $sInfo &= @TAB & 'МMotherboard: ...... ' & $objItemMB.Product & @CRLF Next For $ObjItemM In $ObjMemory $sItemM = $objItemM.Speed Next For $objItemR In $ObjRam $sInfo &= @TAB & 'RAM: .................... ' & Round($objItemR.TotalPhysicalMemory / 1024 / 1024 ^ 2, 0) & ' GB | ' & $ObjMemory.Count & ' pieces | ' & $sItemM & ' Mhz' & @CRLF Next For $ObjItemG In $ObjGraph $sInfo &= @TAB & 'Videocard: ............. ' & $ObjItemG.Name & ' | RAM: ' & $ObjItemG.AdapterRAM / 1024 ^ 2 & ' Mb' & @CRLF Next For $ObjItemD In $ObjDrive $sInfo &= @TAB & 'Hard drives: ........... ' & $ObjItemD.Model & ' | Size: ' & Round($ObjItemD.Size / 1024 / 1024 / 1024) & ' Gb' & @CRLF Next For $ObjItemCD In $ObjCDDrive $sInfo &= @TAB & 'CD-Drive: ............... ' & $ObjItemCD.Name & @CRLF Next For $ObjItemN In $ObjNet If $ObjItemN.PhysicalAdapter = True Then $sInfo &= @TAB & 'Network adapter: ........ ' & $ObjItemN.Name & @CRLF EndIf Next Local $aDisplayInfo = Display_Info() if not $aDisplayInfo = "" then $sInfo &= @TAB & 'UserFriendlyName: ........' & $aDisplayInfo[0] & @CRLF $sInfo &= @TAB & 'SerialNumberId: ........' & $aDisplayInfo[1] & @CRLF endif EndIf $sInfo &= @CRLF Return $sInfo EndFunc ;==>_InfoPC Func _hide() ;функция. отключает элементы ввода и кнопку, пока работает скрипт GUICtrlSetState($iConnect, $GUI_disable) GUICtrlSetState($iKabina, $GUI_disable) GUICtrlSetState($iType, $GUI_disable) GUICtrlSetState($iModel, $GUI_disable) GUICtrlSetState($iSerialNum, $GUI_disable) GUICtrlSetState($iInv, $GUI_disable) EndFunc ;==>_hide Func _show() ;функция. включает элементы ввода и кнопку, когда скрипт отработал GUICtrlSetState($iConnect, $GUI_enable) GUICtrlSetState($iKabina, $GUI_enable) GUICtrlSetState($iType, $GUI_enable) GUICtrlSetState($iModel, $GUI_enable) GUICtrlSetState($iSerialNum, $GUI_enable) GUICtrlSetState($iInv, $GUI_enable) EndFunc ;==>_show Opt("MustDeclareVars",1) Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next $lss=Null $sls=Null $sInfo &= @CRLF EndFunc Func _ShowOtchot() $Form1 = GUICreate("Order", 482, 438, Default, Default, Default, 0x00000080, $Main) GUISetBkColor(0x02101B) $Edit1 = GUICtrlCreateEdit("", 0, 0, 482, 385) GUICtrlSetData(-1, FileRead($fFile)) $CopyBtn = GUICtrlCreateButton("Copy in txt", 194, 400, 99, 25, $BS_DEFPUSHBUTTON) For $i = 0 To 230 Step 9 Sleep(10) WinSetTrans($Form1, '', $i) ;Прозрачность 0-255 Next GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $CopyBtn ClipPut(GUICtrlRead($Edit1)) DirCreate (@ScriptDir & "\COPY") FileCopy(@ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt", @ScriptDir & "\COPY", 1) MsgBox(64, "Статус", 'Copied', Default, $Main) Case -3 GUIDelete($Form1) WinActivate($Main) ExitLoop EndSwitch WEnd EndFunc Func Display_Info() Local $oComErr, $oWmi, $oInstances $oComErr = ObjEvent("AutoIt.Error", comm_error_handler) #forceref $oComErr ;Get WMI object $oWmi = ObjGet("winmgmts:\root\WMI") If Not IsObj($oWmi) Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to create WMI object") ;Select object instances $oInstances = $oWmi.ExecQuery("SELECT * FROM WMIMonitorID") If $oInstances.Count = 0 Then Exit MsgBox($MB_ICONWARNING,"Warning","No objects found") ; Changed part Local $aReturn[2] ; change number if you want to return more info ;Display instance properties For $oInstance in $oInstances With $oInstance ConsoleWrite(@CRLF) If IsArray(.UserFriendlyName) Then $aReturn[0] = StringFormat("UserFriendlyName = %s", convert_uint16_array_to_string(.UserFriendlyName)) If IsArray(.SerialNumberId) Then $aReturn[1] = StringFormat("SerialNumberId = %s", convert_uint16_array_to_string(.SerialNumberId)) EndWith Next Return $aReturn EndFunc Func convert_uint16_array_to_string($aBytes) Local $s = "" For $i in $aBytes If $i <> 0 Then $s &= Chr($i) Next Return $s EndFunc Func comm_error_handler($oComError) ConsoleWrite(@CRLF) ConsoleWrite(StringFormat("Script Line = %s", $oComError.ScriptLine) & @CRLF) ConsoleWrite(StringFormat("Win Err Desc = %s", StringStripWS($oComError.WinDescription, $STR_STRIPTRAILING)) & @CRLF) ConsoleWrite(StringFormat("Error Number = %i (0x%x)", $oComError.Number, $oComError.Number) & @CRLF) ConsoleWrite(StringFormat("Error Desc = %s", $oComError.Description) & @CRLF) Exit EndFunc I translate.Not work your function(
GokAy Posted November 18, 2020 Posted November 18, 2020 Can you try this one? expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <Constants.au3> #include <Array.au3> #RequireAdmin #NoTrayIcon ;??? ??? ????????, ????? ';' ??????? ???????????? ? ?? ??? ?? ?????? ?? ?????? ???????. ;~ Global $aDispTest = Display_Info() ;~ if $aDispTest = "" Then ;~ ConsoleWrite("problem" & @crlf) ;~ Else ;~ for $i = 0 to (ubound($aDispTest)/2)-1 ;~ ConsoleWrite("Str: " & $i & " " & $aDispTest[(2*$i)] & @crlf) ;~ ConsoleWrite("Str: " & $i & " " & $aDispTest[(2*$i)+1] & @crlf) ;~ Next ;~ EndIf ;~ Exit Global $iKabina, $iType, $iModel, $iSerialNum, $iInv ;????????? ??????????, ??????? ????? ?????????????? ? ????? Global $rKabina, $rType, $rModel, $rSerialNum, $rInv, $Main, $iConnect, $hFile, $sInfo, $CopyBtn, $fFile = @ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt" $Main = GUICreate('Inventarisation', 315, 352) ;?????? ??????? ???? GUISetBkColor(0x02101B) $iKabina = GUICtrlCreateInput('', 20, 30, 272, 21) $iType = GUICtrlCreateInput('', 20, 75, 272, 21) $iModel = GUICtrlCreateInput('', 20, 120, 272, 21) $iSerialNum = GUICtrlCreateInput('', 20, 165, 272, 21) $iInv = GUICtrlCreateInput('', 20, 210, 272, 21) GUISetFont(10, 800, 0, 'Tahoma'); ????????????? ????? ?? ????????? ??? ??????????? ????????? GUI-????. $iConnect = GUICtrlCreateButton('Send', 23, 305, 267, 33, $BS_DEFPUSHBUTTON) ;??????? ?????? ??????????? GUICtrlSetDefColor(0xDEDEDE); ????????????? ???? ?????? ?? ????????? ??? ??????????? ????????? GUI-????. GUICtrlCreateLabel('Cabinet', 20, 10, 150, 17) GUICtrlCreateLabel('Type', 20, 55, 150, 17) GUICtrlCreateLabel('Model', 20, 100, 150, 17) GUICtrlCreateLabel('?erial number PC', 20, 145, 150, 17) GUICtrlCreateLabel('Inventarisation number', 20, 190, 150, 17) WinSetTrans($Main, '', 0) GUISetState(@SW_SHOW) For $i = 0 To 230 Step 9 Sleep(10) WinSetTrans($Main, '', $i) ;???????????? 0-255 Next $hFile = FileOpen(@ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt", 1) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iConnect $rKabina = GUICtrlRead($iKabina) $rType = GUICtrlRead($iType) $rModel = GUICtrlRead($iModel) $rSerialNum = GUICtrlRead($iSerialNum) $rInv = GUICtrlRead($iInv) Select Case (Not StringStripWS($rKabina, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??????? - ??????') Case (Not StringStripWS($rType, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??? - ??????') Case (Not StringStripWS($rModel, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ?????? - ??????') Case (Not StringStripWS($rSerialNum, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ???????? ????? - ??????') Case (Not StringStripWS($rInv, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??????????? - ??????') Case $hFile = -1 MsgBox(4096, '??????', '?????????? ??????? ????.') Case Else _hide() ;????????? ??? ???????? ????? ? ?????? $sInfo = '======================================================================================' & @CRLF & _ '[??????????????:]' & @CRLF & _ @TAB & 'Date: ................... ' & @MDAY & '.' & @MON & '.' & @YEAR & ' ' & @CRLF & _ @TAB & 'Cabinet: ................ ' & $rKabina & @CRLF & _ @TAB & 'Type: .................... ' & $rType & @CRLF & _ @TAB & 'Model: ................. ' & $rModel & @CRLF & _ @TAB & '?erial number PC: ......... ' & $rSerialNum & @CRLF & _ @TAB & 'Inventarisation number: ...... ' & $rInv & @CRLF & _ @TAB & 'Current User: ......... ' & @UserName & @CRLF & @CRLF $sInfo &= _InfoPC() FileWrite($hFile, $sInfo) FileClose($hFile) _show() ;???????? ??? ???????? ????? ? ?????? _ShowOtchot() EndSelect EndSwitch WEnd Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) Local $ObjProcessor = $ObjService.ExecQuery('SELECT * FROM Win32_Processor', 'WQL', 0x30) Local $ObjMemory = $ObjService.ExecQuery('SELECT * FROM Win32_PhysicalMemory') Local $ObjNet = $ObjService.ExecQuery('SELECT * FROM Win32_NetworkAdapter', 'WQL', 0x30) Local $ObjGraph = $ObjService.ExecQuery('SELECT * FROM Win32_VideoController', 'WQL', 0x30) Local $ObjDrive = $ObjService.ExecQuery('SELECT * FROM Win32_DiskDrive', 'WQL', 0x30) Local $ObjCDDrive = $ObjService.ExecQuery('SELECT * FROM Win32_CDROMDrive', 'WQL', 0x30) Local $ObjRam = $ObjService.ExecQuery('SELECT * FROM Win32_ComputerSystem') Local $sNameComput = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\DataStore\Machine\0', 'szTargetName') Local $sProduct = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ProductName') Local $sBuild = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ReleaseId') Local $sItemM, $sInfo = '[Configuration:]' & @CRLF & @TAB & 'Computer name: ......... ' & $sNameComput & @CRLF & _ @TAB & 'Operating system: ... ' & $sProduct & ' ' & $sBuild & ' ' & '(' & @OSArch & ')' & @CRLF If IsObj($ObjService) Then For $objItemP In $ObjProcessor $sInfo &= @TAB & 'Processor: .............. ' & $objItemP.Name & @CRLF Next For $objItemMB In $ObjMB $sInfo &= @TAB & '?Motherboard: ...... ' & $objItemMB.Product & @CRLF Next For $ObjItemM In $ObjMemory $sItemM = $objItemM.Speed Next For $objItemR In $ObjRam $sInfo &= @TAB & 'RAM: .................... ' & Round($objItemR.TotalPhysicalMemory / 1024 / 1024 ^ 2, 0) & ' GB | ' & $ObjMemory.Count & ' pieces | ' & $sItemM & ' Mhz' & @CRLF Next For $ObjItemG In $ObjGraph $sInfo &= @TAB & 'Videocard: ............. ' & $ObjItemG.Name & ' | RAM: ' & $ObjItemG.AdapterRAM / 1024 ^ 2 & ' Mb' & @CRLF Next For $ObjItemD In $ObjDrive $sInfo &= @TAB & 'Hard drives: ........... ' & $ObjItemD.Model & ' | Size: ' & Round($ObjItemD.Size / 1024 / 1024 / 1024) & ' Gb' & @CRLF Next For $ObjItemCD In $ObjCDDrive $sInfo &= @TAB & 'CD-Drive: ............... ' & $ObjItemCD.Name & @CRLF Next For $ObjItemN In $ObjNet If $ObjItemN.PhysicalAdapter = True Then $sInfo &= @TAB & 'Network adapter: ........ ' & $ObjItemN.Name & @CRLF EndIf Next EndIf Local $aDisplayInfo = Display_Info() if not $aDisplayInfo = "" then for $i = 0 to (ubound($aDisplayInfo)/2)-1 $sInfo &= @TAB & $aDisplayInfo[(2*$i)] & @CRLF $sInfo &= @TAB & $aDisplayInfo[(2*$i)+1] & @CRLF Next EndIf $sInfo &= @CRLF Return $sInfo EndFunc ;==>_InfoPC Func _hide() ;???????. ????????? ???????? ????? ? ??????, ???? ???????? ?????? GUICtrlSetState($iConnect, $GUI_disable) GUICtrlSetState($iKabina, $GUI_disable) GUICtrlSetState($iType, $GUI_disable) GUICtrlSetState($iModel, $GUI_disable) GUICtrlSetState($iSerialNum, $GUI_disable) GUICtrlSetState($iInv, $GUI_disable) EndFunc ;==>_hide Func _show() ;???????. ???????? ???????? ????? ? ??????, ????? ?????? ????????? GUICtrlSetState($iConnect, $GUI_enable) GUICtrlSetState($iKabina, $GUI_enable) GUICtrlSetState($iType, $GUI_enable) GUICtrlSetState($iModel, $GUI_enable) GUICtrlSetState($iSerialNum, $GUI_enable) GUICtrlSetState($iInv, $GUI_enable) EndFunc ;==>_show Opt("MustDeclareVars",1) Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next $lss=Null $sls=Null $sInfo &= @CRLF EndFunc Func _ShowOtchot() Local $Form1 = GUICreate("Order", 482, 438, Default, Default, Default, 0x00000080, $Main) GUISetBkColor(0x02101B) Local $Edit1 = GUICtrlCreateEdit("", 0, 0, 482, 385) GUICtrlSetData(-1, FileRead($fFile)) $CopyBtn = GUICtrlCreateButton("Copy in txt", 194, 400, 99, 25, $BS_DEFPUSHBUTTON) For $i = 0 To 230 Step 9 Sleep(10) WinSetTrans($Form1, '', $i) ;???????????? 0-255 Next GUISetState(@SW_SHOW) While 1 Local $msg = GUIGetMsg() Switch $msg Case $CopyBtn ClipPut(GUICtrlRead($Edit1)) DirCreate (@ScriptDir & "\COPY") FileCopy(@ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt", @ScriptDir & "\COPY", 1) MsgBox(64, "??????", 'Copied', Default, $Main) Case -3 GUIDelete($Form1) WinActivate($Main) ExitLoop EndSwitch WEnd EndFunc Func Display_Info() Local $oComErr, $oWmi, $oInstances $oComErr = ObjEvent("AutoIt.Error", comm_error_handler) #forceref $oComErr ;Get WMI object $oWmi = ObjGet("winmgmts:\root\WMI") If Not IsObj($oWmi) Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to create WMI object") ;Select object instances $oInstances = $oWmi.ExecQuery("SELECT * FROM WMIMonitorID") If $oInstances.Count = 0 Then Exit MsgBox($MB_ICONWARNING,"Warning","No objects found") ; Changed part Local $aReturn[2] ; change number if you want to return more info Local $iDisplayCount = 1 ;Display instance properties For $oInstance in $oInstances With $oInstance ConsoleWrite(@CRLF) if ubound($aReturn) < $iDisplayCount * 2 then redim $aReturn[2*$iDisplayCount] If IsArray(.UserFriendlyName) Then $aReturn[2*($iDisplayCount-1)] = StringFormat("UserFriendlyName = %s", convert_uint16_array_to_string(.UserFriendlyName)) If IsArray(.SerialNumberId) Then $aReturn[2*($iDisplayCount-1)+1] = StringFormat("SerialNumberId = %s", convert_uint16_array_to_string(.SerialNumberId)) $iDisplayCount += 1 EndWith Next Return $aReturn EndFunc Func convert_uint16_array_to_string($aBytes) Local $s = "" For $i in $aBytes If $i <> 0 Then $s &= Chr($i) Next Return $s EndFunc Func comm_error_handler($oComError) ConsoleWrite(@CRLF) ConsoleWrite(StringFormat("Script Line = %s", $oComError.ScriptLine) & @CRLF) ConsoleWrite(StringFormat("Win Err Desc = %s", StringStripWS($oComError.WinDescription, $STR_STRIPTRAILING)) & @CRLF) ConsoleWrite(StringFormat("Error Number = %i (0x%x)", $oComError.Number, $oComError.Number) & @CRLF) ConsoleWrite(StringFormat("Error Desc = %s", $oComError.Description) & @CRLF) Exit EndFunc I have added a test part at the beginning since the script still did not run, and commented out that section. ;~ Global $aDispTest = Display_Info() ;~ if $aDispTest = "" Then ;~ ConsoleWrite("problem" & @crlf) ;~ Else ;~ for $i = 0 to (ubound($aDispTest)/2)-1 ;~ ConsoleWrite("Str: " & $i & " " & $aDispTest[(2*$i)] & @crlf) ;~ ConsoleWrite("Str: " & $i & " " & $aDispTest[(2*$i)+1] & @crlf) ;~ Next ;~ EndIf ;~ Exit I have 2 monitors, one is laptop built in, another Samsung external. This is what I get: Str: 0 UserFriendlyName = SyncMaster Str: 0 SerialNumberId = 1110529591 Str: 1 Str: 1 SerialNumberId = 0 @TheXman Is this expected? Or am I doing something wrong with the array? DirtyJohny 1
DirtyJohny Posted November 18, 2020 Author Posted November 18, 2020 6 minutes ago, GokAy said: Вы можете попробовать это? expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <Constants.au3> #include <Array.au3> #RequireAdmin #NoTrayIcon ; ??? ??? ????????, ????? ';' ??????? ???????????? ? ?? ??? ?? ?????? ?? ?????? ???????. ; ~ Global $ aDispTest = Display_Info () ; ~ if $ aDispTest = "" Then ; ~ ConsoleWrite ("проблема" & @crlf) ; ~ Else ; ~ для $ i = 0 to (ubound ($ aDispTest) / 2) - 1 ; ~ ConsoleWrite ("Str:" & $ i & "" & $ aDispTest [(2 * $ i)] & @crlf) ; ~ ConsoleWrite ("Str:" & $ i & "" & Global $ iKabina , $ iType , $ iModel , $ iSerialNum , $ iInv ; ????????? ??????????, ??????? ????? ?????????????? ? ????? Global $ rKabina , $ rType , $ rModel , $ rSerialNum , $ rInv , $ Main , $ iConnect , $ hFile , $ sInfo , $ CopyBtn , $ fFile = @ScriptDir & "\" & "(" & @MDAY & ". " & @MON & ". " & @YEAR & ")" & ".txt" $ Main = GUICreate ( 'Inventarisation' , 315 , 352 ) ; ?????? ??????? ???? GUISetBkColor ( 0x02101B ) $ iKabina = GUICtrlCreateInput ( '' , 20 , 30 , 272 , 21 ) $ iType = GUICtrlCreateInput ( '' , 20 , 75 , 272 , 21 ) $ iModel = GUICtrlCreateInput ( '' , 20 , 120 , 272 , 21 ) $ iSerialNum = GUICtrlCreateInput ( '' , 20 , 165 , 272 , 21 ) $ iInv = GUICtrlCreateInput ( '' , 20 , 210 , 272 , 21 ) GUISetFont ( 10 , 800 , 0 , 'Тахома' ); ????????????? ????? ?? ????????? ??? ??????????? ????????? GUI - ????. $ iConnect = GUICtrlCreateButton ( 'Отправить' , 23 , 305 , 267 , 33 , $ BS_DEFPUSHBUTTON ) ; ??????? ?????? ??????????? GUICtrlSetDefColor ( 0xDEDEDE ) ; ????????????? ???? ?????? ?? ????????? ??? ??????????? ????????? GUI - ????. GUICtrlCreateLabel ( 'Кабинет' , 20 , 10 , 150 , 17 ) GUICtrlCreateLabel ( 'Тип' , 20, 55 , 150 , 17 ) GUICtrlCreateLabel ( 'Модель' , 20 , 100 , 150 , 17 ) GUICtrlCreateLabel ( 'серийный номер ПК' , 20 , 145 , 150 , 17 ) GUICtrlCreateLabel ( 'Инвентаризационный номер' , 20 , 190 , 150 , 17 ) WinSetTrans ( $ Main , '' , 0 ) GUISetState ( @SW_SHOW ) Для $ i = от 0 до 230 Шаг 9 Сон ( 10 ) WinSetTrans ( $ Main , '' , $ i ) ; ???????????? 0-255 Далее $ hFile = FileOpen ( @ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt" , В то время как один переключатель GUIGetMsg ( ) Case $ GUI_EVENT_CLOSE Выход Case $ IConnect $ rKabina = GUICtrlRead ( $ iKabina ) $ RTYPE = GUICtrlRead ( $ IType ) $ rModel = GUICtrlRead ( $ IModel ) $ rSerialNum = GUICtrlRead ( $ iSerialNum ) $ RINV = GUICtrlRead ( $ iInv ) Выбрать регистр ( не StringStripWS ($ rKabina , 8 ) ) MsgBox ( 16 + 8192 + 262144 , 'Error' , '???? ??????? - ??????' ) Case ( Not StringStripWS ( $ rType , 8 ) ) MsgBox ( 16 + 8192 + 262144 , 'Ошибка' , '???? ??? - ??????' ) Случай ( не StringStripWS ( $ rModel , 8 ) ) MsgBox (16 + 8192 + 262144 , 'Ошибка' , '???? ?????? - ?????? ' ) Case ( Not StringStripWS ( $ rSerialNum , 8 ) ) MsgBox ( 16 + 8192 + 262144 , 'Ошибка' , '???? ???????? ????? - ??????' ) Случай ( не StringStripWS ( $ rInv , 8 ) ) MsgBox ( 16 + 8192 + 262144 , 'Ошибка' , '???? ??????????? - ?????? ' ) Case $ hFile = - 1 MsgBox ( 4096 , '??????' , '?????????? ??????? ????.' ) Case Else _ hide ( ) ; ????????? ??? ???????? ????? ? ?????? $ sInfo = '================================================ ======================================== ' & @CRLF & _ ' [?? ????????????:] ' & @CRLF & _ @TAB & ' Дата: ................... ' & & '.' & @MON & '.' & @YEAR & '' & @CRLF & _ @TAB & 'Cabinet: ................' & $ rKabina & @CRLF & _ @TAB & 'Тип: .. .................. ' & $ rType & @CRLF & _ @TAB & ' Модель: ................. ' & $ rModel & @CRLF & _ @TAB & ' пробный номер ПК: ......... & _ @TAB & 'Номер инвентаризации : ......' & $ rInv & @CRLF & _ @TAB & 'Текущий пользователь: .........' & @UserName & @CRLF & @CRLF $ sInfo & = _ InfoPC ( ) FileWrite ( $ hFile , $ sInfo ) FileClose ( $ hFile ) _ show ( ) ; ???????? ??? ???????? ????? ? ?????? _ ShowOtchot ( ) EndSelect EndSwitch WEnd Func _ InfoPC ( ) Local $ ObjService = ObjGet ( 'winmgmts: {impersonationLevel = impersonate}! \\' & @ComputerName & '\ root \ cimv2' ) Local $ ObjMB = $ ObjService . ExecQuery ( 'SELECT * FROM Win32_BaseBoard' , 'WQL' , 0x30 ) Локальный $ ObjProcessor = $ ObjService . ExecQuery ( 'SELECT * FROM Win32_Processor' , 'WQL' , 0x30 ) Локальный $ ObjMemory = $ ObjService . ExecQuery ( 'SELECT * FROM Win32_PhysicalMemory' ) Локальный $ ObjNet = $ ObjService . ExecQuery ( 'SELECT * FROM Win32_NetworkAdapter' , 'WQL' , 0x30 ) Локальный $ ObjGraph = $ ObjService . ExecQuery ( 'SELECT * FROM Win32_VideoController' , 'WQL' , 0x30 ) Локальный $ ObjDrive = $ ObjService . ExecQuery ( 'ВЫБРАТЬ * ИЗ Win32_DiskDrive', 'WQL' , 0x30 ) Локальный $ ObjCDDrive = $ ObjService . ExecQuery ( 'SELECT * FROM Win32_CDROMDrive' , 'WQL' , 0x30 ) Локальный $ ObjRam = $ ObjService . ExecQuery ( 'SELECT * FROM Win32_ComputerSystem' ) Local $ sNameComput = RegRead ( 'HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Group Policy \ DataStore \ Machine \ 0' , 'szTargetName' ) Local $ sProduct = RegRead ('HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion' , 'ProductName' ) Local $ sBuild = RegRead ( 'HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion' , 'ReleaseId' ) Local $ sItemM , $ sInfo = '[Конфигурация :] ' & @CRLF & @TAB & ' Имя компьютера: ......... ' & $ sNameComput & @CRLF & _ @TAB & ' Операционная система: ... ' & $ sProduct & '' & $ sBuild & '' & '(' & @OSArch & ')' & @CRLF Если IsObj ( $ ObjService ) Тогда для $ objItemP В $ ObjProcessor $ sInfo & = @tab & «Процессор: .......... .... ' & $ objItemP . Имя & @CRLF Далее для $ objItemMB в $ ObjMB $ sInfo & = @TAB & '? Motherboard: ......' & $ objItemMB . Продукт и Для $ ObjItemM в $ ObjMemory $ sItemM = $ objItemM . Скорость Next Для $ objItemR В $ ObjRam $ sInfo & = @TAB & 'Оперативная память: ....................' & Round ( $ objItemR . TotalPhysicalMemory / 1024 / 1024 ^ 2 , 0 ) & 'GB | ' & $ ObjMemory . Подсчитайте & 'штук | ' & $ sItemM & ' Mhz ' & @CRLF Далее для $ ObjItemG в $ ObjGraph $ sInfo & = @TAB & ' Videocard : .............' & $ ObjItemG . Имя & '| ОЗУ: ' & $ ObjItemG . AdapterRAM / 1024 ^ 2 & 'Mb' & @CRLF Далее для $ ObjItemD в $ ObjDrive $ sInfo & = @TAB & 'Жесткие диски: ...........' & $ ObjItemD . Модель & '| Размер: ' & $ ObjItemD . Размер / +1024 / +1024 / +1024 ) & 'Gb' & @CRLF Next для $ ObjItemCD В $ ObjCDDrive $ sInfo & = @TAB & 'CD-привод: ...............' & $ ObjItemCD . Имя & @CRLF Далее для $ ObjItemN в $ ObjNet Если $ ObjItemN . PhysicalAdapter = True Тогда $ sInfo & = @TAB & 'Сетевой адаптер: ........' & $ ObjItemN . Имя & @CRLF EndIf Next EndIf Local $ aDisplayInfo = Display _ Info ( ) если не $ aDisplayInfo = "", то для $ i = 0 до ( ubound ( $ aDisplayInfo ) / 2 ) - 1 $ sInfo & = @TAB & $ aDisplayInfo [ ( 2 * $ i ) ] & @CRLF $ sInfo & = @TAB & $ aDisplayInfo [ ( 2 * $ i ) + 1 ] & @CRLF Next EndIf $ sInfo & = @CRLF Return $ sInfo EndFunc ; ==> _ InfoPC Func _ hide ( ) ; ????? ??. ????????? ???????? ????? ? ??????, ???? ???????? ?????? GUICtrlSetState ( $ iConnect , $ GUI_disable ) GUICtrlSetState ( $ iKabina , $ GUI_disable ) GUICtrlSetState ($ IType , $ GUI_disable ) GUICtrlSetState ( $ IModel , $ GUI_disable ) GUICtrlSetState ( $ iSerialNum , $ GUI_disable ) GUICtrlSetState ( $ IINV , $ GUI_disable ) EndFunc ; ==> _ скрыть Func _ шоу ( ) ; ???????. ???????? ???????? ????? ? ??????, ????? ?????? ????????? GUICtrlSetState ( $ iConnect , $ GUI_enable ) GUICtrlSetState ( $ iKabina , $ GUI_enable ) GUICtrlSetState ( $ IType , $ GUI_enable ) GUICtrlSetState ( $ IModel , $ GUI_enable ) GUICtrlSetState ( $ iSerialNum , $ GUI_enable ) GUICtrlSetState ( $ IINV , $ GUI_enable ) EndFunc ; ==> _ показать Opt ( "MustDeclareVars" , 1 ) Func _ ( ) Local $ sls = ObjGet ( "winmgmts: {impersonationLevel = impersonate," _ &"authenticationLevel = Pkt}! \\" & _ @ComputerName & '\ root \ wmi' ) , $ lss = $ sls . ExecQuery _ ( 'SELECT * FROM WmiMonitorID' ) , _ $ lll , $ sll , $ sss = "" , $ lsl , $ lls , $ i , $ z Для $ z In $ lss $ lsl = $ z . UserFriendlyName For $ i = 0 To Ubound ($ lsl ) - 1 if ( $ lsl [ $ i ] ) Тогда $ lll & = Chr ( $ lsl [ $ i ] ) Далее $ lls = $ z . SerialNumberID For $ i = 0 To Ubound ( $ lls ) - 1 if ( $ lls [ $ i ] ) Then $ sll & = Chr ( $ lls [ $ i ] ) Далее $ sss & = "Модель" & @TAB & @TAB & ":" & $ lll & @CR & "Серийный номер" & @TAB & ":" & $ sll & @CR & @CR $ lll = "" $ sll = "" Далее $ lss = Null $ sls = Null $ sInfo &= @CRLF EndFunc Func _ ShowOtchot ( ) Локальный $ Form1 = GUICreate ("Порядок" , 482 , 438 , По умолчанию , По умолчанию , По умолчанию , 0x00000080 , $ Main ) GUISetBkColor ( 0x02101B ) Локальный $ Edit1 = GUICtrlCreateEdit ( "" , 0 , 0 , 482 , 385 ) GUICtrlSetData ( - 1 , FileRead ( $ fFile ) ) $ CopyBtn = GUICtrlCreateButton ( "Копировать в txt" , 194 , 400 , 99 , 25 , $ BS_DEFPUSHBUTTON ) Для $ i = 0 до 230 Шаг 9 Sleep ( 10 ) WinSetTrans ( $ Form1 , '' , $ i ) ; ???????????? 0-255 Далее GUISetState ( @SW_SHOW ) Пока 1 локальный $ msg = GUIGetMsg ( ) Переключить $ msg Case $ CopyBtn ClipPut (GUICtrlRead ( $ Edit1 ) ) DirCreate ( @ScriptDir & "\ COPY" ) FileCopy ( @ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt" , @ScriptDir & "\ COPY" , 1 ) MsgBox ( 64 , "??????" , 'Copied' , По умолчанию , $ Main ) Case - 3 GUIDelete ( $ Form1 ) WinActivate ( $ Main ) ExitLoop EndSwitch WEnd EndFunc Func Display _ Info ( ) Local $ oComErr , $ oWmi , $ oInstances $ oComErr = ObjEvent ( "AutoIt.Error" , comm _ error _ handler ) #forceref $ oComErr ; Получить объект WMI $ oWmi = ObjGet ( "winmgmts: \ root \ WMI" ) Если не IsObj ( $ oWmi ) Тогда выход MsgBox ( $ MB_ICONERROR , "ERROR" , "Невозможно создать объект WMI" ) , выберите экземпляры объектов $ oInstances = $ oWmi . ExecQuery ( "ВЫБРАТЬ * ИЗ WMIMonitorID" ) Если $ oInstances . Count = 0 Тогда выход MsgBox ( $ MB_ICONWARNING , "Внимание" , "Нет объекты найдены" ) ; Изменена часть Local $ aReturn [2 ] ; измените номер, если вы хотите вернуть дополнительную информацию. Local $ iDisplayCount = 1 ; Показать свойства экземпляра Для $ oInstance в $ oInstances С $ oInstance ConsoleWrite ( @CRLF ), если ubound ( $ aReturn ) < $ iDisplayCount * 2, затем переименовать $ aReturn [ 2 * $ iDisplayCount ] Если IsArray ( . UserFriendlyName ) Тогда $ aReturn [ 2* ( $ IDisplayCount - 1 ) ] = StringFormat ( "UserFriendlyName =% s" , новообращенный _ uint16 _ массив _ в _ строка ( . UserFriendlyName ) ) Если IsArray ( . SerialNumberId ) Тогда $ aReturn [ 2 * ( $ iDisplayCount - 1 ) + 1 ] = StringFormat ( "SerialNumberId =% s", преобразовать _ uint16 _ array _ в _ строку ( . SerialNumberId ) ) $ iDisplayCount + = 1 EndWith Next Return $ aReturn EndFunc Func convert _ uint16 _ array _ to _ string ( $ aBytes ) Local $ s = "" For $ i in $ aBytes Если $ i <> 0 Тогда $ s & = Chr ( $ i ) Далее Вернуть $ s EndFunc Func comm _ обработчикошибок _ ( $ oComError ) ConsoleWrite ( @CRLF & @CRLF ) ConsoleWrite ( StringFormat ( "Error Desc =% s" , $ oComError . Description ) & @CRLF ) Exit EndFunc) ConsoleWrite(StringFormat("Script Line = %s", $oComError.ScriptLine) & @CRLF) ConsoleWrite(StringFormat("Win Err Desc = %s", StringStripWS($oComError.WinDescription, $STR_STRIPTRAILING)) & @CRLF) ConsoleWrite(StringFormat("Error Number = %i (0x%x)", $oComError.Number, $oComError.Number) Я добавил тестовую часть в начале, поскольку скрипт все еще не запускался, и закомментировал этот раздел. ; ~ Global $ aDispTest = Display_Info () ; ~ if $ aDispTest = "" Then ; ~ ConsoleWrite ("проблема" & @crlf) ; ~ Else ; ~ для $ i = 0 to (ubound ($ aDispTest) / 2) - 1 ; ~ ConsoleWrite ("Str:" & $ i & "" & $ aDispTest [(2 * $ i)] & @crlf) ; ~ ConsoleWrite ("Str:" & $ i & "" & $ aDispTest [(2 * $ i) +1] & @crlf) ; ~ Next ; ~ EndIf ; ~ Exit У меня 2 монитора, один встроенный ноутбук, другой внешний Samsung. Вот что я получаю: Str: 0 UserFriendlyName = SyncMaster Str: 0 SerialNumberId = 1110529591 Str: 1 Str: 1 SerialNumberId = 0 @TheXman Ожидается ли это? Или я что-то не так делаю с массивом? You can named me an idiot, but not working or they part not writing all this txt document and i dont see error, and dont see working this part or not...
TheXman Posted November 18, 2020 Posted November 18, 2020 (edited) 18 minutes ago, GokAy said: Is this expected? Or am I doing something wrong with the array? @GokAy What do you get on your laptop when you run my original example? Edited November 18, 2020 by TheXman DirtyJohny 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
GokAy Posted November 18, 2020 Posted November 18, 2020 (edited) @TheXman Yeah, I just ran it. And I see the problem. There is no friendlyname for laptop display and serial is 0. So, it is working as intended. InstanceName = DISPLAY\SAM05C5\4&a0cd8b3&0&UID198147_0 YearOfManufacture = 2010 WeekOfManufacture = 14 UserFriendlyName = SyncMaster ManufacturerName = SAM SerialNumberId = 1110529591 ProductCodeID = 05C5 InstanceName = DISPLAY\LGD04B9\4&a0cd8b3&0&UID265988_0 YearOfManufacture = 2015 WeekOfManufacture = 0 ManufacturerName = LGD SerialNumberId = 0 ProductCodeID = 04B9 Edited November 18, 2020 by GokAy DirtyJohny 1
GokAy Posted November 18, 2020 Posted November 18, 2020 @DirtyJohny I guess I am supposed to enter some text at the boxes when running your script. And I just get an error, when I click "SEND". One of these: Select Case (Not StringStripWS($rKabina, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??????? - ??????') Case (Not StringStripWS($rType, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??? - ??????') Case (Not StringStripWS($rModel, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ?????? - ??????') Case (Not StringStripWS($rSerialNum, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ???????? ????? - ??????') Case (Not StringStripWS($rInv, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??????????? - ??????') Case $hFile = -1 MsgBox(4096, '??????', '?????????? ??????? ????.') Case Else _hide() ;????????? ??? ???????? ????? ? ?????? DirtyJohny 1
DirtyJohny Posted November 18, 2020 Author Posted November 18, 2020 8 minutes ago, GokAy said: @TheXman Yeah, I just ran it. And I see the problem. There is no friendlyname for laptop display and serial is 0. So, it is working as intended. InstanceName = DISPLAY\SAM05C5\4&a0cd8b3&0&UID198147_0 YearOfManufacture = 2010 WeekOfManufacture = 14 UserFriendlyName = SyncMaster ManufacturerName = SAM SerialNumberId = 1110529591 ProductCodeID = 05C5 InstanceName = DISPLAY\LGD04B9\4&a0cd8b3&0&UID265988_0 YearOfManufacture = 2015 WeekOfManufacture = 0 ManufacturerName = LGD SerialNumberId = 0 ProductCodeID = 04B9 lol InstanceName = DISPLAY\PHLC0B3\5&1db54a27&0&UID521_0 YearOfManufacture = 2013 WeekOfManufacture = 16 UserFriendlyName = Philips 236V4 ManufacturerName = PHL SerialNumberId = UHB1316009223 ProductCodeID = C0B3 InstanceName = DISPLAY\PHLC07D\5&1db54a27&0&UID522_0 YearOfManufacture = 2013 WeekOfManufacture = 3 UserFriendlyName = 273ELH ManufacturerName = PHL SerialNumberId = AU51303008408 ProductCodeID = C07D
DirtyJohny Posted November 18, 2020 Author Posted November 18, 2020 4 minutes ago, GokAy said: @DirtyJohny I guess I am supposed to enter some text at the boxes when running your script. And I just get an error, when I click "SEND". One of these: Select Case (Not StringStripWS($rKabina, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??????? - ??????') Case (Not StringStripWS($rType, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??? - ??????') Case (Not StringStripWS($rModel, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ?????? - ??????') Case (Not StringStripWS($rSerialNum, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ???????? ????? - ??????') Case (Not StringStripWS($rInv, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??????????? - ??????') Case $hFile = -1 MsgBox(4096, '??????', '?????????? ??????? ????.') Case Else _hide() ;????????? ??? ???????? ????? ? ?????? Yes you right, write anything)
GokAy Posted November 19, 2020 Posted November 19, 2020 (edited) Ok, figured it out once I was able to run it. My bad really You may be an idiot, but I am the King of Idiots! Messed up with check if $aDisplayInfo is an array. This window being slightly transparent makes it hard to read. Also, friendlyname as you see from my laptop (Display 2), may not show any info. Anyway, here is working script: expandcollapse popup#RequireAdmin #NoTrayIcon #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <Constants.au3> #include <Array.au3> Opt("MustDeclareVars",1) ;??? ??? ????????, ????? ';' ??????? ???????????? ? ?? ??? ?? ?????? ?? ?????? ???????. Global $iKabina, $iType, $iModel, $iSerialNum, $iInv ;????????? ??????????, ??????? ????? ?????????????? ? ????? Global $rKabina, $rType, $rModel, $rSerialNum, $rInv, $Main, $iConnect, $hFile, $sInfo, $CopyBtn, $fFile = @ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt" $Main = GUICreate('Inventarisation', 315, 352) ;?????? ??????? ???? GUISetBkColor(0x02101B) $iKabina = GUICtrlCreateInput('', 20, 30, 272, 21) $iType = GUICtrlCreateInput('', 20, 75, 272, 21) $iModel = GUICtrlCreateInput('', 20, 120, 272, 21) $iSerialNum = GUICtrlCreateInput('', 20, 165, 272, 21) $iInv = GUICtrlCreateInput('', 20, 210, 272, 21) GUISetFont(10, 800, 0, 'Tahoma'); ????????????? ????? ?? ????????? ??? ??????????? ????????? GUI-????. $iConnect = GUICtrlCreateButton('Send', 23, 305, 267, 33, $BS_DEFPUSHBUTTON) ;??????? ?????? ??????????? GUICtrlSetDefColor(0xDEDEDE); ????????????? ???? ?????? ?? ????????? ??? ??????????? ????????? GUI-????. GUICtrlCreateLabel('Cabinet', 20, 10, 150, 17) GUICtrlCreateLabel('Type', 20, 55, 150, 17) GUICtrlCreateLabel('Model', 20, 100, 150, 17) GUICtrlCreateLabel('?erial number PC', 20, 145, 150, 17) GUICtrlCreateLabel('Inventarisation number', 20, 190, 150, 17) WinSetTrans($Main, '', 0) GUISetState(@SW_SHOW) For $i = 0 To 230 Step 9 Sleep(10) WinSetTrans($Main, '', $i) ;???????????? 0-255 Next $hFile = FileOpen(@ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt", 1) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iConnect $rKabina = GUICtrlRead($iKabina) $rType = GUICtrlRead($iType) $rModel = GUICtrlRead($iModel) $rSerialNum = GUICtrlRead($iSerialNum) $rInv = GUICtrlRead($iInv) Select Case (Not StringStripWS($rKabina, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??????? - ??????') Case (Not StringStripWS($rType, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??? - ??????') Case (Not StringStripWS($rModel, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ?????? - ??????') Case (Not StringStripWS($rSerialNum, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ???????? ????? - ??????') Case (Not StringStripWS($rInv, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??????????? - ??????') Case $hFile = -1 MsgBox(4096, '??????', '?????????? ??????? ????.') Case Else _hide() ;????????? ??? ???????? ????? ? ?????? $sInfo = '======================================================================================' & @CRLF & _ '[??????????????:]' & @CRLF & _ @TAB & 'Date: ................... ' & @MDAY & '.' & @MON & '.' & @YEAR & ' ' & @CRLF & _ @TAB & 'Cabinet: ................ ' & $rKabina & @CRLF & _ @TAB & 'Type: .................... ' & $rType & @CRLF & _ @TAB & 'Model: ................. ' & $rModel & @CRLF & _ @TAB & '?erial number PC: ......... ' & $rSerialNum & @CRLF & _ @TAB & 'Inventarisation number: ...... ' & $rInv & @CRLF & _ @TAB & 'Current User: ......... ' & @UserName & @CRLF & @CRLF $sInfo &= _InfoPC() FileWrite($hFile, $sInfo) FileClose($hFile) _show() ;???????? ??? ???????? ????? ? ?????? _ShowOtchot() EndSelect EndSwitch WEnd Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) Local $ObjProcessor = $ObjService.ExecQuery('SELECT * FROM Win32_Processor', 'WQL', 0x30) Local $ObjMemory = $ObjService.ExecQuery('SELECT * FROM Win32_PhysicalMemory') Local $ObjNet = $ObjService.ExecQuery('SELECT * FROM Win32_NetworkAdapter', 'WQL', 0x30) Local $ObjGraph = $ObjService.ExecQuery('SELECT * FROM Win32_VideoController', 'WQL', 0x30) Local $ObjDrive = $ObjService.ExecQuery('SELECT * FROM Win32_DiskDrive', 'WQL', 0x30) Local $ObjCDDrive = $ObjService.ExecQuery('SELECT * FROM Win32_CDROMDrive', 'WQL', 0x30) Local $ObjRam = $ObjService.ExecQuery('SELECT * FROM Win32_ComputerSystem') Local $sNameComput = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\DataStore\Machine\0', 'szTargetName') Local $sProduct = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ProductName') Local $sBuild = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ReleaseId') Local $sItemM, $sInfo = '[Configuration:]' & @CRLF & @TAB & 'Computer name: ......... ' & $sNameComput & @CRLF & _ @TAB & 'Operating system: ... ' & $sProduct & ' ' & $sBuild & ' ' & '(' & @OSArch & ')' & @CRLF If IsObj($ObjService) Then For $objItemP In $ObjProcessor $sInfo &= @TAB & 'Processor: .............. ' & $objItemP.Name & @CRLF Next For $objItemMB In $ObjMB $sInfo &= @TAB & '?Motherboard: ...... ' & $objItemMB.Product & @CRLF Next For $ObjItemM In $ObjMemory $sItemM = $objItemM.Speed Next For $objItemR In $ObjRam $sInfo &= @TAB & 'RAM: .................... ' & Round($objItemR.TotalPhysicalMemory / 1024 / 1024 ^ 2, 0) & ' GB | ' & $ObjMemory.Count & ' pieces | ' & $sItemM & ' Mhz' & @CRLF Next For $ObjItemG In $ObjGraph $sInfo &= @TAB & 'Videocard: ............. ' & $ObjItemG.Name & ' | RAM: ' & $ObjItemG.AdapterRAM / 1024 ^ 2 & ' Mb' & @CRLF Next For $ObjItemD In $ObjDrive $sInfo &= @TAB & 'Hard drives: ........... ' & $ObjItemD.Model & ' | Size: ' & Round($ObjItemD.Size / 1024 / 1024 / 1024) & ' Gb' & @CRLF Next For $ObjItemCD In $ObjCDDrive $sInfo &= @TAB & 'CD-Drive: ............... ' & $ObjItemCD.Name & @CRLF Next For $ObjItemN In $ObjNet If $ObjItemN.PhysicalAdapter = True Then $sInfo &= @TAB & 'Network adapter: ........ ' & $ObjItemN.Name & @CRLF EndIf Next EndIf Local $aDisplayInfo = Display_Info() if $aDisplayInfo = "" then ConsoleWrite("$aDisplayInfo is not an array" & @crlf) Else for $i = 0 to (ubound($aDisplayInfo)/2)-1 $sInfo &= @TAB & "Display " & $i+1 & ": UserFriendlyName: " & $aDisplayInfo[(2*$i)] & @CRLF $sInfo &= @TAB & "Display " & $i+1 & ": SerialNumberId: " & $aDisplayInfo[(2*$i)+1] & @CRLF Next EndIf $sInfo &= @CRLF Return $sInfo EndFunc ;==>_InfoPC Func _hide() ;???????. ????????? ???????? ????? ? ??????, ???? ???????? ?????? GUICtrlSetState($iConnect, $GUI_disable) GUICtrlSetState($iKabina, $GUI_disable) GUICtrlSetState($iType, $GUI_disable) GUICtrlSetState($iModel, $GUI_disable) GUICtrlSetState($iSerialNum, $GUI_disable) GUICtrlSetState($iInv, $GUI_disable) EndFunc ;==>_hide Func _show() ;???????. ???????? ???????? ????? ? ??????, ????? ?????? ????????? GUICtrlSetState($iConnect, $GUI_enable) GUICtrlSetState($iKabina, $GUI_enable) GUICtrlSetState($iType, $GUI_enable) GUICtrlSetState($iModel, $GUI_enable) GUICtrlSetState($iSerialNum, $GUI_enable) GUICtrlSetState($iInv, $GUI_enable) EndFunc ;==>_show Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next $lss=Null $sls=Null $sInfo &= @CRLF EndFunc Func _ShowOtchot() Local $Form1 = GUICreate("Order", 482, 438, Default, Default, Default, 0x00000080, $Main) GUISetBkColor(0x02101B) Local $Edit1 = GUICtrlCreateEdit("", 0, 0, 482, 385) GUICtrlSetData(-1, FileRead($fFile)) $CopyBtn = GUICtrlCreateButton("Copy in txt", 194, 400, 99, 25, $BS_DEFPUSHBUTTON) For $i = 0 To 230 Step 9 Sleep(10) WinSetTrans($Form1, '', $i) ;???????????? 0-255 Next GUISetState(@SW_SHOW) While 1 Local $msg = GUIGetMsg() Switch $msg Case $CopyBtn ClipPut(GUICtrlRead($Edit1)) DirCreate (@ScriptDir & "\COPY") FileCopy(@ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt", @ScriptDir & "\COPY", 1) MsgBox(64, "??????", 'Copied', Default, $Main) Case -3 GUIDelete($Form1) WinActivate($Main) ExitLoop EndSwitch WEnd EndFunc Func Display_Info() Local $oComErr, $oWmi, $oInstances $oComErr = ObjEvent("AutoIt.Error", comm_error_handler) #forceref $oComErr ;Get WMI object $oWmi = ObjGet("winmgmts:\root\WMI") If Not IsObj($oWmi) Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to create WMI object") ;Select object instances $oInstances = $oWmi.ExecQuery("SELECT * FROM WMIMonitorID") If $oInstances.Count = 0 Then Exit MsgBox($MB_ICONWARNING,"Warning","No objects found") ; Changed part Local $aReturn[2] ; change number if you want to return more info Local $iDisplayCount = 1 ;Display instance properties For $oInstance in $oInstances With $oInstance ConsoleWrite(@CRLF) if ubound($aReturn) < $iDisplayCount * 2 then redim $aReturn[2*$iDisplayCount] If IsArray(.UserFriendlyName) Then $aReturn[2*($iDisplayCount-1)] = convert_uint16_array_to_string(.UserFriendlyName) ;StringFormat("UserFriendlyName = %s", convert_uint16_array_to_string(.UserFriendlyName)) If IsArray(.SerialNumberId) Then $aReturn[2*($iDisplayCount-1)+1] = convert_uint16_array_to_string(.SerialNumberId) ;StringFormat("SerialNumberId = %s", convert_uint16_array_to_string(.SerialNumberId)) $iDisplayCount += 1 EndWith Next Return $aReturn EndFunc Func convert_uint16_array_to_string($aBytes) Local $s = "" For $i in $aBytes If $i <> 0 Then $s &= Chr($i) Next Return $s EndFunc Func comm_error_handler($oComError) ConsoleWrite(@CRLF) ConsoleWrite(StringFormat("Script Line = %s", $oComError.ScriptLine) & @CRLF) ConsoleWrite(StringFormat("Win Err Desc = %s", StringStripWS($oComError.WinDescription, $STR_STRIPTRAILING)) & @CRLF) ConsoleWrite(StringFormat("Error Number = %i (0x%x)", $oComError.Number, $oComError.Number) & @CRLF) ConsoleWrite(StringFormat("Error Desc = %s", $oComError.Description) & @CRLF) Exit EndFunc Edit: Couldn't post sooner as the forums were down Edited November 19, 2020 by GokAy DirtyJohny 1
DirtyJohny Posted November 19, 2020 Author Posted November 19, 2020 38 minutes ago, GokAy said: Ok, figured it out once I was able to run it. My bad really You may be an idiot, but I am the King of Idiots! Messed up with check if $aDisplayInfo is an array. This window being slightly transparent makes it hard to read. Also, friendlyname as you see from my laptop (Display 2), may not show any info. Anyway, here is working script: expandcollapse popup#RequireAdmin #NoTrayIcon #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <Constants.au3> #include <Array.au3> Opt("MustDeclareVars",1) ;??? ??? ????????, ????? ';' ??????? ???????????? ? ?? ??? ?? ?????? ?? ?????? ???????. Global $iKabina, $iType, $iModel, $iSerialNum, $iInv ;????????? ??????????, ??????? ????? ?????????????? ? ????? Global $rKabina, $rType, $rModel, $rSerialNum, $rInv, $Main, $iConnect, $hFile, $sInfo, $CopyBtn, $fFile = @ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt" $Main = GUICreate('Inventarisation', 315, 352) ;?????? ??????? ???? GUISetBkColor(0x02101B) $iKabina = GUICtrlCreateInput('', 20, 30, 272, 21) $iType = GUICtrlCreateInput('', 20, 75, 272, 21) $iModel = GUICtrlCreateInput('', 20, 120, 272, 21) $iSerialNum = GUICtrlCreateInput('', 20, 165, 272, 21) $iInv = GUICtrlCreateInput('', 20, 210, 272, 21) GUISetFont(10, 800, 0, 'Tahoma'); ????????????? ????? ?? ????????? ??? ??????????? ????????? GUI-????. $iConnect = GUICtrlCreateButton('Send', 23, 305, 267, 33, $BS_DEFPUSHBUTTON) ;??????? ?????? ??????????? GUICtrlSetDefColor(0xDEDEDE); ????????????? ???? ?????? ?? ????????? ??? ??????????? ????????? GUI-????. GUICtrlCreateLabel('Cabinet', 20, 10, 150, 17) GUICtrlCreateLabel('Type', 20, 55, 150, 17) GUICtrlCreateLabel('Model', 20, 100, 150, 17) GUICtrlCreateLabel('?erial number PC', 20, 145, 150, 17) GUICtrlCreateLabel('Inventarisation number', 20, 190, 150, 17) WinSetTrans($Main, '', 0) GUISetState(@SW_SHOW) For $i = 0 To 230 Step 9 Sleep(10) WinSetTrans($Main, '', $i) ;???????????? 0-255 Next $hFile = FileOpen(@ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt", 1) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iConnect $rKabina = GUICtrlRead($iKabina) $rType = GUICtrlRead($iType) $rModel = GUICtrlRead($iModel) $rSerialNum = GUICtrlRead($iSerialNum) $rInv = GUICtrlRead($iInv) Select Case (Not StringStripWS($rKabina, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??????? - ??????') Case (Not StringStripWS($rType, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??? - ??????') Case (Not StringStripWS($rModel, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ?????? - ??????') Case (Not StringStripWS($rSerialNum, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ???????? ????? - ??????') Case (Not StringStripWS($rInv, 8)) MsgBox(16 + 8192 + 262144, 'Error', '???? ??????????? - ??????') Case $hFile = -1 MsgBox(4096, '??????', '?????????? ??????? ????.') Case Else _hide() ;????????? ??? ???????? ????? ? ?????? $sInfo = '======================================================================================' & @CRLF & _ '[??????????????:]' & @CRLF & _ @TAB & 'Date: ................... ' & @MDAY & '.' & @MON & '.' & @YEAR & ' ' & @CRLF & _ @TAB & 'Cabinet: ................ ' & $rKabina & @CRLF & _ @TAB & 'Type: .................... ' & $rType & @CRLF & _ @TAB & 'Model: ................. ' & $rModel & @CRLF & _ @TAB & '?erial number PC: ......... ' & $rSerialNum & @CRLF & _ @TAB & 'Inventarisation number: ...... ' & $rInv & @CRLF & _ @TAB & 'Current User: ......... ' & @UserName & @CRLF & @CRLF $sInfo &= _InfoPC() FileWrite($hFile, $sInfo) FileClose($hFile) _show() ;???????? ??? ???????? ????? ? ?????? _ShowOtchot() EndSelect EndSwitch WEnd Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) Local $ObjProcessor = $ObjService.ExecQuery('SELECT * FROM Win32_Processor', 'WQL', 0x30) Local $ObjMemory = $ObjService.ExecQuery('SELECT * FROM Win32_PhysicalMemory') Local $ObjNet = $ObjService.ExecQuery('SELECT * FROM Win32_NetworkAdapter', 'WQL', 0x30) Local $ObjGraph = $ObjService.ExecQuery('SELECT * FROM Win32_VideoController', 'WQL', 0x30) Local $ObjDrive = $ObjService.ExecQuery('SELECT * FROM Win32_DiskDrive', 'WQL', 0x30) Local $ObjCDDrive = $ObjService.ExecQuery('SELECT * FROM Win32_CDROMDrive', 'WQL', 0x30) Local $ObjRam = $ObjService.ExecQuery('SELECT * FROM Win32_ComputerSystem') Local $sNameComput = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\DataStore\Machine\0', 'szTargetName') Local $sProduct = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ProductName') Local $sBuild = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'ReleaseId') Local $sItemM, $sInfo = '[Configuration:]' & @CRLF & @TAB & 'Computer name: ......... ' & $sNameComput & @CRLF & _ @TAB & 'Operating system: ... ' & $sProduct & ' ' & $sBuild & ' ' & '(' & @OSArch & ')' & @CRLF If IsObj($ObjService) Then For $objItemP In $ObjProcessor $sInfo &= @TAB & 'Processor: .............. ' & $objItemP.Name & @CRLF Next For $objItemMB In $ObjMB $sInfo &= @TAB & '?Motherboard: ...... ' & $objItemMB.Product & @CRLF Next For $ObjItemM In $ObjMemory $sItemM = $objItemM.Speed Next For $objItemR In $ObjRam $sInfo &= @TAB & 'RAM: .................... ' & Round($objItemR.TotalPhysicalMemory / 1024 / 1024 ^ 2, 0) & ' GB | ' & $ObjMemory.Count & ' pieces | ' & $sItemM & ' Mhz' & @CRLF Next For $ObjItemG In $ObjGraph $sInfo &= @TAB & 'Videocard: ............. ' & $ObjItemG.Name & ' | RAM: ' & $ObjItemG.AdapterRAM / 1024 ^ 2 & ' Mb' & @CRLF Next For $ObjItemD In $ObjDrive $sInfo &= @TAB & 'Hard drives: ........... ' & $ObjItemD.Model & ' | Size: ' & Round($ObjItemD.Size / 1024 / 1024 / 1024) & ' Gb' & @CRLF Next For $ObjItemCD In $ObjCDDrive $sInfo &= @TAB & 'CD-Drive: ............... ' & $ObjItemCD.Name & @CRLF Next For $ObjItemN In $ObjNet If $ObjItemN.PhysicalAdapter = True Then $sInfo &= @TAB & 'Network adapter: ........ ' & $ObjItemN.Name & @CRLF EndIf Next EndIf Local $aDisplayInfo = Display_Info() if $aDisplayInfo = "" then ConsoleWrite("$aDisplayInfo is not an array" & @crlf) Else for $i = 0 to (ubound($aDisplayInfo)/2)-1 $sInfo &= @TAB & "Display " & $i+1 & ": UserFriendlyName: " & $aDisplayInfo[(2*$i)] & @CRLF $sInfo &= @TAB & "Display " & $i+1 & ": SerialNumberId: " & $aDisplayInfo[(2*$i)+1] & @CRLF Next EndIf $sInfo &= @CRLF Return $sInfo EndFunc ;==>_InfoPC Func _hide() ;???????. ????????? ???????? ????? ? ??????, ???? ???????? ?????? GUICtrlSetState($iConnect, $GUI_disable) GUICtrlSetState($iKabina, $GUI_disable) GUICtrlSetState($iType, $GUI_disable) GUICtrlSetState($iModel, $GUI_disable) GUICtrlSetState($iSerialNum, $GUI_disable) GUICtrlSetState($iInv, $GUI_disable) EndFunc ;==>_hide Func _show() ;???????. ???????? ???????? ????? ? ??????, ????? ?????? ????????? GUICtrlSetState($iConnect, $GUI_enable) GUICtrlSetState($iKabina, $GUI_enable) GUICtrlSetState($iType, $GUI_enable) GUICtrlSetState($iModel, $GUI_enable) GUICtrlSetState($iSerialNum, $GUI_enable) GUICtrlSetState($iInv, $GUI_enable) EndFunc ;==>_show Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next $lss=Null $sls=Null $sInfo &= @CRLF EndFunc Func _ShowOtchot() Local $Form1 = GUICreate("Order", 482, 438, Default, Default, Default, 0x00000080, $Main) GUISetBkColor(0x02101B) Local $Edit1 = GUICtrlCreateEdit("", 0, 0, 482, 385) GUICtrlSetData(-1, FileRead($fFile)) $CopyBtn = GUICtrlCreateButton("Copy in txt", 194, 400, 99, 25, $BS_DEFPUSHBUTTON) For $i = 0 To 230 Step 9 Sleep(10) WinSetTrans($Form1, '', $i) ;???????????? 0-255 Next GUISetState(@SW_SHOW) While 1 Local $msg = GUIGetMsg() Switch $msg Case $CopyBtn ClipPut(GUICtrlRead($Edit1)) DirCreate (@ScriptDir & "\COPY") FileCopy(@ScriptDir & "\" & "(" & @MDAY & "." & @MON & "." & @YEAR & ")" & ".txt", @ScriptDir & "\COPY", 1) MsgBox(64, "??????", 'Copied', Default, $Main) Case -3 GUIDelete($Form1) WinActivate($Main) ExitLoop EndSwitch WEnd EndFunc Func Display_Info() Local $oComErr, $oWmi, $oInstances $oComErr = ObjEvent("AutoIt.Error", comm_error_handler) #forceref $oComErr ;Get WMI object $oWmi = ObjGet("winmgmts:\root\WMI") If Not IsObj($oWmi) Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to create WMI object") ;Select object instances $oInstances = $oWmi.ExecQuery("SELECT * FROM WMIMonitorID") If $oInstances.Count = 0 Then Exit MsgBox($MB_ICONWARNING,"Warning","No objects found") ; Changed part Local $aReturn[2] ; change number if you want to return more info Local $iDisplayCount = 1 ;Display instance properties For $oInstance in $oInstances With $oInstance ConsoleWrite(@CRLF) if ubound($aReturn) < $iDisplayCount * 2 then redim $aReturn[2*$iDisplayCount] If IsArray(.UserFriendlyName) Then $aReturn[2*($iDisplayCount-1)] = convert_uint16_array_to_string(.UserFriendlyName) ;StringFormat("UserFriendlyName = %s", convert_uint16_array_to_string(.UserFriendlyName)) If IsArray(.SerialNumberId) Then $aReturn[2*($iDisplayCount-1)+1] = convert_uint16_array_to_string(.SerialNumberId) ;StringFormat("SerialNumberId = %s", convert_uint16_array_to_string(.SerialNumberId)) $iDisplayCount += 1 EndWith Next Return $aReturn EndFunc Func convert_uint16_array_to_string($aBytes) Local $s = "" For $i in $aBytes If $i <> 0 Then $s &= Chr($i) Next Return $s EndFunc Func comm_error_handler($oComError) ConsoleWrite(@CRLF) ConsoleWrite(StringFormat("Script Line = %s", $oComError.ScriptLine) & @CRLF) ConsoleWrite(StringFormat("Win Err Desc = %s", StringStripWS($oComError.WinDescription, $STR_STRIPTRAILING)) & @CRLF) ConsoleWrite(StringFormat("Error Number = %i (0x%x)", $oComError.Number, $oComError.Number) & @CRLF) ConsoleWrite(StringFormat("Error Desc = %s", $oComError.Description) & @CRLF) Exit EndFunc Edit: Couldn't post sooner as the forums were down Oooooh myyy God.Its awesome.Seriosly thank you all very much.Low bow....
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