KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: How do I use SendKeys to type a URL?
Topic Summary:
Created On: 09/21/2020 01:21 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 How do I use SendKeys to type a URL?   - wristofdoom - 09/21/2020 01:21 PM  
 How do I use SendKeys to type a URL?   - Matt_Chambers - 09/21/2020 01:54 PM  
 How do I use SendKeys to type a URL?   - wristofdoom - 09/21/2020 05:18 PM  
 How do I use SendKeys to type a URL?   - Lunis Orcutt - 09/21/2020 05:37 PM  
 How do I use SendKeys to type a URL?   - Lunis Orcutt - 09/21/2020 05:34 PM  
 How do I use SendKeys to type a URL?   - kkkwj - 09/21/2020 10:14 PM  
 How do I use SendKeys to type a URL?   - Edgar - 09/22/2020 11:43 AM  
 How do I use SendKeys to type a URL?   - wristofdoom - 09/22/2020 04:16 PM  
 How do I use SendKeys to type a URL?   - Mav - 09/23/2020 02:28 AM  
 How do I use SendKeys to type a URL?   - Edgar - 09/23/2020 11:26 AM  
 How do I use SendKeys to type a URL?   - harpalus - 09/29/2020 08:00 PM  
 How do I use SendKeys to type a URL?   - PG LTU - 09/30/2020 02:40 AM  
Keyword
 09/21/2020 01:21 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Power Member

Posts: 63
Joined: 09/03/2020

I want to create a script of bookmarks that will open a new tab and go to my frequently used websites. For example, I want to say "new tab my website" and it will create a new browser tab, fill in the browser URL as defined in my script, and hit enter.

 

For simplicity sake, I am just trying to send a single URL to start off, but it's not working. Here's what I have so far, which is not working:

 

Command name: new tab my website

 

Code:

 

Sub Main
SendKeys "^t", 1
SendKeys "%d", 1
SendKeys "{https://admin.mysite.com/Adminportal/#/Mypage}", 1
SendKeys "{Enter}"
End Sub

 

The error seems to be with the URL. The other parts are working. The alert message says "Error invalid keyname."

 

It seems like SendKeys doesn't want to send special characters? Even though they are wrapped up in curly braces?

 

Do I need to "escape" special characters like the slashes and the hashtag?



-------------------------

Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017.



 09/21/2020 01:54 PM
User is offline View Users Profile Print this message

Author Icon
Matt_Chambers
Top-Tier Member

Posts: 272
Joined: 08/09/2018

I think the double slashes are the problem. Try:

SendKeys "admin.mysite.com/Adminportal/#/Mypage", 1
 09/21/2020 05:18 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Power Member

Posts: 63
Joined: 09/03/2020

Thank you. Actually it looks like all I had to do was remove the curly braces. It even works fine with the https://

 

Now I'm confused about the exact function of the curly braces.

 

When are the curly braces necessary or not necessary?

 

My working code:

 

Sub Main
SendKeys "^t", 1
SendKeys "%d", 1
SendKeys "https://website.com", 1
SendKeys "{Enter}"
End Sub


-------------------------

Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017.

 09/21/2020 05:37 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 38137
Joined: 10/01/2006

Sorry, our previous answer might be confusing because we didn't post until you answered your own question.


Braces are typically used to surround keystrokes like {Tab{PgDn 2}{Enter} ect...



-------------------------

Forum Mission Statement
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ext 1



 09/21/2020 05:34 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 38137
Joined: 10/01/2006

Braces don't work for an HTML address. Try the following

Sub Main
SendKeys "^t", 1
Wait 0.1
SendKeys "%d", 1
Wait 0.1
SendKeys "https://admin.mysite.com/Adminportal/#/Mypage{Enter}"
End Sub


-------------------------

Forum Mission Statement
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ext 1



 09/21/2020 10:14 PM
User is offline View Users Profile Print this message

Author Icon
kkkwj
Top-Tier Member

Posts: 512
Joined: 11/05/2015

To be precise and add to Lunis' practical explanation, curly braces are used to surround non-printing keys such as Esc,Control,Alt,PgUp, and so on. You can see a complete list in the Microsoft documentation for SendKeys.

 

Curly braces are also used when you're trying to send curly braces, like so "SendKeys {{}blah blah{}}" is the equivalent of "SendKeys {blah blah}".

 

For some reason, I have a memory that of seeing that you only had to escape the closing curly brace {}}. I could be wrong on that.



