StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
jackhab  
#1 Posted : Monday, September 19, 2022 1:09:17 PM(UTC)
jackhab

Rank: Newbie

Reputation:

Groups: Approved
Joined: 7/6/2020(UTC)
Posts: 9
Israel

Thanks: 1 times
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.

Rob  
#2 Posted : Monday, September 19, 2022 8:50:44 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
What's your hotkey?
jackhab  
#3 Posted : Tuesday, September 20, 2022 6:09:23 AM(UTC)
jackhab

Rank: Newbie

Reputation:

Groups: Approved
Joined: 7/6/2020(UTC)
Posts: 9
Israel

Thanks: 1 times
Originally Posted by: Rob Go to Quoted Post
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...
Rob  
#4 Posted : Wednesday, September 21, 2022 4:56:37 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 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);
Users browsing this topic
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.