Altecice Posted April 5, 2012 Share Posted April 5, 2012 Hello again . after following waters suggestion about using yes/no to determin if a "report" is made. I am trying to figure out how to make my script call the function if "YES" is pressed and not if "NO" is pressed. expandcollapse popup$iResult = MsgBox(4, "Report?", "Would you like a Report made?") If $iResult = 6 Then MsgBox(64, "Report?", "Yes has been pressed!") Call("func1") Else MsgBox(64, "Report?", "No has been pressed!") call("func2") EndIf ;======================Part two gets windows COA from registry and decodes it, saves Dxdiag.txt ready for parsing========================== Func func1() $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 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) $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) 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]", "") EndFunc Func func2() EndFunc you will probably notice that i have an empty function (func2) but i couldn't think of another way of stopping it from executing Func1 anyway. I dont think i fully understand functions but i have been stuck for ages and i have looked at the help page for it as well. The problem i get is when i run the above script i get an error: Line 26 (blahblah) Func MSDecode($msd_prodid, $msd_sep="") Error: "Func" statement has no matching "EndFunc". But as far as i am aware both FUNC1,2 have end func's. So im not really sure what im doing wrong. Thanks for reading . Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 5, 2012 Moderators Share Posted April 5, 2012 Altecice, Just do nothing in the "No" case: $iResult = MsgBox(4, "Report?", "Would you like a Report made?") If $iResult = 6 Then MsgBox(64, "Report?", "Yes has been pressed!") func1() ; You do not need Call - just the function name <<<<<<<<<<<<<<<<<<<<<<<<<< Else MsgBox(64, "Report?", "No has been pressed!") ; Do nothing here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndIf Func func1() ; Code EndFunc All clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Altecice Posted April 5, 2012 Author Share Posted April 5, 2012 (edited) Thanks for your help i didn't know you could just leave it bank! haha I have tried your suggestion but i still get the same error . expandcollapse popup$iResult = MsgBox(4, "Report?", "Would you like a Report made?") If $iResult = 6 Then MsgBox(64, "Report?", "Yes has been pressed!") func1() Else MsgBox(64, "Report?", "No has been pressed!") EndIf Func func1() $a=RegRead("HKLMSOFTWAREMicrosoftWindows NTCurrentVersion", "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 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) $Text = FileRead("C:Documents and SettingsuserDesktopDxDiag.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 SettingsuserDesktopSpecReport.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) 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 SettingsuserDesktopDxDiag.txt") $ReportArrayDATA = StringRegExp($Text,"(?i)(?s)Card name: (.*?)"&@CRLF&".*?Display Memory: (.*?)"&@CRLF&".*?Current Mode: (.*?)"&@CRLF&".*?Monitor: (.*?)"&@CRLF,1) $NewFileHen = FileOpen("C:Documents and SettingsuserDesktopSpecReport.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 SettingsuserDesktopDxDiag.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 SettingsuserDesktopSpecReport.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 SettingsuserDesktopDxDiag.txt") WinClose("[CLASS:#32770]", "") EndFunc the only problemi think might be that i have a function inside a function (func MSDecode) could that be a problem? Edited April 5, 2012 by Altecice Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 5, 2012 Moderators Share Posted April 5, 2012 Altecice,the only problemi think might be that i have a function inside a function (func MSDecode) could that be a problem?It most certainly is! You cannot declare a function within another function - they must be with separate Func/EndFunc blocks. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
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