Skip to content

Instantly share code, notes, and snippets.

@simply-coded
simply-coded / ClipBoardText.vbs
Last active July 19, 2024 08:32
Set, get, append, and clear your clipboard text.
Class ClipBoardText
REM @author: Jeremy England ( SimplyCoded )
REM @info: Set, get, append, and clear your clipboard text.
REM @mini: Class ClipBoardText:Property Get Text:Text=CreateObject("HTMLFile").parentWindow.clipboardData.getData("Text"):If IsNull(Text)Then Text="":End If:End Property:Property Let Text(s):CreateObject("WScript.Shell").Run "mshta.exe javascript:eval(""document.parentWindow.clipboardData.setData('text','"&Replace(Replace(s,"'","\\u0027"),"""","\\u0022")&"');close()"")",0,True:End Property:Sub ClearText:Text="":End Sub:Sub AddText(s):Text=Text&s:End Sub:End Class
Property Get Text
Text = CreateObject( "HTMLFile" ).parentWindow.clipboardData.getData( "Text" )
If IsNull( Text )Then Text = ""
End Property
Property Let Text( str )
@simply-coded
simply-coded / FormatString.md
Last active September 5, 2020 14:09
VBScript Class to evaluate data in strings between {curly brackets} or user defined tokens. The class also allows for easy appending of strings.
@simply-coded
simply-coded / OnTopNotepad.ps1
Last active July 20, 2024 14:37
An always on top notepad for taking notes and such.
# makes a notepad process that remains on top of other windows.
$cs = Add-Type -MemberDefinition '
[DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr a, IntPtr b, int c, int d, int e, int f, uint g);
public static void AlwaysOnTop(IntPtr a, int d) { SetWindowPos(a, (IntPtr)(-1), 0, d-250, 300, 200, 64); }
' -Name PS -PassThru;
$hWnd = Start-Process -FilePath notepad -PassThru;
$screen = Get-WmiObject -Class Win32_VideoController | Select-Object CurrentVerticalResolution;
$cs::AlwaysOnTop($hWnd.MainWindowHandle, $screen.CurrentVerticalResolution);
@simply-coded
simply-coded / AlwaysOnTop.vbs
Last active July 20, 2024 14:38
Makes a window always on top if setOnTop is true, else makes it normal again. Will wait up to 10 seconds for window to load.
Sub AlwaysOnTop(appName, regExpTitle, setOnTop)
' @description: Makes a window always on top if setOnTop is true, else makes it normal again. Will wait up to 10 seconds for window to load.
' @author: Jeremy England (SimplyCoded)
If (setOnTop) Then setOnTop = "-1" Else setOnTop = "-2"
CreateObject("wscript.shell").Run "powershell -Command """ & _
"$Code = Add-Type -MemberDefinition '" & vbcrlf & _
" [DllImport(\""user32.dll\"")] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,int Y, int cx, int cy, uint uFlags);" & vbcrlf & _
" [DllImport(\""user32.dll\"")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);" & vbcrlf & _
" public static void AlwaysOnTop (IntPtr fHandle, int insertAfter) {" & vbcrlf & _
" if (insertAfter == -1) { ShowWindow(fHandle, 7); ShowWindow(fHandle, 9); }" & vbcrlf & _
@simply-coded
simply-coded / Window.vbs
Last active July 21, 2024 05:32
Create custom windows with VBScript by running HTML code through MSHTA.
Class Window
'@description: Create a custom window with MSHTA.
'@author: Jeremy England (SimplyCoded).
Private title, style, body, options, width, height, xpos, ypos
Private Sub Class_Initialize()
title = " " : width = 350 : height = 250
xpos = "(screen.width - " & width & ")/2"
ypos = "(screen.height -" & height & ")/2"
style = "html{display:table;}body{display:table-cell;font-family:Arial;background-color:#f6f6f6;}html,body{width:100%;height:100%;margin:0;}"
End Sub
@simply-coded
simply-coded / ShowWindow.md
Last active September 5, 2020 14:13
AppActivate alternative that works even if the window is minimized in VBScript.
@simply-coded
simply-coded / RunAsAdminNoUAC.md
Last active January 6, 2021 16:07
Will run the current VBScript as an administrator without a UAC prompt after the initial setup run.
@simply-coded
simply-coded / BrowseForFolder.vbs
Created August 6, 2017 01:55
Browse for folder dialog box in VBScript.
Function BrowseForFolder()
'@description: Browse for folder dialog.
'@author: Jeremy England (SimplyCoded)
Dim oFolder
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0,"Select a Folder",0,0)
If (oFolder Is Nothing) Then
BrowseForFolder = Empty
Else
BrowseForFolder = oFolder.Self.Path
End If
@simply-coded
simply-coded / QuickZip.vbs
Last active July 21, 2024 05:29
Compress and decompress zip files in VBScript.
Function QuickZip(path)
'@description: Compress and uncompress zip files.
'@author: Jeremy England (SimplyCoded)
Dim oFso : Set oFso = CreateObject("Scripting.FileSystemObject")
Dim oSap : Set oSap = CreateObject("Shell.Application")
Dim oWss : Set oWss = CreateObject("WScript.Shell")
Dim isZip, count, root, base, add, out
Dim isZipping, isCancelable
Const NOT_FOUND = 1
Const NOT_A_ZIP = 2
@simply-coded
simply-coded / Console.md
Last active September 5, 2020 14:17
Run command prompt command and get its output in VBScript.