CDATA problem
Printed From: MSSpeech-Forum
Category: Windows™ Speech Recognition Forums
Forum Name: Macros and Macro Development
Forum Description: WSR Macros, Tools, Files, and new Macro requests
URL: https://www.msspeech-forum.com/forum_posts.asp?TID=46
Printed Date: 04/Dec/2024 at 8:48pm Software Version: Web Wiz Forums 12.02 - http://www.webwizforums.com
Topic: CDATA problem
Posted By: cactustweeter
Subject: CDATA problem
Date Posted: 27/Dec/2008 at 8:15pm
Brad,
I am a veteran DNS user who is trying to get up to speed with WSR. I'm trying to create the macros I use in DNS that are not available by default in WSR. I bought your book to help me get up to speed on macro programming. I found it a good read. Well worth the money.
I'm currently working on my window manipulation macros. Stuff like move/expand/shrink window <direction> <1to500>. I have the move/expand window macros finished. I'm having trouble with the shrink window macro. Basically I'm trying to use a script block to determine which side of the window to set so I can shrink it. I've tried several things and the following code is my latest revision. There are no compile errors. However, it just doesn't seem to work. Have any suggestions?
<speechMacros> <command> <listenFor>shrink window [Direction] [1to500]</listenFor> <script language='VBScript'> <![CDATA[ Dim strDirection if "{[Direction]}" = "up" then strDirection = "{down}" elseif "{[Direction]}" = "down" then strDirection = "{up}" elseif "{[Direction]}" = "left" then strDirection = "{right}" elseif "{[Direction]}" = "right" then strDirection = "{left}" else strDirection = "{esc}" end if ]]> </script> <!-- set the window for sizing --> <sendKeys>{{alt}}{u+0020}s</sendKeys> <waitFor seconds=".25"/> <!-- set the window side for shrinking --> <sendKeys times="1">{[strDirection]}{5 wait}</sendKeys> <!-- for my computer I had to add the 5 ms delay otherwise the keys were missed --> <sendKeys times="{[1to500]}">{[Direction.Keys]}{5 wait}</sendKeys> <sendKeys>{enter}</sendKeys> </command>
<listenForList name="Direction" propname="Keys"> <item propval="{up}">up</item> <item propval="{down}">down</item> <item propval="{left}">left</item> <item propval="{right}">right</item> </listenForList> </speechMacros>
Thanks...
|
Replies:
Posted By: cactustweeter
Date Posted: 28/Dec/2008 at 3:19pm
I posted the wrong revision of the script. What I posted earlier definitely won't work. However, what's below I believe should work. Sorry for the confusion.
<speechMacros> <command> <listenFor>shrink window [WindowSide] [1to500]</listenFor> <script language="VBScript"> <![CDATA[ Dim strWindowSide if "{[WindowSide]}" = "top" then strWindowSide = "{up}" elseif "{[WindowSide]}" = "bottom" then strWindowSide = "{down}" elseif "{[WindowSide]}" = "left" then strWindowSide = "{left}" elseif "{[WindowSide]}" = "right" then strWindowSide = "{right}" else strWindowSide = "{esc}" end if ]]> </script> <!-- set the window for sizing --> <sendKeys>{{alt}}{u+0020}s</sendKeys> <waitFor seconds=".25"/> <!-- set the window side for shrinking --> <sendKeys times="1">{[strWindowSide]}{5 wait}</sendKeys> <!-- for my computer I had to add the 5 ms delay otherwise the keys were missed --> <sendKeys times="{[1to500]}">{[WindowSide.Keys]}{5 wait}</sendKeys> <sendKeys>{enter}</sendKeys> </command>
<listenForList name="WindowSide" propname="Keys"> <item propval="{down}">top</item> <item propval="{up}">bottom</item> <item propval="{right}">left</item> <item propval="{left}">right</item> </listenForList> <numbers name="1to500" start="1" stop="500"/> </speechMacros>
|
Posted By: BradT
Date Posted: 28/Dec/2008 at 4:58pm
Hi cactustweeter,
Glad the User's Guide has helped you with WSR Macros...
Here's the code I use for resizing windows, maybe it will help or at least give you some ideas. Let me know if you have any questions...
Brad
'********* <?xml version="1.0" encoding="utf-8" ?>
<!-- ResizeWindow - allows resizing of active window (non-maximized) by using ALT-SPACE-S
Syntax: "resize window [SideDirection] [Amount]"
[SideDirection] = top up || top down || bottom up || bottom down || left in || left out || right in || right out [Amount] = 1 to 100
"resize window much smaller" "resize window smaller" "resize window larger" "resize window much larger" Created: 20 August 2008 Author: BradT -->
<speechMacros> <command> <listenFor>resize window [SideDirection] [Amount]</listenFor>
<script language='VBScript'> <![CDATA[ strSideDirection = "{[SideDirection]}" Select Case strSideDirection Case "top up" strSide = "{UP}" strDirection = "{UP}" Case "top down" strSide = "{UP}" strDirection = "{DOWN}" Case "bottom up" strSide = "{DOWN}" strDirection = "{UP}" Case "bottom down" strSide = "{DOWN}" strDirection = "{DOWN}" Case "left in" strSide = "{LEFT}" strDirection = "{RIGHT}" Case "left out" strSide = "{LEFT}" strDirection = "{LEFT}" Case "right in" strSide = "{RIGHT}" strDirection = "{LEFT}" Case "right out" strSide = "{RIGHT}" strDirection = "{RIGHT}" Case Else ' should not happen with SideDirection rule End Select ' ' set named state so we can access it outside VBScript ' NamedStates.SetNamedStateValue "strSide", strSide NamedStates.SetNamedStateValue "strDirection", strDirection ]]> </script>
<sendKeys>{{ALT}}{U+0020}s</sendKeys> <waitFor seconds='.250'/> <sendKeys>{[strSide]}</sendKeys> <!-- note: Not all of the 'times' amount of keystrokes are being received even with a 250 wait --> <sendKeys times='{[Amount]}'>{[strDirection]}{250 WAIT}</sendKeys> <sendKeys>{ENTER}</sendKeys> </command>
<command> <listenFor>resize window smaller</listenFor> <emulateRecognition>resize window bottom up 10</emulateRecognition> <waitFor seconds=".50"/> <emulateRecognition>resize window right in 10</emulateRecognition> </command>
<command> <listenFor>resize window +much +smaller</listenFor> <emulateRecognition>resize window bottom up 50</emulateRecognition> <waitFor seconds=".50"/> <emulateRecognition>resize window right in 50</emulateRecognition> </command>
<command> <listenFor>resize window larger</listenFor> <emulateRecognition>resize window bottom down 10</emulateRecognition> <waitFor seconds=".50"/> <emulateRecognition>resize window right out 10</emulateRecognition> </command>
<command> <listenFor>resize window +much +larger</listenFor> <emulateRecognition>resize window bottom down 50</emulateRecognition> <waitFor seconds=".50"/> <emulateRecognition>resize window right out 50</emulateRecognition> </command> <!-- no commands below here --> <rule name="SideDirection"> <list> <p>top up</p> <p>top down</p> <p>bottom up</p> <p>bottom down</p> <p>left in</p> <p>left out</p> <p>right in</p> <p>right out</p> </list> </rule> <numbers name="Amount" start="1" stop="100"/> </speechMacros>
|
Posted By: cactustweeter
Date Posted: 28/Dec/2008 at 5:44pm
Thanks Brad. Your script showed me this was what I was missing:
' set named state so we can access it outside VBScript ' NamedStates.SetNamedStateValue "strWindowSide", strWindowSide
|
Posted By: BradT
Date Posted: 28/Dec/2008 at 6:54pm
cactustweeter wrote:
Thanks Brad. Your script showed me this was what I was missing:
' set named state so we can access it outside VBScript ' NamedStates.SetNamedStateValue "strWindowSide", strWindowSide
|
Great. I also uploaded the macro here:
http://www.msspeech-forum.com/uploads/public/25/ResizeWindow.txt
|
|