MSSpeech-Forum Homepage
Forum Home Forum Home > Windows™ Speech Recognition Forums > Macros and Macro Development
  New Posts New Posts RSS Feed - CDATA problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CDATA problem

 Post Reply Post Reply
Author
Message
cactustweeter View Drop Down
Member
Member


Joined: 25/Dec/2008
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote cactustweeter Quote  Post ReplyReply Direct Link To This Post Topic: CDATA problem
    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...
Back to Top
cactustweeter View Drop Down
Member
Member


Joined: 25/Dec/2008
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote cactustweeter Quote  Post ReplyReply Direct Link To This Post 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>

Back to Top
BradT View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 06/Oct/2008
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote BradT Quote  Post ReplyReply Direct Link To This Post 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>

Back to Top
cactustweeter View Drop Down
Member
Member


Joined: 25/Dec/2008
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote cactustweeter Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
BradT View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 06/Oct/2008
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote BradT Quote  Post ReplyReply Direct Link To This Post Posted: 28/Dec/2008 at 6:54pm
Originally posted by cactustweeter 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

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.02
Copyright ©2001-2019 Web Wiz Ltd.

This page was generated in 0.152 seconds.

Microsoft Most Valuable Professional

§- Thank you for visiting our Windows Speech Recognition and Macro Forum.. -§