Jump to content

Really simple confirmation question


Recommended Posts

Hey guys/girls

I have spent some time to write my first scrpit and now i am editing it to add new functions as a see fit, Anyway i have to my script to check for programs and install if missing and write a basic hardware report. But i have come across a little problem.

Not every computer i build needs a "spec report" so is there someway i can get a message box to appear asking if you would like a report with a simple yes/no?

My code so far for the report is:

$a=RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductId")
If $a<>"" Then
    $xpkey=MSDecode($a, "-")
    ClipPut($xpkey)
    Else
    MsgBox(0,"ERROR","No Product Key Found")
EndIf

Func MSDecode($msd_prodid, $msd_sep="")
$msd_decoded =""
$msd_code="BCDFGHJKMPQRTVWXY2346789"
Dim $msd_encoded[16]
$msd_cnt=0
For $msd_t = 105 To 135 Step + 2
    $msd_encoded[$msd_cnt]=Dec(StringMid($msd_prodid, $msd_t, 2))
    $msd_cnt += 1
Next
$msd_cnt=1
For $msd_t = 29 To 1 Step - 1
If $msd_cnt <> 6 Then
    $msd_mod = 0
    For $msd_r = 14 To 0 Step -1
        $msd_bit = BitOR(BitShift($msd_mod, -8), $msd_encoded[$msd_r])
        $msd_encoded[$msd_r] = Int($msd_bit / 24)
        $msd_mod = Mod($msd_bit, 24)
    Next
    $msd_decoded = StringMid($msd_code, $msd_mod + 1, 1) & $msd_decoded
    $msd_cnt += 1
Else
    $msd_cnt=1
    If $msd_sep<>"" Then $msd_decoded = $msd_sep & $msd_decoded
EndIf
Next
Return $msd_decoded
EndFunc

Send("#r")
WinWaitActive("Run")
Send("dxdiag{Enter}")
WinWaitActive("DirectX Diagnostic Tool")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{Enter}")
WinWaitActive("Save As")
Send("{Enter}")

Sleep(1500)
;======================Part two end==========================

;======================Part three parses data of DxDiag.txt and $xpkey saves parsed data to NewFile System Info.txt same directory (Finished)==========================

$Text = FileRead("C:\Documents and Settings\user\Desktop\DxDiag.txt")
$ReportArrayDATA = StringRegExp($Text,"(?i)(?s)Time of this report: (.*?)"&@CRLF&".*?Operating System: (.*?)"&@CRLF&".*?System Manufacturer: (.*?)"&@CRLF&".*?System Model: (.*?)"&@CRLF&".*?Processor: (.*?)"&@CRLF&".*?Memory: (.*?)"&@CRLF,1)
$NewFileHen = FileOpen("C:\Documents and Settings\user\Desktop\SpecReport.txt", 1)
FileWrite($NewFileHen," #####    #####   ######  #   #  #    #    #   #######  ######"&@CRLF) 
FileWrite($NewFileHen,"#     #  #    #  #    #    #  #  #   #    #       #   #   #"&@CRLF)
FileWrite($NewFileHen,"#        #       #    #    #  #  #  #      #      #   #   #"&@CRLF) 
FileWrite($NewFileHen,"#        #       ######   #   #  ###    #         #   #   #"&@CRLF) 
FileWrite($NewFileHen,"#        #       #         #  #  #  #      #      #   #   #"&@CRLF) 
FileWrite($NewFileHen,"#     #  #    #  #         #  #  #   #    #       #   #   #"&@CRLF) 
FileWrite($NewFileHen," #####    #####   #         #####   #    #    #######   #     ######"&@CRLF) 
FileWrite($NewFileHen," "&@CRLF)
FileWrite($NewFileHen," "&@CRLF)
FileWrite($NewFileHen,"========================"&@CRLF&"Spec Report"&@CRLF&"========================"&@CRLF)
$Input = InputBox("What is the part number?", "Please Enter the Part Number of the laptop you are working on.", "(Part Number here!)")
FileWrite($NewFileHen," "&@CRLF)
FileWrite($NewFileHen,"Part Number: ")
FileWrite($NewFileHen,$Input)
FileWrite($NewFileHen," "&@CRLF)
FileWrite($NewFileHen,"Windows COA: ")
FileWrite($NewFileHen,$xpkey)
FileWrite($NewFileHen," "&@CRLF)
FileWrite($NewFileHen," "&@CRLF)
FileWrite($NewFileHen,"------------------"&@CRLF&"Basic System Info"&@CRLF&"------------------"&@CRLF)
FileWrite($NewFileHen," "&@CRLF)

