Jump to content

Recommended Posts

Hi everyone.Need rewrite this function how in еxample.

Original:

#RequireAdmin
#NoTrayIcon
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
MsgBox(262144,'Monitors   '&$lss.Count,$sss&" "&@CR)
$lss=Null
$sls=Null
EndFunc
_a()

Example:

Func _InfoPC()
    Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2')
    Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30)
     If IsObj($ObjService) Then
       For $objItemMB In $ObjMB
            $sInfo &= @TAB & 'Motherboard: ...... ' & $objItemMB.Product & @CRLF

I'm beginner in this sphere and need  you all speak easy and simply because i'm Russian.Thanks)

Edited by DirtyJohny
Link to post
Share on other sites
  • Moderators

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

Please search the forum for "Scriptomatic". This tool creates AutoIt scripts to query WMI for you.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Run the script and wait until the "please wait" messages in WMI namespace and WMI class have disappeared. Then select the Win32_DesktopMonitor class and click "Run".

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
4 hours ago, Nine said:

Not all environments support "WmiMonitorID",  use instead "Win32_DesktopMonitor".

I see the class Win32_DesktopMonitor, but you must know in this class not show Serial nubmber and model, check please. And this function must work in autoit.See more in this link "https://docs.microsoft.com/en-us/windows/win32/wmicoreprov/wmimonitorid".Now i have a trying  rewrite  but unfinished...

Edited by DirtyJohny
Link to post
Share on other sites
4 hours ago, water said:

Run the script and wait until the "please wait" messages in WMI namespace and WMI class have disappeared. Then select the Win32_DesktopMonitor class and click "Run".

I not see the MonitorID...I just want see serial numbers and models and how i know, others classes "Monitor" not show this information. Is it really impossible rewrite this script, when this script working? I need rewrite form how i see it in example....And I need help in this

Edited by DirtyJohny
Link to post
Share on other sites
  • Moderators

@DirtyJohny Just because this is the most important thing in the world to you does not mean you need to post every 10 minutes. Please follow the forum etiquette and wait at least 24 hours before bumping your thread. You could use that time to do some research on your own.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

 

9 minutes ago, JLogan3o13 said:

@DirtyJohny Just because this is the most important thing in the world to you does not mean you need to post every 10 minutes. Please follow the forum etiquette and wait at least 24 hours before bumping your thread. You could use that time to do some research on your own.

I just answered, not see problem.I edit my messages because my english not very good and I think, based on etiquette, it would be better to speak clearly so that I can be understood.But thanks for the advice.

Link to post
Share on other sites

@DirtyJohny

Since this is not as simple as it seems because some of the WMIMonitorID class properties are byte arrays that need to be converted to strings, I thought I would help you out.  Below is one way that you can grab the property values.

#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d

#include <Constants.au3>

example()

Func example()
    Local $oComErr, $oWmi, $oInstances

    $oComErr = ObjEvent("AutoIt.Error", com_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")

    ;Display instance properties
    For $oInstance in $oInstances
        With $oInstance
            ConsoleWrite(@CRLF)
            ConsoleWrite("InstanceName      = " & .InstanceName      & @CRLF)
            ConsoleWrite("YearOfManufacture = " & .YearOfManufacture & @CRLF)
            ConsoleWrite("WeekOfManufacture = " & .WeekOfManufacture & @CRLF)

            If IsArray(.UserFriendlyName) Then ConsoleWrite("UserFriendlyName  = " & convert_int_array_to_string(.UserFriendlyName) & @CRLF)
            If IsArray(.ManufacturerName) Then ConsoleWrite("ManufacturerName  = " & convert_int_array_to_string(.ManufacturerName) & @CRLF)
            If IsArray(.SerialNumberId)   Then ConsoleWrite("SerialNumberId    = " & convert_int_array_to_string(.SerialNumberId)   & @CRLF)
            If IsArray(.ProductCodeID)    Then ConsoleWrite("ProductCodeID     = " & convert_int_array_to_string(.ProductCodeID)    & @CRLF)
        EndWith
    Next
EndFunc

Func convert_int_array_to_string($aUInts)
    Local $s  = ""

    For $i = 0 To UBound($aUInts) - 1
        If $aUInts[$i] = 0 Then ExitLoop
        $s &= Chr($aUInts[$i])
    Next

    Return $s
EndFunc

Func com_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

Example Output:

InstanceName           = DISPLAY\HWP293A\5&294a6614&0&UID1048849_0
YearOfManufacture      = 2012
WeekOfManufacture      = 46
UserFriendlyName       = HP 2311x
ManufacturerName       = HWP
SerialNumberId         = 3CQ24628ZX
ProductCodeID          = 293A

 

Edited by TheXman
Link to post
Share on other sites

 Thank you so much) And i correct your script see that 

