Rank: Newbie
Groups: Approved
Joined: 2/21/2022(UTC) Posts: 4
|
hello!
i'm moving from strokes+ to the new version and there is one action i can't recreate.
the code in Global Lua tab:
-- search menu
function popupMenu(id)
if id == 1 then acSendKeys("^c") acDelay(50) local s = acGetClipboardText() acShellExecute("open", "https://www.google.com/search?q="..s) acDelay(500) acActivateWindow(owner)
elseif id == 2 then acSendKeys("^c") acDelay(50) local s = acGetClipboardText() acShellExecute("open", "https://www.google.hu/search?hl=hu&meta=lr=lang_hu&q="..s) acDelay(500) acActivateWindow(owner)
elseif id == 3 then acSendKeys("^c") acDelay(50) local s = acGetClipboardText() acShellExecute("open", "https://translate.google.com/#auto/hu/"..s) acDelay(500) acActivateWindow(owner)
else --Do nothing, for the Close Menu item end
and the action: acCreatePopupMenu(gex, gey, "Google,Google HU,Google Translate,Close Menu", ",", "popupMenu")
how can i create this in strokesplus.net? :)
thanks!
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,349 Location: Tampa, FL Thanks: 28 times Was thanked: 416 time(s) in 354 post(s)
|
Try this. Code:sp.SendKeys("^c");
sp.Sleep(50);
var s = encodeURIComponent(clip.GetText());
var popupMenuInfoEx = new PopupMenuInfoEx(action.End);
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Google",
`sp.Run("https://www.google.com/search?q=" + s);`)
);
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Google HU",
`sp.Run("https://www.google.com/search?hl=hu&meta=lr=lang_hu&q=" + s);`)
);
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Google Translate",
`sp.Run("https://translate.google.com/#auto/hu/" + s);`)
);
// Spacer and Close menu
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("-"));
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Close Menu", ""));
sp.ShowPopupMenuEx(popupMenuInfoEx);
Edited by user Tuesday, February 22, 2022 7:49:56 PM(UTC)
| Reason: Added encodeURIComponent
|
|
|
|
Rank: Newbie
Groups: Approved
Joined: 2/21/2022(UTC) Posts: 4
|
oh, it's working! :) thank you for the quick reply!
|
|
|
|
Rank: Newbie
Groups: Approved
Joined: 2/21/2022(UTC) Posts: 4
|
another noob question is, when i select for example "black book" the script only uses the first word for search (in my example "black"). is there a way for searching multiple words?
thanks!
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,349 Location: Tampa, FL Thanks: 28 times Was thanked: 416 time(s) in 354 post(s)
|
Edited the script, change line to: Code:var s = encodeURIComponent(clip.GetText());
That's a javascript function which encodes a string to be URL friendly/valid.
|
|
|
|
Rank: Newbie
Groups: Approved
Joined: 2/21/2022(UTC) Posts: 4
|
now it's perfect for my needs. :) thank you very much!
|
|
|
|
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