1.27.2012

NPPCompare.VBS

'-
Dim aaaNPPCompare _
, oArgs _
, oFs _
, oSh _
, sDir2 _
, sMsg _
, zzzNPPCompare

Sub Help()
    sMsg = _
    " This uses Notepad++ to compare two files.  Assumptions:               " & vbLF & _
    " #1 Notepad++ is installed                                             " & vbLF & _
    " #2 'Compare' plug-in is active, e.g., if Plugins/Compare              " & vbLF & _
    "     doesn't show up -- activate by:                                   " & vbLF & _
    "     Plugins/Plugin Manager/Show Plugin Manager ... check 'Compare'.   "
    Msgbox sMsg,vbOkOnly,WScript.Scriptname
End Sub
'-
Sub QExit
    Set oSh=Nothing
    Set oFS=Nothing
    WScript.Quit
End Sub
'-

Set oSh=CreateObject("WScript.Shell")
Set oFS=CreateObject("Scripting.FileSystemObject")

If Not oFS.FileExists("C:\Program Files\Notepad++\notepad++.exe") Then
    Help
    QExit
End If
'-
Sub ccSleep(seconds)
  cmd = "%COMSPEC% /c ping -n " & _
    1 + seconds & " 127.0.0.1>nul"
  oSh.Run cmd,0,1
End Sub
'-
Set oArgs = WScript.Arguments
If oArgs.Count = 2 Then
  sDir2=Split(oArgs.Item(1),"\")
  oSh.Run _
    chr(34) & "c:\Program Files\" & _
              "Notepad++\" & _
              "notepad++.exe" & chr(34) & " " & _
      chr(34) & oArgs.Item(0) & chr(34) & _
        "," & _
      chr(34) & oArgs.Item(1) & chr(34)
    While Not _
      oSh.AppActivate(sDir2(UBound(sDir2)) & _
        " - Notepad++")
      ccSleep 1
    Wend
    oSh.AppActivate(sDir2(UBound(sDir2)) & _
      " - Notepad++")
    oSh.SendKeys "%P{Enter 2}"
End If

Set oSh=Nothing
Set oFS=Nothing

WScript.Quit

2 comments:

  1. Would like to enhance to work with MWSnap:
    -Check the current MWSnap autosnap folder store, replace with folder of file1
    -Make file1.to.file2.jpg based on last snap size
    append "file2.OK" ~ "file2.Differences". if 'compares' window available ~ not available
    -Restore autosnap folder to original

    ReplyDelete
  2. NB: To fully specify date and time -- extend MWSnap format an additional item, e.g.,
    ^yyyy.mm.dd^hh.nn.ss.s (the final non-leading zero sub-second doesn't appear -- but
    rather something of this form: MWSnap1^2012.02.02^07.20.48.jpg)

    ReplyDelete