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

Notification

Icon
Error

Options
Go to last post Go to first unread
haito  
#1 Posted : Monday, February 21, 2022 12:18:30 PM(UTC)
haito

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/21/2022(UTC)
Posts: 4
Hungary

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!
Rob  
#2 Posted : Monday, February 21, 2022 12:49:43 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
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

haito  
#3 Posted : Monday, February 21, 2022 1:26:21 PM(UTC)
haito

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/21/2022(UTC)
Posts: 4
Hungary

oh, it's working! :)
thank you for the quick reply!
haito  
#4 Posted : Tuesday, February 22, 2022 6:49:59 PM(UTC)
haito

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/21/2022(UTC)
Posts: 4
Hungary

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!
Rob  
#5 Posted : Tuesday, February 22, 2022 7:50:45 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
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.
haito  
#6 Posted : Tuesday, February 22, 2022 8:17:38 PM(UTC)
haito

Rank: Newbie

Reputation:

Groups: Approved
Joined: 2/21/2022(UTC)
Posts: 4
Hungary

now it's perfect for my needs. :)
thank you very much!
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.