#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d

#include <Constants.au3>
#include <Array.au3>

example()

Func example()
    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")

    ;Display instance properties
    For $oInstance in $oInstances
        With $oInstance
            ConsoleWrite(@CRLF)
            If IsArray(.UserFriendlyName) Then ConsoleWrite(StringFormat("UserFriendlyName       = %s", convert_uint16_array_to_string(.UserFriendlyName)) & @CRLF)
            If IsArray(.SerialNumberId)   Then ConsoleWrite(StringFormat("SerialNumberId         = %s", convert_uint16_array_to_string(.SerialNumberId)) & @CRLF)

        EndWith
    Next
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

 

Edited by DirtyJohny
Link to post
Share on other sites

And next question how i insert all this in my script?( I heve no idea(

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>
#RequireAdmin
#NoTrayIcon

;Все что написано, посде ';' явлется комментарием и ни как не влияет на работу скрипта.

Global $iKabina, $iType, $iKabina, $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

    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
    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

 

Link to post
Share on other sites

Hey, you could incorporate the example script like this:

I hope this will be clear :) 

copy paste func example() and other functions needed to your script, and change: func example() to a more meaningful name, say, func Display_Info()

Then in your script:

(Local/Global) $aDisplayInfo = Display_Info()

 

and change func Display_Info() as such that instead of consolewriting, add what you want returned to an array, say, $aReturn, at this 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

and at the end of func Display_Info()  add this line

Return $aReturn

 

Now, in your script use $aDisplayInfo[0] for UserFriendlyName, or $aDisplayInfo[1] for SerialNumberId

Also, check if returned is an array before using it in your script, like:

if $aDisplayInfo = "" then

 Exit/msgbox/skip this part/whatever you want to do

endif

Link to post
Share on other sites
1 hour ago, GokAy said:

Hey, you could incorporate the example script like this:

I hope this will be clear :) 

copy paste func example() and other functions needed to your script, and change: func example() to a more meaningful name, say, func Display_Info()

Then in your script:

(Local/Global) $aDisplayInfo = Display_Info()

 

and change func Display_Info() as such that instead of consolewriting, add what you want returned to an array, say, $aReturn, at this 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

and at the end of func Display_Info()  add this line

Return $aReturn

 

Now, in your script use $aDisplayInfo[0] for UserFriendlyName, or $aDisplayInfo[1] for SerialNumberId

Also, check if returned is an array before using it in your script, like:

if $aDisplayInfo = "" then

 Exit/msgbox/skip this part/whatever you want to do

endif

Thanks)Sorry dont  understand how it should look....

Edited by DirtyJohny
Link to post
Share on other sites

Where do you want the information for display in your script? I can't decipher it :) 

Your script should be like this, but need to add:

(Local/Global) $aDisplayInfo = Display_Info()

somewhere. And then read what is returned from the array after checking if it is an array. Empty string would mean, the query was unsuccessful I guess.

Note: I can read cyrillic alphabet and understand some of the words in Russian especially if technical, however, I don't know where you would like to access the information within your script.

Untested!

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>

#include <Constants.au3>
#include <Array.au3>

#RequireAdmin
#NoTrayIcon

;Все что написано, посде ';' явлется комментарием и ни как не влияет на работу скрипта.

Global $iKabina, $iType, $iKabina, $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

    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
    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
Link to post
Share on other sites
4 minutes ago, GokAy said:

Where do you want the information for display in your script? I can't decipher it :) 

Your script should be like this, but need to add:

(Local/Global) $aDisplayInfo = Display_Info()

somewhere. And then read what is returned from the array after checking if it is an array. Empty string would mean, the query was unsuccessful I guess.

Note: I can read cyrillic alphabet and understand some of the words in Russian especially if technical, however, I don't know where you would like to access the information within your script.

Untested!

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>

