Re: !xStatsGraphShowPerformancePicker and setting evar
Brian Wolven <[email protected]>
| Newsgroups | gmane.comp.windows.shells.litestep |
|---|---|
| Message-ID | <[email protected]> |
Hale, Paul wrote:
> Hey guys,
>
> I have found, in person experience only, that the perfmon seems to work
> better for me with xStatsGraph. The only problem is that I am trying to
> make this theme as simple to the the users as possible. I don't want
> them to have to edit a text file. (Blasphemous I know). It's more for
> the newbs, I don't want to have to deal with the "I boke the theme
> emails".
>
> That being said, is there a way to write the contects of the clipboard
> to a file on an event? If I create a button, click on it and execute:
> !xStatsGraphShowPerformancePicker
>
> I want to it to:
>
> !xTextSaveEvar @$ConfigDir$\themevars.rc@ @ThemeVar@ @perfmon string@
>
> Can that be done?
I thought there was an ls clipboard module, but can't find anything ATM. The
following script will do it, though. Execute it as follows (assuming it's saved
as updateThemeVar.vbs):
!execute [wscript "full_path_to_updateThemeVar.vbs"
"your_theme_var_rc_file_path" evar_to_be_replaced]
It'll give an error message if the file does not exist. If the evar does not
exist it won't do anything.
Hopefully.
Make backups. =)
Dim oFS,ArgC,oShell,oHtml
ArgC = Wscript.Arguments.Count
If ArgC = 2 Then
Set oFS = WScript.CreateObject("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject("WScript.Shell")
Set oHtml = WScript.CreateObject("htmlfile")
File = Wscript.Arguments(0)
Key = oFS.GetFileName(Wscript.Arguments(1))
' Value = oFS.GetFileName(Wscript.Arguments(2))
'--- Grab contents of clipboard instead of using command line arg
Value = oHtml.ParentWindow.ClipboardData.GetData("text")
ReplaceLine File,Key,Value '--- function at the bottom of this file
Set oFS = Nothing
Set oShell = Nothing
Set oHtml = Nothing
End If
WScript.Quit
'---
Function ReadTextFile(txtFile)
Const ForReading = 1
Dim MyFile
If (not oFS.FileExists(txtFile)) then
'--- If the file that we want to write to does not exist, then pop up this
'--- msgbox with the critical icon
MsgBox txtFile & " file does not exist!" , 16 , "updateThemeVar.vbs"
ReadTextFile = ""
WScript.Quit
Else
Set MyFile = oFS.OpenTextFile(txtFile,ForReading)
ReadTextFile = MyFile.ReadAll
MyFile.Close
Set MyFile = Nothing
End If
End Function
'---
Sub WriteTextFile(txtFile,text)
Const ForWriting = 2
Dim fOutput
Set fOutput = oFS.OpenTextFile(txtFile,ForWriting,True)
fOutput.Write text
fOutput.Close
Set fOutput = Nothing
End Sub
'---
Sub ReplaceLine(file,Key,value)
filetext = ReadTextFile(file)
With New RegExp
.Global = False
.IgnoreCase = True
.Multiline = True
.Pattern = "^[ \t]*" & key & "[ \t]+.+$"
filetext = .Replace( filetext , key & " """ & value & """" )
End With
WriteTextFile file,filetext
End Sub
---------------------------------------------------------------------
Can't Unsubscribe? Check http://desktopian.org/listunsub.html
LS List Homepage: http://wuzzle.org/list/litestep.php
Get the LS FAQ: http://lsfaq.shellfront.org