FileWrite($NewFileHen,"Time of this report: "&$ReportArrayDATA[0]&@CRLF)
   FileWrite($NewFileHen,"Operating System: "&$ReportArrayDATA[1]&@CRLF)
   FileWrite($NewFileHen,"System Manufacturer: "&$ReportArrayDATA[2]&@CRLF)
   FileWrite($NewFileHen,"System Model: "&$ReportArrayDATA[3]&@CRLF)
   FileWrite($NewFileHen,"Processor: "&$ReportArrayDATA[4]&@CRLF)
      FileWrite($NewFileHen,"Memory: "&$ReportArrayDATA[5]&@CRLF)
      FileClose($NewFileHen)

$Text = FileRead("C:\Documents and Settings\user\Desktop\DxDiag.txt")
$ReportArrayDATA = StringRegExp($Text,"(?i)(?s)Card name: (.*?)"&@CRLF&".*?Display Memory: (.*?)"&@CRLF&".*?Current Mode: (.*?)"&@CRLF&".*?Monitor: (.*?)"&@CRLF,1)
$NewFileHen = FileOpen("C:\Documents and Settings\user\Desktop\SpecReport.txt", 1)
FileWrite($NewFileHen," "&@CRLF)
FileWrite($NewFileHen," "&@CRLF)
FileWrite($NewFileHen,"------------------"&@CRLF&"Display Devices"&@CRLF&"------------------"&@CRLF)
FileWrite($NewFileHen," "&@CRLF)
FileWrite($NewFileHen,"Card name: "&$ReportArrayDATA[0]&@CRLF)
   FileWrite($NewFileHen,"Display Memory: "&$ReportArrayDATA[1]&@CRLF)
   FileWrite($NewFileHen,"Current Mode: "&$ReportArrayDATA[2]&@CRLF)
   FileWrite($NewFileHen,"Monitor: "&$ReportArrayDATA[3]&@CRLF)
   FileClose($NewFileHen)
  

$Text = FileRead("C:\Documents and Settings\user\Desktop\DxDiag.txt")
$ReportArrayDATA = StringRegExp($Text,"(?i)(?s)Drive: C(.*?)"&@CRLF&".*?Free Space: (.*?)"&@CRLF&".*?Total Space: (.*?)"&@CRLF&".*?Model: (.*?)"&@CRLF&".*?Drive: D(.*?)"&@CRLF&".*?Model: (.*?)"&@CRLF,1)
$NewFileHen = FileOpen("C:\Documents and Settings\user\Desktop\SpecReport.txt", 1)
FileWrite($NewFileHen," "&@CRLF)
FileWrite($NewFileHen," "&@CRLF)
FileWrite($NewFileHen,"------------------"&@CRLF&"HardDisk & DVD/CD-ROM Drives"&@CRLF&"------------------"&@CRLF)
FileWrite($NewFileHen," "&@CRLF)
FileWrite($NewFileHen,"Drive: C"&$ReportArrayDATA[0]&@CRLF)
   FileWrite($NewFileHen,"Free Space: "&$ReportArrayDATA[1]&@CRLF)
   FileWrite($NewFileHen,"Total Space: "&$ReportArrayDATA[2]&@CRLF)
   FileWrite($NewFileHen,"Model: "&$ReportArrayDATA[3]&@CRLF)
   FileWrite($NewFileHen," "&@CRLF)
      FileWrite($NewFileHen,"Drive: D"&$ReportArrayDATA[4]&@CRLF)
      FileWrite($NewFileHen,"Model: "&$ReportArrayDATA[5]&@CRLF)
      FileClose($NewFileHen)
FileDelete("C:\Documents and Settings\user\Desktop\DxDiag.txt")
WinClose("[CLASS:#32770]", "")
;======================Part three end==========================

Bit confusing but it works!. Just need help with the confirmation, i have looked around at at the messagebox tutorial but i cant seem to get it to work :oops:.

Thanks in advance,

Altie

Link to comment
Share on other sites

Function "MsgBox" will do what you need. You can sepcify the buttons to appear on the MsgBox. Then you check the returnvalue for which button has beend pressed by the user.

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 comment
Share on other sites

Something like this:

$iResult = MsgBox(4, "Report?", "Would you like a Report made?")
If $iResult = 6 Then
  MsgBox(64, "Report?", "Yes has been pressed!")
Else
  MsgBox(64, "Report?", "No has been pressed!")
EndIf

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 comment
Share on other sites

:oops:

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