June 24, 2009

WinTask - CleanString$

'
' CleanString$ - replace all occurences of < and > in a string,
'                with < Lower> and < Greater> respectively
'                so it can be safely used with SendKeys()
'
' Author - Joe Strazzere
'

 

Function CleanString$(StringIn$)
    StringIn$=Replace$(StringIn$,"<","{{lt}}")
    StringIn$=Replace$(StringIn$,">","< Greater>")
    StringIn$=Replace$(StringIn$,"{{lt}}","< Lower>")
    CleanString$ = StringIn$
EndFunction

 

'
' For example
'
KeyString$="a < b and b > c"

 

UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
    SendKeys(CleanString$(KeyString$))