Jump to content

input box help


Recommended Posts

hello all i have a script after searching other posts that grabs the dell service tag then rights to a ini. i would like for this to populate into a input, so this can be changed if needed before writing to ini. below is the code i have already and thank you for your help...

this one writes to the ini

#include <GUIConstants.au3>

$Form1 = GUICreate("test", 174, 102, 193, 115)
$Input1 = GUICtrlCreateInput("", 48, 16, 89, 21)
$Label1 = GUICtrlCreateLabel("Asset:", 16, 16, 33, 17)
$Button_Close = GUICtrlCreateButton("Close", 48, 48, 75, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
            Case $GUI_EVENT_CLOSE
    Exit
            Case $Button_Close  
    Exit

    EndSwitch
    
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
    
    IniWrite ( "C:\TAG.ini", "HW Info", "Service Tag", $objItem.IdentifyingNumber )

   Next
Else
    IniWrite ( "C:\TAG.ini", "HW Info", "Service Tag", "Not Found" )
Endif
    
WEndoÝ÷ ÚØb²ÞÂ)e¸­{+r¥è§¶¢­nëbÂ¥vX¤zÚ»-¦n«^¶zYlz»âqëZ«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì((ÀÌØí½É´ÄôU%
ÉÑ ÅÕ½ÐíÑÍÐÅÕ½Ðì°ÄÜаÄÀÈ°ÄäÌ°ÄÄÔ¤(ÀÌØí%¹ÁÕÐÄôU%
Ñɱ
ÉÑ%¹ÁÕÐ ÅÕ½ÐìÅÕ½Ðì°Ðà°ÄØ°àä°ÈĤ(ÀÌØí1°ÄôU%
Ñɱ
ÉÑ1° ÅÕ½ÐíÍÍÐèÅÕ½Ðì°ÄØ°ÄØ°ÌÌ°Äܤ(ÀÌØí ÕÑѽ¹}%¹ÁÕÐôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí%¹ÁÕÐÅÕ½Ðì°Ðà°Ðà°ÜÔ°ÈÔ°À¤)U%MÑMÑÑ¡M]}M!=¤()]¡¥±Ä($ÀÌØí¹5ÍôU%Ñ5Í ¤(%MÝ¥Ñ ÀÌØí¹5Í($%
ÍÀÌØíU%}Y9Q}
1=M($$$($$$$$%
ÍÀÌØí  ÕÑѽ¹}%¹ÁÕÐ($$ÀÌØíÍ%¹¤ôͭѽÁ¥ÈµÀìÅÕ½ÐìÀäÈíQ¹¥¹¤ÅÕ½Ðì($$ÀÌØíÍÑôÅÕ½ÐíMÉÙ¥ôÅÕ½ÐìµÀìÕ¥
ÑɱI ÀÌØí%¹ÁÕÐĤµÀì1($%%¹¥]É¥ÑMÑ¥½¸ ÀÌØíÍ%¹¤°ÅÕ½Ðí10ÅÕ½Ðì°ÀÌØíÍѤ($$(%á¥Ð(((%¹MÝ¥Ñ ($(ÀÌØíݵ±IÑÕɹ%µµ¥Ñ±äôÁàÄÀ(ÀÌØíݵ±½ÉÝÉ=¹±äôÁàÈÀ(ÀÌØí½±%ѵÌôÅÕ½ÐìÅÕ½Ðì(ÀÌØíÍÑÉ
½µÁÕÑÈôÅÕ½Ðí±½±¡½ÍÐÅÕ½Ðì((ÀÌØí½©]5%MÉÙ¥ô=©Ð ÅÕ½ÐíÝ¥¹µµÑÌèÀäÈìÀäÈìÅÕ½ÐìµÀìÀÌØíÍÑÉ
½µÁÕÑȵÀìÅÕ½ÐìÀäÈíɽ½ÐÀäÈí
%5XÈÅÕ½Ðì¤(ÀÌØí½±%ѵÌôÀÌØí½©]5%MÉÙ¥¹áEÕÉä ÅÕ½ÐíM1
P¨I=4]¥¸ÌÉ}
½µÁÕÑÉMåÍѵAɽÕÐÅÕ½Ðì°ÅÕ½Ðí]E0ÅÕ½Ðì°|(ÀÌØíݵ±IÑÕɹ%µµ¥Ñ±ä¬ÀÌØíݵ±½ÉÝÉ=¹±ä¤()%%Í=¨ ÀÌØí½±%ѵ̤ѡ¸(½ÈÀÌØí½©%Ñ´%¸ÀÌØí½±%ѵÌ((%¹¥]É¥Ñ ÅÕ½ÐíèÀäÈíQ¹¥¹¤ÅÕ½Ðì°ÅÕ½Ðí!%¹¼ÅÕ½Ðì°ÅÕ½ÐíMÉÙ¥QÅÕ½Ðì°ÀÌØí%¹ÁÕÐĤ((9áÐ)±Í(%¹¥]É¥Ñ ÅÕ½ÐíèÀäÈíQ¹¥¹¤ÅÕ½Ðì°ÅÕ½Ðí!%¹¼ÅÕ½Ðì°ÅÕ½ÐíMÉÙ¥QÅÕ½Ðì°ÅÕ½Ðí9½Ð½Õ¹ÅÕ½Ðì¤)¹¥($)]¹

thanks again

Link to comment
Share on other sites

If you want to set data to any GUI control use GUICtrlSetData. What i see here is though that it continually is looping and writing to the file. So maybe something like this?

#include <GUIConstants.au3>
Global $sIni = @DesktopDir & "\TAG.ini"
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_ComputerSystemProduct", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) Then
    For $objItem In $colItems

        IniWrite($sIni, "HW Info", "Service Tag", $objItem.IdentifyingNumber)

    Next
Else
    IniWrite($sIni, "HW Info", "Service Tag", "Not Found")
EndIf

$Form1 = GUICreate("test", 174, 102, 193, 115)
$Input1 = GUICtrlCreateInput(IniRead($sIni, 'HW Info', 'Service Tag', ''), 48, 16, 89, 21)
$Label1 = GUICtrlCreateLabel("Asset:", 16, 16, 33, 17)
$Button_Input = GUICtrlCreateButton("Input", 48, 48, 75, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button_Input
            IniWrite($sIni, "HW Info",'Service Tag',GUICtrlRead($Input1))
            Exit
    EndSwitch
WEnd
Edited by Thatsgreat2345
Link to comment
Share on other sites

thank you, that did do the trick, kinda, it also added alot of extra stuff in the ini, not sure why. i have cleaned up the code from earlier, but im still having that same issue, and now a few more. i have noted the code, that again everyone for your help with this...

#include <GUIConstants.au3>

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then ; do i need this code?  it is creating problems i cant seem to end it with like an endif.
For $objItem In $colItems

$Form = GUICreate("System Info", 279, 230, 193, 115)
$UserName = GUICtrlCreateLabel("User Name:", 32, 48, 60, 17)
$ComputerName = GUICtrlCreateLabel("Computer Name", 32, 88, 80, 17)
$ServiceTag = GUICtrlCreateLabel("Service Tag:", 32, 128, 65, 17)
$Group_Information = GUICtrlCreateGroup("Information", 16, 16, 249, 193)
$Input_UserName = GUICtrlCreateInput("" & @UserName, 96, 48, 121, 21)
$Input_ComputerName = GUICtrlCreateInput("" & @ComputerName, 120, 88, 121, 21)
$Input_ServiceTag = GUICtrlCreateInput("", 104, 128, 121, 21) ; this is where i get confused
$Button_Input = GUICtrlCreateButton("Input", 96, 168, 75, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $Button_Input
        $sIni = @DesktopDir & "\tag.ini"
        $sData = "UserName=" & GuiCtrlRead($Input_UserName) & @LF & "ComputerName=" & GuiCtrlRead($Input_ComputerName) & @LF & "ServiceTag=" & GuiCtrlRead($Input_ServiceTag) & @LF
    IniWriteSection($sIni, "DATA", $sData)
            
            Exit            
    EndSwitch       
WEnd
Link to comment
Share on other sites

You don't seem to be trying to use the Obj in the example you are giving so here is just a quick example I've done based on your previous code. I'm no good with objects so I can't really help you about the objects sorry.

#include <GUIConstants.au3>

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$sIni = @DesktopDir & "\tag.ini"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)


$Form = GUICreate("System Info", 279, 230, 193, 115)
$UserName = GUICtrlCreateLabel("User Name:", 32, 48, 60, 17)
$ComputerName = GUICtrlCreateLabel("Computer Name", 32, 88, 80, 17)
$ServiceTag = GUICtrlCreateLabel("Service Tag:", 32, 128, 65, 17)
$Group_Information = GUICtrlCreateGroup("Information", 16, 16, 249, 193)
$Input_UserName = GUICtrlCreateInput(@UserName, 96, 48, 121, 21)
$Input_ComputerName = GUICtrlCreateInput(@ComputerName, 120, 88, 121, 21)
$Input_ServiceTag = GUICtrlCreateInput("", 104, 128, 121, 21) ; this is where i get confused
$Button_Input = GUICtrlCreateButton("Input", 96, 168, 75, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
If IsObj($colItems) Then 
    For $objInput In $colItems
        GUICtrlSetData($Input_ServiceTag,$objInput.IdentifyingNumber)
    Next
EndIf

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button_Input
        $sData = "UserName=" & GuiCtrlRead($Input_UserName) & @LF & "ComputerName=" & GuiCtrlRead($Input_ComputerName) & @LF & "ServiceTag=" & GuiCtrlRead($Input_ServiceTag) & @LF
    IniWriteSection($sIni, "DATA", $sData)
            Exit           
    EndSwitch      
WEnd
Link to comment
Share on other sites

would it be hard, or is it possible to, or can we place text in a certain place? right now the ini ouputs like this...

[DATA]

UserName=Input_Username

ComputerName=Input_ComputerName

ServiceTag=Input_ServiceTag

i need the end result to look like this...

CODE
Start Component

Name = "Form"

Start Group

Name = "AssetForm"

ID = 1

Class = "Information"

Start Attribute

Name = "UserName"

ID = 2

Type = String(50)

Storage = Specific

Value = "Input_UserName"

End Attribute

Start Attribute

Name = "ComputerName"

ID = 3

Type = String(30)

Storage = Specific

Value = "Input_ComuterName"

End Attribute

Start Attribute

Name = "ServiceTag"

ID = 4

Type = String(30)

Storage = Specific

Value = "Input_ServiceTag"

End Attribute

End Group

End Component

i would like to replace or generate the following 3 parts within the code of the ini.

Input_UserName

Input_ComuterName

Input_ServiceTag

i would like to the entry code above out of the autoit script, im just not to sure how to even start going about this. thanks again for the help. i promise this is the last step i need to finish...

Edited by mikeopp
Link to comment
Share on other sites

after doing some more research it would be better if i can output all this code into a file instead of just replace the parts needed from a separate ini. hopefully that makes sense. thanks again everyone for your help.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...