StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
How to copy text to clipboard in reliable manner?
Rank: Newbie
Groups: Approved
Joined: 7/6/2020(UTC) Posts: 4 
|
I'm using the following code to Google selected text via hotkey: Code:function CopyAndGoogleSelection() {
sp.Sleep(500)
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_C]);
sp.Sleep(10)
var txt = "www.google.com/search?q=" + encodeURIComponent(clip.GetText())
sp.RunProgram("C:\\Program Files\\Mozilla Firefox\\firefox.exe", txt, "", "", false, false, false);
}
It works pretty much OK as long as I use Sleep() while sending Ctrl-C. If I remove the Sleeps Ctrl-C does not always copy text, which, as I suspect, happens because Ctrl-C is being sent while hotkey is still being pressed. 1. Is there a better/recommend way to copy currently selected text to clipboard reliably? 2. Is there a way to execute script on hotkey-UP instead of hotkey-DOWN? Thanks.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,294  Location: Tampa, FL Thanks: 28 times Was thanked: 404 time(s) in 349 post(s)
|
|
|
|
|
Rank: Newbie
Groups: Approved
Joined: 7/6/2020(UTC) Posts: 4 
|
Originally Posted by: Rob  What's your hotkey? Alt-Zero but I'm having the same problem with a mouse stroke. Adding delays seems like a workaround because I'm doing something wrong...
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,294  Location: Tampa, FL Thanks: 28 times Was thanked: 404 time(s) in 349 post(s)
|
Hmm, my Copy gesture (just right+up line) works fine without any delays. For the hotkey, you can try adding this at the top of your hotkey script - to force release of the Alt key: Code:StrokesPlus.Input.Keyboard.Keys.Release(vk.MENU);
//or sp.SendAltUp();
// May have to try these for left and right alt
//StrokesPlus.Input.Keyboard.Keys.Release(vk.LMENU);
//StrokesPlus.Input.Keyboard.Keys.Release(vk.RMENU);
|
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
How to copy text to clipboard in reliable manner?
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close