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

Notification

Icon
Error

Options
Go to last post Go to first unread
liuchina  
#1 Posted : Monday, December 21, 2020 7:29:08 PM(UTC)
liuchina

Rank: Member

Reputation:

Groups: Approved
Joined: 9/25/2018(UTC)
Posts: 29
China
Location: 北京

Thanks: 11 times
Was thanked: 1 time(s) in 1 post(s)
This code does not work and asks for help. Thank you.

On my computer, sp. RunOrActivate ('C:'Windows'System32') works in other scripts, but in ShowPopupMenuEx, it always has error prompts
no


Code:

//For script is running in an action, otherwise use a Point instead of action.End
var popupMenuInfoEx = new PopupMenuInfoEx(action.Start);
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("System", `sp.RunOrActivate('C:\\Windows\\System32');`));//
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("-"));
var mnuSubMenu = new PopupMenuItem("Sub Menu");
    mnuSubMenu.SubMenuItems.Add(new PopupMenuItem("Sub Item 1", `sp.MessageBox("Sub Item 1", "Sub Item 1");`));
    var mnuSubSubMenu = new PopupMenuItem("Sub Sub Menu");
        mnuSubSubMenu.SubMenuItems.Add(new PopupMenuItem("Sub Sub Item 1", `sp.MessageBox("Sub Sub Item 1", "Sub Sub Item 1");`));
    mnuSubMenu.SubMenuItems.Add(mnuSubSubMenu);
    mnuSubMenu.SubMenuItems.Add(new PopupMenuItem("Sub Item 2", `sp.MessageBox("Sub Item 2", "Sub Item 2");`));
popupMenuInfoEx.MenuItems.Add(mnuSubMenu);
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Last", `sp.MessageBox("Last", "Last");`));
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("-"));
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Close Popup", ""));
sp.ShowPopupMenuEx(popupMenuInfoEx);
sp.MouseMove(new Point(action.Start.X+100, action.Start.Y+150));

Edited by user Tuesday, December 22, 2020 5:43:24 PM(UTC)  | Reason: Not specified

Rob  
#2 Posted : Tuesday, December 22, 2020 1:28:33 AM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 18 times
Was thanked: 195 time(s) in 170 post(s)
This works fine for me.

Do you get any kind of error message?
Rob Otter  
#3 Posted : Tuesday, December 22, 2020 4:07:15 AM(UTC)
Rob Otter

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 10/26/2020(UTC)
Posts: 44
Germany
Location: Darmstadt

Thanks: 14 times
Was thanked: 1 time(s) in 1 post(s)
I also don´t have any error with your script - must be something on your machine. I´m running Windows 10 Pro latest.
Btw., nice example, I was not aware of the possibility yet!
liuchina  
#4 Posted : Tuesday, December 22, 2020 5:27:47 PM(UTC)
liuchina

Rank: Member

Reputation:

Groups: Approved
Joined: 9/25/2018(UTC)
Posts: 29
China
Location: 北京

Thanks: 11 times
Was thanked: 1 time(s) in 1 post(s)
On my computer, sp. RunOrActivate ('C:'Windows'System32') works in other scripts, but in ShowPopupMenuEx, it always has error prompts



no

Edited by user Tuesday, December 22, 2020 5:35:29 PM(UTC)  | Reason: Not specified

Rob  
#5 Posted : Tuesday, December 22, 2020 6:38:57 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 18 times
Was thanked: 195 time(s) in 170 post(s)
Ah I see now. Because the string is being passed twice (once in script, once when executed), it has to have special characters escaped twice.

sp.RunOrActivate('C:\\\\Windows\\\\System32');
Code:
var popupMenuInfoEx = new PopupMenuInfoEx(action.Start);
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("System", `sp.RunOrActivate('C:\\\\Windows\\\\System32');`));//
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("-"));
var mnuSubMenu = new PopupMenuItem("Sub Menu");
    mnuSubMenu.SubMenuItems.Add(new PopupMenuItem("Sub Item 1", `sp.MessageBox("Sub Item 1", "Sub Item 1");`));
    var mnuSubSubMenu = new PopupMenuItem("Sub Sub Menu");
        mnuSubSubMenu.SubMenuItems.Add(new PopupMenuItem("Sub Sub Item 1", `sp.MessageBox("Sub Sub Item 1", "Sub Sub Item 1");`));
    mnuSubMenu.SubMenuItems.Add(mnuSubSubMenu);
    mnuSubMenu.SubMenuItems.Add(new PopupMenuItem("Sub Item 2", `sp.MessageBox("Sub Item 2", "Sub Item 2");`));
popupMenuInfoEx.MenuItems.Add(mnuSubMenu);
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Last", `sp.MessageBox("Last", "Last");`));
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("-"));
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Close Popup", ""));
sp.ShowPopupMenuEx(popupMenuInfoEx);
sp.MouseMove(new Point(action.Start.X+100, action.Start.Y+150));
thanks 1 user thanked Rob for this useful post.
liuchina on 12/23/2020(UTC)
liuchina  
#6 Posted : Wednesday, December 23, 2020 5:17:43 PM(UTC)
liuchina

Rank: Member

Reputation:

Groups: Approved
Joined: 9/25/2018(UTC)
Posts: 29
China
Location: 北京

Thanks: 11 times
Was thanked: 1 time(s) in 1 post(s)
Now, the script is working properly
Thank you Rob
Users browsing this topic
Similar Topics
How to pass arguments, use special characters in script (General Discussion)
by Robert "Bob" Belcher, Jr. 12/4/2020 10:18:58 AM(UTC)
Resize windows based on region, holding ALT (Scripts)
by Rob 10/23/2020 1:02:46 PM(UTC)
How can I open a link in background, and how to remove a bookmark (General Discussion)
by lyscop 4/23/2020 10:07:40 AM(UTC)
How to turn off monitor, sleep , hibernate? (Scripts)
by sunnyabcd 4/15/2020 9:53:16 PM(UTC)
Just thanks for your work, Rob! It is great application! (General Discussion)
by kypaku 12/30/2019 1:45:49 PM(UTC)
Hot key, make window always on top? (Feature Requests)
by parrottm 12/12/2019 12:37:33 AM(UTC)
全屏应用时,禁用手势功能 (General Discussion)
by Final 8/13/2019 8:00:42 PM(UTC)
Mouse Events (Hotkeys on X1, X2) sent twice (Bug Reports)
by Roland 6/25/2019 6:27:32 AM(UTC)
system volume,help (Scripts)
by thepromises 6/13/2019 11:12:42 PM(UTC)
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.