#include <Constants.au3>
#include <Array.au3>

#RequireAdmin
#NoTrayIcon

;Все что написано, посде ';' явлется комментарием и ни как не влияет на работу скрипта.

Global $iKabina, $iType, $iKabina, $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

    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
    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

Oh.Not have error but not see  information about monitors(Need write in the last line)

Безымянный.jpg

Link to post
Share on other sites

Added this part to the end under "Configuration" 😛 , check if it works..

Local $aDisplayInfo = Display_Info()
        if not $aDisplayInfo = "" then
            $sInfo &= @TAB & 'UserFriendlyName: ........' & $aDisplayInfo[0] & @CRLF
            $sInfo &= @TAB & 'SerialNumberId: ........' & $aDisplayInfo[1] & @CRLF
        endif

Code:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>

#include <Constants.au3>
#include <Array.au3>

#RequireAdmin
#NoTrayIcon

;Все что написано, посде ';' явлется комментарием и ни как не влияет на работу скрипта.

Global $iKabina, $iType, $iKabina, $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

    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
Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By HoangDung
      This is the function that returns the result from cmd, initially i connect to the network wait then i make a call to the above _GetDOSOutput($sCommand) function i want to wait 1 period of time netsh wlan connect name="name" actually but after starting to execute the netsh wlan show interfaces command i tried adding a timeout command it seems to have ignored the timeout command?
      #include <WindowsConstants.au3> #include <Constants.au3> Func _GetDOSOutput($sCommand) Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $sOutput = '' Local $iPID = Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sOutput &= StdoutRead($iPID, False, False) If @error Then ExitLoop EndIf Sleep(10) WEnd Return $sOutput EndFunc Local $sCommand= 'netsh wlan delete profile name="wait" & netsh wlan connect name="name" interface="Wi-fi" & netsh wlan show interfaces' MsgBox(0,0,_GetDOSOutput($sCommand))  
    • By D3fr0s7
      I'm trying to make one tray item delete another, but when I do this, all tray items that were created after the deleted item don't work as intended, as if their controlID's were all shifted down one value, and their corresponding tray items now (after deletion) run the code of the tray item before it. Am I missing something? Is there a better way to accomplish what I'm trying to do?
      #include <TrayConstants.au3> #include <Array.au3> HotKeySet ( "{ESC}", "Abort" ) Opt ( "TrayMenuMode", 3 ) TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. Global $aTray[8] ; Defines array to hold tray items. $aTray[0] = TrayCreateItem ( "Test 1 (Name Test 5)" ) $aTray[1] = TrayCreateItem ( "Test 2 (Delete Test 5)" ) $aTray[2] = TrayCreateItem ( "Test 3 (Restore Test 5)" ) $aTray[3] = TrayCreateItem ( "Test 4 (Check if Test 5 is blank or space)" ) $aTray[4] = TrayCreateItem ( "Test 5 Delete Me" ) $aTray[5] = TrayCreateItem ( "Test 6 (Check Test 5 Text)" ) $aTray[6] = TrayCreateItem ( "Test 7 (Read Values)" ) $aTray[7] = TrayCreateItem ( "Test 8 (Count Blanks)" ) While 1 Switch TrayGetMsg() Case $aTray[0] ; "Test 1" Change Test 5 Text. If TrayItemGetText ( $aTray[0] ) <> "" Then Global $TrayText = InputBox ( "Test", "Choose text for Test 5", "Test 5 Delete Me" ) TrayItemSetText ( $aTray[4], $TrayText) EndIf Case $aTray[1] ; "Test 2" Deletes "Test 5". If TrayItemGetText ( $aTray[1] ) <> "" Then Global $TrayDeletedName = TrayItemGetText ( $aTray[4] ) TrayItemDelete ( $aTray[4] ) _ArrayInsert ( $aTray, 4 ) EndIf Case $aTray[2] ; "Test 3" Restores "Test 5". If TrayItemGetText ( $aTray[2] ) <> "" Then $aTray[4] = TrayCreateItem ( $TrayDeletedName ) EndIf Case $aTray[3] ; "Test 4" Check if Test 5 value is blank, space, or filled. If TrayItemGetText ( $aTray[3] ) <> "" Then If TrayItemGetText ( $aTray[4] ) = "" Then MsgBox ( 0, "Test", "Test 5 is blank" ) ElseIf TrayItemGetText ( $aTray[4] ) = " " Then MsgBox ( 0, "Test", "Test 5 is not blank (space)" ) Else MsgBox ( 0, "Test", "Test 5 is assigned a value" ) EndIf EndIf Case $aTray[4] ; "Test 5" (Item to test for, during, and after deletion). If TrayItemGetText ( $aTray[4] ) <> "" Then MsgBox ( 0, "Test", "I'm here!" ) EndIf Case $aTray[5] ; "Test 6" Displays Text from Test 5 item. If TrayItemGetText ( $aTray[5] ) <> "" Then $Test5Text = TrayItemGetText ( $aTray[4] ) MsgBox ( 0, "Test", "Test 5 Text: " & $Test5Text ) EndIf Case $aTray[6] ; "Test 7" Displays all item values. If TrayItemGetText ( $aTray[6] ) <> "" Then MsgBox ( 0, "Test", "$aTray[0]: " & $aTray[0] & @CRLF & _ "$aTray[1]: " & $aTray[1] & @CRLF & _ "$aTray[2]: " & $aTray[2] & @CRLF & _ "$aTray[3]: " & $aTray[3] & @CRLF & _ "$aTray[4]: " & $aTray[4] & @CRLF & _ "$aTray[5]: " & $aTray[5] & @CRLF & _ "$aTray[6]: " & $aTray[6] & @CRLF & _ "$aTray[7]: " & $aTray[7] & @CRLF ) EndIf Case $aTray[7] ; "Test 8" Counts all blanks in tray values. If TrayItemGetText ( $aTray[7] ) <> "" Then Global $blankCount = _ArrayFindAll ( $aTray, "" ) If $blankCount = -1 Then If @error = 6 Then MsgBox ( 0, "Test", "Error, No blanks present") EndIf Else MsgBox ( 0, "Test", "# of blanks: " & $blankCount ) EndIf EndIf EndSwitch WEnd Func Abort() Exit EndFunc Here is a test script I created to try to troubleshoot the problem on my own, with no luck. pay specific attention to "Test 2" ($aTray[1]), "Test 5" ($aTray[4]), and how every tray item after "Test 5" ($aTray[4]) behaves after deletion. Clicking "Test 2" will delete tray item "Test 5", after deletion every item runs the code of the tray item that was established before it (ex. "Test 3" and "Test 4" run their respective code, "Test 5" no longer exists, "Test 6" runs "Test 7", "Test 7" runs "Test 8"), and the last item ("Test 8" $aTray[7]) has no effect when the tray item is clicked. 

      I understand that deleting the tray item changes the controlID, but I don't know in what way it does, and therefore how I can fix it to be able to achieve what I want it to. I appreciate any help or guidance with this problem.

      To clarify, what I'm ultimately trying to do is create a 'while' loop with switch case functions that can exist without necessarily being linked to a tray item, so that I can add and delete them at liberty using the script's functions, without having to differentiate switch case functions with if functions (if $aTray[x] exists, then use this set of switch case functions, etc.). 

      Please, I am in pain. Water come school me again pls
    • By PeterVerbeek
      This topic give you access to an AutoIt functions library I maintain which is called PAL, Peter's AutoIt Library. The latest version 1.26 contains 214 functions divided into these topics:
      window, desktop and monitor GUI, mouse and color GUI controls including graphical buttons (jpg, png) GUI numberbox controls for integer, real, binary and hexadecimal input logics and mathematics include constants string, xml string and file string dialogues and progress bars data lists: lists, stacks, shift registers and key maps (a.ka. dictionaries) miscellaneous: logging/debugging, process and system info Change log and files section  on the PAL website (SourceForge).
      A lot of these functions were created in the development of Peace, Peter's Equalizer APO Configuration Extension, which is a user interface for the system-wide audio driver called Equalizer APO.
    • By jguinch
      Hello.
      I did create these few functions several months ago. I post here, if it can interest someone.
      These functions based on WMI queries allow you to manage printers : add / delete printer, driver, port, or obtain configuration, set default printer ... I let you discover it with the code.

       
      Here is the list of the available functions :
      _PrintMgr_AddLocalPort
      _PrintMgr_AddLPRPort
      _PrintMgr_AddPrinter
      _PrintMgr_AddPrinterDriver
      _PrintMgr_AddTCPIPPrinterPort
      _PrintMgr_AddWindowsPrinterConnection
      _PrintMgr_CancelAllJobs
      _PrintMgr_CancelPrintJob
      _PrintMgr_EnumPorts
      _PrintMgr_EnumPrinter
      _PrintMgr_EnumPrinterConfiguration
      _PrintMgr_EnumPrinterDriver
      _PrintMgr_EnumPrinterProperties
      _PrintMgr_EnumPrintJobs
      _PrintMgr_EnumTCPIPPrinterPort
      _PrintMgr_Pause
      _PrintMgr_PortExists
      _PrintMgr_PrinterExists
      _PrintMgr_PrinterSetComment
      _PrintMgr_PrinterSetDriver
      _PrintMgr_PrinterSetPort
      _PrintMgr_PrinterShare
      _PrintMgr_PrintTestPage
      _PrintMgr_RemoveLocalPort
      _PrintMgr_RemoveLPRPort
      _PrintMgr_RemovePrinter
      _PrintMgr_RemovePrinterDriver
      _PrintMgr_RemoveTCPIPPrinterPort
      _PrintMgr_RenamePrinter
      _PrintMgr_Resume
      _PrintMgr_SetDefaultPrinter
       
       
      And some examples :
      #include <Array.au3> #include "PrintMgr.au3" _Example() Func _Example() ; Remove a printer called "My old Lexmark printer" : _PrintMgr_RemovePrinter("My old Lexmark printer") ; Remove the driver called "Lexmark T640" : _PrintMgr_RemovePrinterDriver("Lexmark T640") ; Remove the TCP/IP printer port called "TCP/IP" _PrintMgr_RemoveTCPIPPrinterPort("MyOLDPrinterPort") ; Add a driver, called "Samsung ML-451x 501x Series", and driver inf file is ".\Samsung5010\sse2m.inf" _PrintMgr_AddPrinterDriver("Samsung ML-451x 501x Series", "Windows NT x86", @ScriptDir & "\Samsung5010", @ScriptDir & "\Samsung5010\sse2m.inf") ; Add a TCP/IP printer port, called "MyTCPIPPrinterPort", with IPAddress = 192.168.1.10 and Port = 9100 _PrintMgr_AddTCPIPPrinterPort("MyTCPIPPrinterPort", "192.168.1.10", 9100) ; Add a printer, give it the name "My Printer", use the driver called "Samsung ML-451x 501x Series" and the port called "MyTCPIPPrinterPort" _PrintMgr_AddPrinter("My Printer", "Samsung ML-451x 501x Series", "MyTCPIPPrinterPort") ; Set the printer called "My Printer" as default printer _PrintMgr_SetDefaultPrinter("My Printer") ; Connect to the shared printer "\\192.168.1.1\HPDeskjetColor") _PrintMgr_AddWindowsPrinterConnection("\\192.168.1.1\HPDeskjetColor") ; List all installed printers Local $aPrinterList = _PrintMgr_EnumPrinter() _ArrayDisplay($aPrinterList) ; List all printers configuration Local $aPrinterConfig = _PrintMgr_EnumPrinterConfiguration() _ArrayDisplay($aPrinterConfig) ; List all installed printer drivers Local $aDriverList = _PrintMgr_EnumPrinterDriver() _ArrayDisplay($aDriverList) ; Retrieve the printer configuration for the printer called "Lexmark T640" $aPrinterConfig = _PrintMgr_EnumPrinterConfiguration("Lexmark T640") _ArrayDisplay($aPrinterConfig) ; Add a local printer port (for a file output) _PrintMgr_AddLocalPort("c:\temp\output.pcl") ; Remove the local port _PrintMgr_RemoveLocalPort("c:\temp\output.pcl") ; Enum a print job Local $aJobList = _PrintMgr_EnumPrintJobs() _ArrayDisplay($aJobList) EndFunc ;==>_Example Download link :
      PrintMgr_Example.au3  
      PrintMgr.au3
    • By Zaoka
      HI,
      for couple of years I'm using  Jos script for sending reports, email with excel attachment. But from last week i'm getting this error when sending excel or word attachment
      message has lines too long for transport jpeg, pdf works with no problems, any sugestion ?
×
×
  • Create New...