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

Notification

Icon
Error

Options
Go to last post Go to first unread
fury  
#1 Posted : Thursday, December 17, 2020 11:14:33 AM(UTC)
fury

Rank: Member

Reputation:

Groups: Approved
Joined: 12/14/2020(UTC)
Posts: 11
Korea, Republic Of
Location: busan

Activate gestures after selecting text
Display 'copy' if successful copy of text to clipboard
If copy fails, do nothing.

I tried to make this gesture for more than three hours, but I failed.

What's the problem?Activate gestures after selecting text
Display 'copy' if successful copy of text to clipboard
If copy fails, do nothing.

I tried to make this gesture for more than three hours, but I failed.

What's the problem?

Code:
clip.Clear()
sp.SendModifiedVKeys([vk.CONTROL], [vk.VK_C]);
if(clip.GetDataObject != null){
 var info = new DisplayTextInfo();
 info.Message = 'copy';
 info.Duration = 300;
 info.Location = (action.End.X)+','+(action.End.Y+10); 
 sp.DisplayText(info);
}
Rob  
#2 Posted : Monday, December 21, 2020 6:23:23 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)
Sorry for the delay, for some reason I got a bunch of forum emails just this morning so I didn't see your post until now.

If you're just looking to see if the clipboard contains text, there is a method specifically for that. Also, I would suggest a very slight delay just to allow time for data to be copied before checking the clipboard.
Code:
sp.SendModifiedVKeys([vk.CONTROL], [vk.VK_C]);
sp.Delay(50);
if(clip.ContainsText()){
    var info = new DisplayTextInfo();
    info.Message = 'copy';
    info.Duration = 300;
    info.Location = (action.End.X)+','+(action.End.Y+10); 
    sp.DisplayText(info);
}
fury  
#3 Posted : Sunday, December 27, 2020 11:44:47 PM(UTC)
fury

Rank: Member

Reputation:

Groups: Approved
Joined: 12/14/2020(UTC)
Posts: 11
Korea, Republic Of
Location: busan

55 / 5000
자동완성
Thank you for your answers.

I tested the code you posted and an error occurred.

Code:
clip.Clear()
sp.Delay(50);
sp.SendModifiedVKeys([vk.CONTROL], [vk.VK_C]);
sp.Delay(50);
//Syntax where an error
if(clip.ContainsText()){
//Syntax where an error
    var info = new DisplayTextInfo();
    info.Message = 'copy';
    info.Duration = 300;
    info.Location = (action.End.X)+','+(action.End.Y+10); 
    sp.DisplayText(info);
}
Rob  
#4 Posted : Monday, December 28, 2020 12:46:35 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)
It doesn't cause an error for me, can you describe the error messages?
fury  
#5 Posted : Wednesday, December 30, 2020 1:13:39 AM(UTC)
fury

Rank: Member

Reputation:

Groups: Approved
Joined: 12/14/2020(UTC)
Posts: 11
Korea, Republic Of
Location: busan

There is no error when I remove the parentheses after Clip.ContainsText()

The result of Clip.ContainsText is always true.

Even if the clipboard is null, it is determined by the value of the trure.

The word 'copy' is displayed even if I do not select text and actuate gestures.
Rob  
#6 Posted : Wednesday, December 30, 2020 6:15:21 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)
ContainsText() is a method, so the parentheses are required. Without the parentheses will return true because ClearScript sees clip is a valid object and any potential property name is considered possibly valid.

What is the error you receive when you leave them? ( clip.ContainsText() )
fury  
#7 Posted : Thursday, December 31, 2020 6:14:03 AM(UTC)
fury

Rank: Member

Reputation:

Groups: Approved
Joined: 12/14/2020(UTC)
Posts: 11
Korea, Republic Of
Location: busan

Code:
clip.Clear()
sp.SendModifiedVKeys([vk.CONTROL], [vk.VK_C]);
sp.Delay(50);
if(clip.ContainsText()){
    var info = new DisplayTextInfo();
    info.Message = 'copy';
    info.Duration = 300;
    info.Location = (action.End.X)+','+(action.End.Y+10); 
    sp.DisplayText(info);
}



Script execution failed.

Error: Requested Clipboard operation did not succeed
at Script [3]:4:9 -> if(clip.ContainsText()){


Rob  
#8 Posted : Thursday, December 31, 2020 6:42:41 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)
Okay, that helps point to where the issue is.

Quote:
Requested Clipboard operation did not succeed

That typically means the clipboard is not available, and is a Windows response (not something S+ is doing wrong).

For the purpose of testing, what happens if you do this, to add long delays between the clipboard operations?
Code:
clip.Clear()
sp.Delay(1000);
sp.SendModifiedVKeys([vk.CONTROL], [vk.VK_C]);
sp.Delay(1000);
if(clip.ContainsText()){
    var info = new DisplayTextInfo();
    info.Message = 'copy';
    info.Duration = 300;
    info.Location = (action.End.X)+','+(action.End.Y+10); 
    sp.DisplayText(info);
}

This is just to test, I know it is not a practical solution to have two 1 second pauses, but I want to see if you still receive the error.
fury  
#9 Posted : Thursday, December 31, 2020 6:57:53 AM(UTC)
fury

Rank: Member

Reputation:

Groups: Approved
Joined: 12/14/2020(UTC)
Posts: 11
Korea, Republic Of
Location: busan

An error occurs when you launch a gesture with the letter selected.

If I don't select letters, there will be no errors and the word 'copy' will not be displayed.

As you said, my computer setup and window problems are correct.

I'm going to keep on googling. Thank you for your answer.
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.