-------------------------

Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.3, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones



 09/22/2020 11:43 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 939
Joined: 04/03/2009

Using the curly braces is a method of "escaping" a character with special meaning. You may always put any SINGLE printable character in curly braces ({a} etc.). As kkkwj points out this is particularly important for nonprinting characters:

{End}, {Tab}, {Space}, {Enter} etc.

SendKeys "{Tab}", 1' send a single tab key

SendKeys "{Tab 2}", 1' send two tab keys in rapid succession

SendKeys "+{Tab}", 1' send a single shifted tab key

all of these are well documented:

https://www.nuance.com/products/help/dragon/dragon-for-pc/scriptref/Content/vbs/sendkeys_instruction.htm?Highlight=sendkeys

and, if you are using KnowBrainer, from its Command Editor via the button near the top right corner labeled (in red) "Keys".

However, what is not well documented is how you modify some special characters to escape them. I don't think anyone has ever come up with a documented exhaustive list but some of them are:

"
%
(
^
{
+

Note: you do not need to "escape" the closing parentheses nor the closing curly brace.

 
								

-------------------------

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 09/22/2020 04:16 PM
User is offline View Users Profile Print this message

Author Icon
wristofdoom
Power Member

Posts: 63
Joined: 09/03/2020


However, what is not well documented is how you modify some special characters to escape them.

 

Thanks. But what do you mean by "modify"? Are you just saying that those are characters that need to be escaped with the curly braces?

 

Different topic, but related to the original question: I have run into a situation where my URL is too long to be sent with SendKeys. It throws an error saying that it's too long.

 

What's best practice for sending a long string of text that does not fit inside SendKeys? Do I have to store the long string of text in my clipboard and then paste it?



-------------------------

Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017.

 09/23/2020 02:28 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 235
Joined: 10/02/2008

Just split the long text into several SendKeys commands...

 09/23/2020 11:26 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 939
Joined: 04/03/2009

Originally posted by: wristofdoom

   
Edgar However, what is not well documented is how you modify some special characters to escape them.
 

 

Thanks. But what do you mean by "modify"? Are you just saying that those are characters that need to be escaped with the curly braces?

 

exactly:

SendKeys "{(}{Tab})", 1

this creates a set of open/close parens with some white space in between.

SendKeys "{TAB}TTSPlayString {""}{""}{Left}", 1

Escaping of the open/close quotation mark is a bit trickier; the above inserts a little white space, types out the programming statement "TTSPlayString" followed by a single space, then a open/close quotation mark pair and finally moves the cursor inside the empty quotation marks.



-------------------------

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 09/29/2020 08:00 PM
User is offline View Users Profile Print this message

Author Icon
harpalus
Advanced Member

Posts: 179
Joined: 10/05/2008


Um, I'm probably missing something but if there is a default browser selected in Windows, why not just simply use ShellExecute "URL address". I have a script with a series of if statements that use that command to open up websites in Microsoft edge. The command always opens up the appropriate site in a new tab. I don't know how long the URL address can be with this command but just tested it on a Google search string that is shown below. (I'm writing a history book and to find digitized items often have to throw out a string of words or a quote from a book in the hope that Google will bring up an interesting reference.) I think the URL given below is much longer than what can be sent with SendKeys.

Does anyone know the maximum length of what can be specified with ShellExecute?

ShellExecute "https://books.google.com/books?id=PgUyAQAAMAAJ&pg=PA324&lpg=PA324&dq=are+becoming+bold+and+rebellious+from+their+successful+depredations,+and+should+be+chastised&source=bl&ots=5ZTxGcIXu8&sig=Ypk80woVDWANOR5DM161f916ejA&hl=en&sa=X&ved=0ahUKEwihn-OIxbnLAhUBy2MKHUaFAF0Q6AEIHDAA#v=onepage&q=are%20becoming%20bold%20and%20rebellious%20from%20their%20successful%20depredations%2C%20and%20should%20be%20chastised&f=false"

-------------------------

GaryN

 09/30/2020 02:40 AM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2100
Joined: 03/21/2007

You could use a link shortener:

ShellExecute "https://bit.ly/33cKjNS"



-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



Statistics
31833 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 0 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 493 guests browsing this forum, which makes a total of 493 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2020 FuseTalk™ Inc. All rights reserved.