9.26.2013

Tips for Unix scripting

I had been creating sequence diagrams for some of the more complicated ksh scripts I've written. And, I still feel this is a great idea for scripts of any great complexity. However, I've also begun using a simple 'call structure' grep where I'll take a main script and subs like so:
grep "\. \." main.ksh >../_DOC/main.callstruct.txt 
. ../_CMD/sub1.ksh 
. ../_CMD/sub2.ksh
grep "\. \." sub1.ksh >>../_DOC/main.callstruct.txt 
...
grep "\. \." sub1.ksh >>../_DOC/main.callstruct.txt 
...

...also, have begun running - redirecting the scripts to an output ../_TEST/main.test.txt file and checking this in along with the other components. And the ../_DOC/main.callstruct.txt file.

8.21.2013

Taking CTRL-\ completely out of my vocabulary

#SCRIPT ~ Taking CTRL-\ completely out of my vocabulary ;- ;AutoIt Script is wicked cool
#NoTrayIcon
;-
; hook ctrl\ display message
HotKeySet("^\","NoCtrlBackSlash")
While 1 
   Sleep(100)
WEnd
;-
Func NoCtrlBackSlash()
   msgbox(4096+48,@ScriptName,"Please don't press this!",5)
   WinActivate("C:\Documents and Settings\mbee\My Documents\$.Michael.T.Bee\","")
   WinFlash("C:\Documents and Settings\mbee\My Documents\$.Michael.T.Bee\","",5,500)   
EndFunc

6.25.2013

powerpivot.ps1

#-
# For those that are still struggling with the Excel 2012 powerpivot add-in
# that comes disabled...
#-
add-type -AssemblyName microsoft.VisualBasic
add-type -AssemblyName System.Windows.Forms
start-sleep -Milliseconds 500
[Microsoft.VisualBasic.Interaction]::AppActivate("Microsoft Office Application Add-In") 
[System.Windows.Forms.SendKeys]::SendWait("{Enter}")   # error
start-sleep -Milliseconds 500
[Microsoft.VisualBasic.Interaction]::AppActivate("Microsoft Excel") 
start-sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("%(Ft)")   # _File/Op_tions
start-sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("(AA)")   # _Advanced ~ _Add-in
start-sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("{Tab}P")   # Select list ~ _PowerPivot
start-sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("%a")    # Select M_anage:
start-sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("C{Tab}{Enter}")  # _Com Select _Go
start-sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait(" {Tab}{Enter}")  # Check Powerpivot Select Ok
start-sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("%g")    # Select Powerpivot menu
start-sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("{Tab}")   # Select Powerpivot window
start-sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait("{Enter}")   # Open
start-sleep -Milliseconds 500
#[Microsoft.VisualBasic.Interaction]::AppActivate("PowerPivot for Excel") 
start-sleep -Milliseconds 30000
[System.Windows.Forms.SendKeys]::SendWait("%(Hw)")   # _Home / Diagram Vie_w

6.05.2013

VirtuaWin.hta ~ an HTML Application to work in tandem with VirtuaWin.exe

https://www.box.com/s/k0wplgfluln53w49uvnx
<HTML>
<HEAD>
<HTA:APPLICATION 
 ID  = 'VirtuaWin' 
 BORDER  = 'none' 
 minimize = 'no' 
 maximize = 'no' 
 borderstyle = 'none' 
 caption  = '' 
 showintaskbar = 'no'
/>
<TITLE></TITLE>
</HEAD>
<BODY style=";overflow:hidden;"
onload='vbscript:VirtuaWin_onload'>
<img id='Exit' 
 title = 'Exit' 
 name = 'Exit' 
 src = 'http://bit.ly/TangoExit' 
 onclick = 'vbscript:VirtuaWin_Exit_Click' 
 valign  = 'yes'
 align   = 'center'
 style = '
 ;width:16
 ;height:16
 ;font-family:wingdings 2
 ;font-size:14
 ;top=2
 ;left=2 
 ;position:absolute;
 ;border:1px solid #021a40
    ' 
/>
<img id='Cut' 
 title = 'Cut' 
 name = 'Cut' 
 valign  = 'yes'
 align   = 'center'
 src     = 'http://bit.ly/TangoCut'
 onclick = 'vbscript:VirtuaWin_Cut_Click' 
 style = '
 ;width:16
 ;height:16
 ;font-family:wingdings 2
 ;font-size:14
 ;top=2
 ;left=20
 ;position:absolute;
 ;border:1px solid #021a40
    ' 
/>
<img id = 'Copy' 
 title = 'Copy' 
 name = 'Copy' 
 src     = 'http://bit.ly/TangoCopy'
 onclick = 'vbscript:VirtuaWin_Copy_Click' 
 valign  = 'yes'
 align   = 'center'
 style = '
 ;width:16
 ;height:16
 ;font-family:wingdings 2
 ;font-size:14
 ;top=2
 ;left=38
 ;position:absolute;
 ;border:1px solid #021a40
    ' 
/>
<img id = 'Paste' 
 title = 'Paste' 
 name = 'Paste' 
 src     = 'http://bit.ly/TangoPaste'
 onclick = 'vbscript:VirtuaWin_Paste_Click' 
 valign  = 'yes'
 align   = 'center'
 style = '
 ;width:16
 ;height:16
 ;font-family:wingdings 2
 ;font-size:14
 ;top=2
 ;left=56
 ;position:absolute;
 ;border:1px solid #021a40
    ' 
/>
<img id = 'Refresh' 
 title = 'Refresh' 
 name = 'Refresh' 
 src     = 'http://bit.ly/TangoRefresh'
 onclick = 'vbscript:VirtuaWin_Refresh' 
 valign  = 'yes'
 align   = 'center'
 style   = '
 ;width:16
 ;height:16
 ;font-family:Webdings
 ;font-size:11
 ;top=2
 ;left=92
 ;position:absolute;
 ;border:1px solid #021a40
    '
/>
<img id = 'Help' 
 title = 'Help' 
 name = 'Help' 
 src     = 'http://bit.ly/TangoHelp'
 onclick = 'vbscript:VirtuaWin_Help' 
 valign  = 'yes'
 align   = 'center'
 style = '
 ;width:16
 ;height:16
 ;font-size:14
 ;top=2
 ;left=110
 ;position:absolute;
 ;border:1px solid #021a40
    ' 
/>
<select id = 'lstDesktop' 
 title = 'Desktop' 
 name = 'lstDesktop' 
 onChange= 'vbscript:VirtuaWin_lstDesktop_Change' 
 style = '
 ;width:1013
 ;left=130
 ;top=1
 ;position:absolute;
    '
 >
</select>
</BODY>
</HTML>
<script type='text/vbscript'>
Dim oSh ,oFS ,sRun ,sPath 
'-
Sub VirtuaWin_onload
  Window.reSizeTo 1147,27 : Window.moveTo 132,0
  sPath=window.location.pathname
  sPath=Replace(sPath,"VirtuaWin.hta","")
  Set oSh=CreateObject("WScript.Shell")
  Set oFS=CreateObject("Scripting.FileSystemObject")
  sRun= _
    Chr(34) & _
    sPath & _
    "/VirtuaWin.exe" & _
    chr(34) & _
    " -msg 1050 0 1 "
  oSh.Run sRun,4,vbFalse
  VirtuaWin_Open_Click
End Sub
'-
Sub VirtuaWin_Exit_Click
  window.close
End Sub
'-
Sub VirtuaWin_Cut_Click
  oSh.sendkeys "%{Tab}^x"
End Sub
'-
Sub VirtuaWin_Copy_Click
  oSh.sendkeys "%{Tab}^c"
End Sub
'-
Sub VirtuaWin_Paste_Click
  oSh.sendkeys "%{Tab}^v"
End Sub
'-
Sub VirtuaWin_Open_Click
  Dim oFile,sFile,sLine,i,oOpt,inode,stext,sinode
  Const ForRead=1,ForWrite=2,ForAppend=8
  Set oFile= _
    oFS.OpenTextFile ( _
      sPath &  _
      "\..\..\Data\config\virtuawin.cfg",ForRead,vbFalse _
      )
  sFile=oFile.ReadAll
  sLine=Split(sFile,vbCrLf)
  For Each oOpt in lstDesktop.Options
  oOpt.RemoveNode
  Next 
  For i=LBound(sLine) To UBound(sLine)
    If Left(sLine(i),11)="desktopName" Then
      If Left(sLine(i),16)<>"desktopNameCount" Then
 sinode=split(sline(i),"#")
 inode=sinode(lbound(sinode))
 inode=replace(inode,"desktopName","")
 stext=trim(sinode(ubound(sinode)))
 Set oOpt = document.createElement ("option")
 oOpt.value = inode
 oOpt.text = inode & stext
 lstDesktop.Options.Add oOpt
      End If
    End If
  Next
  oFile.Close
End Sub
'-
Sub VirtuaWin_lstDesktop_Change 
  sRun= _
    chr(34) & _
    sPath & _
    "\VirtuaWin.exe" & _
    chr(34) & _
    " -msg 1034 " & _
    lstDesktop.value
  oSh.Run sRun,0,vbTrue
End Sub
'-
Sub VirtuaWin_Refresh
    oSh.Sendkeys "{F5}"
End Sub
'-
Sub VirtuaWin_Help
  oSh.Popup _
    "HTA application created as a help for use with VirtuaWin--" & vbLF & _
    "for issues contact Michael.T.Bee.ITProf@GMail.com" & vbLF & vbLF & _
    "No warranties expressed or implied" & vbLF & _
    "AS IS SOFTWARE" & vbLF & vbLF & _
    "Place this file in the '../App/VirtuaWin folder'" ,15,"VirtuaWin.hta"
End Sub
</script>