Statistics Parsing
sql-server
Never really enjoyed reading through the statistics IO results, as it makes it hard to easily guage total impact when you have a long list of tables. A friend referred me to: http://www.statisticsparser.com/ This site is great! However, I really don’t like manually copying and pasting the results each time. I threw together a quick autohotkey script that will detect your clipboard change event, look for “scan count” keyword, and then open a “chrome app”, paste the results and submit. Note that I have the option “window name enabled” at the bottom of the textbox on the webpage. If you don’t the tabcount navigation might be a little off, so tweak this if you want.
Code
#SingleInstance force
#NoEnv
#Persistent
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, Slow
SetTitleMatchMode,2
DetectHiddenWindows, On
DetectHiddenText, On
SendMode, Input
return
; RUN THE HELPER FOR GUIDE ON HOTKEYS/HELPERS
GroupAdd, SSMSGroup, SQL
GroupAdd, SSMSGroup, Microsoft SQL Server Management Studio
GroupAdd, SSMSGroup, Microsoft SQL Server Management Studio
GroupAdd, SSMSGroup, ahk_class HwndWrapper[
#IfWinExist, SSMSGroup
OnClipboardChange:
IfInString, Clipboard, Scan count
{
BlockInput, On
RunWait, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --app=http://statisticsparser.com/index.html, , Max, OutputVarPID ; this is the checkbox right before the field input to... thus one tab to allow input
Sleep, 2000
WinActivate, Statistics Parser
WinSet, AlwaysOnTop, On , Statistics Parser ; this helps ensure it always flips to the top
Loop 8
{
SendInput, {Tab}
sleep 50
}
CleanupInput := Clipboard
Clipboard = ; frees memory
CleanupInput := RegExReplace(CleanupInput, "im)_" ,"") ; for temp tables, remove the really long underscored name seperator for readability
Clipboard = %CleanupInput%
ClipWait, 2, 1
SendInput, ^v ; paste results instead of "inputting values", much faster
Sleep, 1000
Clipboard = ; free memory again
SendInput, {Tab} ; go to the submit button
SendInput, 500
SendInput, {Enter} ; submit
BlockInput, Off
WinSet, AlwaysOnTop, Off , Statistics Parser ; flip back the properties of window to allow to be in background
return
#IfWinActive