This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function ShowWindow( name, title ) | |
REM@description | |
' An AppActivate alternative that shows and activates a window using its process name, window title, or both. | |
REM@author | |
' Jeremy England, http://codeartery.com/ | |
REM@params | |
' name <string> The process name running the window. Use a comma delimited string to add more processes if you're unsure what process will be used. Leave blank "" if you don't know the process. | |
' title <regex> A regular expression string, to match the correct window title. Use "." if you don't know the title. | |
REM@returns | |
' ShowWindow <bool> Returns false if it doesn't find the window; true if it does. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class FormatString | |
REM@description | |
' Evaluates data between { brackets } or user defined tokens, within strings, and allows for easy string appending. | |
REM@author | |
' Jeremy England, http://codeartery.com/ | |
REM@mini | |
' Class FormatString:Private l,r,n,q:Sub Class_Initialize:Tokens="{}":n=vbLf:q="""":End Sub:Property Let Tokens(s):l=Left(s,1):r=Right(s,1):End Property:Property Let Append(f,s):f=f&Format(s):End Property:Public Default Function Format(s):Dim p,d:Format=s:p=InStr(1,Format,l)+1:If(p=1)Then:Exit Function:End If:d=Mid(Format,p,InStr(p,Format,r)-p):Format=Format(Replace(Format,(l&d&r),Eval(d))):End Function:End Class | |
Private tokenL, tokenR, n, q | |
Sub Class_Initialize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function QuickClip( sText ) | |
REM@description | |
' A quick way to set, get, or clear clipboard text. | |
REM@author | |
' Jeremy England, http://codeartery.com/ | |
REM@params | |
' sText <string/null> - null will get the clipboard; a string will set it. | |
REM@return | |
' QuickClip <string> - The contents of your clipboard as a string. | |
REM@mini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class HTMLApp | |
REM@description | |
' A class for creating an HTA window with the ability to return a value on close to the VBScript that called it. | |
' Use the r() javascript function to return a message and close the window. | |
' The return value will be returned to the VBScript Start() function. | |
REM@author | |
' Jeremy England, http://codeartery.com/ | |
REM@mini | |
' Class HTMLApp:Public OnXReturn:Private h,b:Sub AppendHead(c):h=h&Replace(c,"""","""):End Sub:Sub AppendBody(c):b=b&Replace(c,"""","""):End Sub:Function Start:Start=CreateObject("WScript.Shell").Exec("mshta ""about:<html><head><style>html{background:#fff}</style><script>var c=1;function r(s){c=0;new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(s);close()}onbeforeunload=function(){if(c)r("&OnXReturn&")}</script>"&h&"</head><body>"&b&"</body></html>""").StdOut.ReadLine:End Function:End Class | |
Public OnXReturn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class StdMessageStream | |
REM@description | |
' Allows synchronous communication between VBScripts, if you call one from the other. Works with HTA files as well. | |
' If one file is reading, the other needs to be writing. | |
REM@author | |
' Jeremy England, http://codeartery.com/ | |
REM@mini | |
' Class StdMessageStream:Private s,f,x:Private Sub Class_Initialize:Set s=CreateObject("WScript.Shell"):Set f=CreateObject("Scripting.FileSystemObject"):End Sub:Property Let RunFile(a,p):Set x=s.Exec(a&" """&p&""""):End Property:Function Read:If IsObject(x)Then:Read=x.StdOut.ReadLine:Else:Read=f.GetStandardStream(0).ReadLine:End If:End Function:Sub Write(v):If IsObject(x)Then:x.StdIn.WriteLine(v):Else:f.GetStandardStream(1).WriteLine(v):End If:End Sub:End Class | |
Private oWss, oFso, oExe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class FileMessageStream | |
REM@description | |
' Send messages to other scripts whether they're running or not using NTFS multiple data streams. Works with HTA files as well. | |
REM@author | |
' Jeremy England, http://codeartery.com/ | |
REM@mini | |
' Class FileMessageStream:Private o:Private Sub Class_Initialize:Set o=CreateObject("Scripting.FileSystemObject"):End Sub:Function ReadMessages(w):Dim f:If Not IsObject(wscript) And IsObject(window)Then:f=window.location.pathname:Else:f=wscript.scriptfullname:End If:With o.OpenTextFile(f&":FMStream",1,-1):If(.AtEndOfStream And Not w)Then:Exit Function:End If:Do While(.AtEndOfStream And w)::Loop:ReadMessages=.ReadAll():.Close():End With:WriteTo(f,0)="":End Function:Property Let WriteTo(f,a,d):Dim m:If(a)Then:m=8:Else:m=2:End If:If o.FileExists(f)Then:With o.OpenTextFile(f&":FMStream",m,-1):.Write(d):.Close():End With:Else:Err.Raise(53):End If:End Property:End Class | |
Private oFso, gFileNotFound | |
Private Sub Class_Initialize() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Import( vbsFile ) | |
REM@description | |
' Import/include/using code from an external VBScript file. | |
REM@author | |
' Jeremy England, http://codeartery.com/ | |
REM@params | |
' vbsFile <string> - A relative, absolute, or URL path to a file containing vbscript code. | |
REM@returns | |
' Import <bool> - Returns False if the import failed, and True if it succeeded. | |
REM@mini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function CmdOut( pCmd ) | |
REM@description | |
' Run a command prompt command and get its output. | |
REM@params | |
' pCmd <string> - A command prompt command. | |
REM@returns | |
' CmdOut <string> - The output of the command. | |
REM@author | |
' Jeremy England, http://codeartery.com/ | |
REM@mini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function FormatDateAs( dInput, sFormat, padZero ) | |
REM@description | |
' Format a date based off of a user defined 'd', 'm', 'y' pattern. | |
REM@params | |
' dInput <date> - The date to format. | |
' sFormat <string> - The 'd', 'm', 'y' format you want the date in. | |
' padZero <bool> - Pads blank spaces with zeros when extra 'd', 'm', or, 'y's are provided than needed. | |
REM@returns | |
' FormatDateAs <string> - The formatted date. | |
REM@author |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function IsProcessRunning( processNameExe ) | |
IsProcessRunning = GetObject("WinMgmts:\\.\root\cimv2") _ | |
.ExecQuery("SELECT * FROM Win32_Process WHERE Name LIKE '" & processNameExe & "'") _ | |
.Count > 0 | |
End Function |
OlderNewer