StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
How do I know if the clipboard contains data?
Rank: Member
Groups: Approved
Joined: 12/14/2020(UTC) Posts: 11 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);
}
|
|
|
|
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)
|
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);
}
|
|
|
|
Rank: Member
Groups: Approved
Joined: 12/14/2020(UTC) Posts: 11 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);
}
|
|
|
|
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)
|
It doesn't cause an error for me, can you describe the error messages?
|
|
|
|
Rank: Member
Groups: Approved
Joined: 12/14/2020(UTC) Posts: 11 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.
|
|
|
|
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)
|
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() )
|
|
|
|
Rank: Member
Groups: Approved
Joined: 12/14/2020(UTC) Posts: 11 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()){
|
|
|
|
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)
|
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.
|
|
|
|
Rank: Member
Groups: Approved
Joined: 12/14/2020(UTC) Posts: 11 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.
|
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
How do I know if the clipboard contains data?
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