![]() |
KnowBrainer Speech Recognition | ![]() |
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 |
|
![]() |
![]() |
- wristofdoom | - 09/21/2020 01:21 PM |
![]() |
![]() |
- Matt_Chambers | - 09/21/2020 01:54 PM |
![]() |
![]() |
- wristofdoom | - 09/21/2020 05:18 PM |
![]() |
![]() |
- Lunis Orcutt | - 09/21/2020 05:37 PM |
![]() |
![]() |
- Lunis Orcutt | - 09/21/2020 05:34 PM |
![]() |
![]() |
- kkkwj | - 09/21/2020 10:14 PM |
![]() |
![]() |
- Edgar | - 09/22/2020 11:43 AM |
![]() |
![]() |
- wristofdoom | - 09/22/2020 04:16 PM |
![]() |
![]() |
- Mav | - 09/23/2020 02:28 AM |
![]() |
![]() |
- Edgar | - 09/23/2020 11:26 AM |
![]() |
![]() |
- harpalus | - 09/29/2020 08:00 PM |
![]() |
![]() |
- PG LTU | - 09/30/2020 02:40 AM |
![]() |
|
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. |
|
|
|
![]() |
|
I think the double slashes are the problem. Try:
SendKeys "admin.mysite.com/Adminportal/#/Mypage", 1 |
|
|
|
![]() |
|
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. |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
Braces don't work for an HTML address. Try the following
Sub Main
SendKeys "^t", 1
Wait 0.1
SendKeys "%d", 1
SendKeys "https://admin.mysite.com/Adminportal/#/Mypage{Enter}"
End Sub
------------------------- Forum Mission Statement |
|
|
|
![]() |
|
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.61, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse |
|
|
|
![]() |
|
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". "
%
(
^
{
+
Note: you do not need to "escape" the closing parentheses nor the closing curly brace. ------------------------- -Edgar |
|
|
|
![]() |
|
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. |
|
|
|
![]() |
|
Just split the long text into several SendKeys commands... |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
You could use a link shortener: -------------------------
|
|
|
FuseTalk Standard Edition v4.0 - © 1999-2021 FuseTalk™ Inc. All rights reserved.