Wiki Link: [discussion:5442]
Multiple commands (and keystrokes) in one "advanced" XML macro 

Oct 21 2012 at 10:05 PM


Dear All,

I would like to automate a job I have as follows:
1) In order to open a specific window from a website, I have to press ALTf and then after a short delay ALTq. I have managed to do that using the commands below.

<speechMacros>
<command>
<listenFor>Open a new entry</listenFor>
<waitFor seconds="0.25" />
<speak>Opening an entry...</speak>
<sendKeys>ALTf</sendKeys>
<waitFor seconds="0.5" />
<sendKeys>ALTq</sendKeys>
<waitFor seconds="1" />
</command>
</speechMacros>



2) Now I have multiple links (HTML links) and I need to click a link which is called "44325". In Windows speech recognition, I just say the link name; i.e. "44325" and it will click it. How do I do that in XML?

3) Then a page with multiple forms (i.e. input text, radio buttons, drop down menus) how do I select an input text and type some words in there (in XML obviously). Then select a specific text from a drop down menu?


Please help, anything will be much apprecitated.

Where do I find more info about XML for windows speech recognition? Like all the commands and options I have,,,


Thanks guys in advance.

Oct 22 2012 at 1:10 PM
Hey and welcome to the forum!

First of all, a comprehensive list of what can be done using WSRMacros is available at this very site, you can read the wiki and learn a lot from it. Here it is: http://archive.msdn.microsoft.com/wsrmacros/Wiki/View.aspx?title=Windows%20Speech%20Recognition%20Macros%20Wiki&referringTitle=Home
The more important things you need to learn are the executors, which are the base for any macro.

When you need to emulate via macro something you would normally say, you need to use <emulateRecognition>. For example, when you need to click the link called 44325 you should add to your macro the tag <emulateRecognition>44325</emulateRecognition>.

The forms are trickier and I have no idea how to bypass them, specially since they differ depending on what you are trying to do with them and their order, an so forth. For a more general approach, I'd try using TAB until you get where you need to, using <sendKeys>. There is also <insertText> for when you need to input text. I have no idea what can be done for the dropdown menu.

Let us know how it went and what else you might need.

Oct 28 2012 at 9:07 AM


LucasMoraes wrote:
Hey and welcome to the forum!

First of all, a comprehensive list of what can be done using WSRMacros is available at this very site, you can read the wiki and learn a lot from it. Here it is: http://archive.msdn.microsoft.com/wsrmacros/Wiki/View.aspx?title=Windows%20Speech%20Recognition%20Macros%20Wiki&referringTitle=Home
The more important things you need to learn are the executors, which are the base for any macro.

When you need to emulate via macro something you would normally say, you need to use <emulateRecognition>. For example, when you need to click the link called 44325 you should add to your macro the tag <emulateRecognition>44325</emulateRecognition>.

The forms are trickier and I have no idea how to bypass them, specially since they differ depending on what you are trying to do with them and their order, an so forth. For a more general approach, I'd try using TAB until you get where you need to, using <sendKeys>. There is also <insertText> for when you need to input text. I have no idea what can be done for the dropdown menu.

Let us know how it went and what else you might need.




Thank you so much LucasMoraes for your welcome, help and directions to learn more about this awesome tool.

I tried the <emulateRecognition> command and the first time it worked fine. Then I tried it for a few more times and each time it didn't recognise the command! The W.S.R. kept saying: "What was that?"...
I am not sure what is happening there! Do you have some tips?

As per the forms, the insert text works like a treat. It is working fine.

Also, for the dropdown menus, I am not sure if it is always the case, but in my situation just pressing the relevant key, worked. For example, if the drop down list consists of Apple, Orange, Banana, and Cherry, by pressing the letter "O" on the keybord while the dropdown list is highlighted then it automatically selects Orange... So, <sendKeys>O</sendKeys> works perfectly...

Oct 28 2012 at 3:53 PM
You are welcome! We are all here to learn and I'm just paying it forward.

Yeah, sometimes <emulateRecognition> bugs out. Most of the times it's because it processes the commands so fast that it mixes up the previous direct text command with a pseudo-voice command, since it's being emulated. I've found that you can normally prevent that using a <wait>0.1</wait> or <wait>0.5</wait> just before the <emulateRecognition> command. So, for example, instead of:

...
<insertText>BLAH BLAH BLAH</insertText>
<emulateRecognition>4432</emulateRecognition>
...

Try the following:

...
<insertText>BLAH BLAH BLAH</insertText>
<wait>0.1</wait>
<emulateRecognition>4432</emulateRecognition>
...

If that doesnt work, try 0.5 or 1, instead of .1
And if THAT doesnt works as well, then I have no idea what might be wrong XD

I'm happy everything is working as you intended to! I'll gladly accept a cut of your new raise you'll receive for being so productive and speeding up your work as a thank you. I think 20% should do it LOL.

Let us know how the macro went, if everything worked alright or not.

Nov 2 2012 at 4:59 PM


LucasMoraes wrote:
You are welcome! We are all here to learn and I'm just paying it forward.

Yeah, sometimes <emulateRecognition> bugs out. Most of the times it's because it processes the commands so fast that it mixes up the previous direct text command with a pseudo-voice command, since it's being emulated. I've found that you can normally prevent that using a <wait>0.1</wait> or <wait>0.5</wait> just before the <emulateRecognition> command. So, for example, instead of:

...
<insertText>BLAH BLAH BLAH</insertText>
<emulateRecognition>4432</emulateRecognition>
...

Try the following:

...
<insertText>BLAH BLAH BLAH</insertText>
<wait>0.1</wait>
<emulateRecognition>4432</emulateRecognition>
...

If that doesnt work, try 0.5 or 1, instead of .1
And if THAT doesnt works as well, then I have no idea what might be wrong XD

I'm happy everything is working as you intended to! I'll gladly accept a cut of your new raise you'll receive for being so productive and speeding up your work as a thank you. I think 20% should do it LOL.

Let us know how the macro went, if everything worked alright or not.





HaHaHaHaHa, 20% is not bad at all! You've saved my life!!!

I've tried the <wait> c ommand and the one working for me is for 1 second. I don't really mind to wait for a little bit longer....
So, the whole project went good. My next step is to make the macro more dynamic by using the Wildcard commands....

Many thanks indeed LucasMoraes...

Nov 2 2012 at 6:23 PM
I'm really glad everything turned out as it should! And thank you for coming back here and providing feedback as to how the commands worked. Come back whenever you need help with anything.


Updating...
Page view tracker