Rank: Advanced Member
Groups: Translators, Approved Joined: 7/17/2021(UTC) Posts: 135
Thanks: 35 times Was thanked: 18 time(s) in 15 post(s)
|
Hi all, Following are some of the ways to send keystrokes in S+: SendKeys:SendVKey:and SendModifiedVKeys:Code:sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_C]);
sp.SendKeys is used in the sample scripts of S+ such as the copy and cut scripts, but I started using sp.SendModifiedVKeys due to its ability to timely send complex keystrokes. I've always been curious if converting all sp.SendKeys in my scripts to sp.SendModifiedVKeys for the sake of consistency would have any affect on the resources, performance, and efficiency of script. I haven't seen a related discussion on forum yet and would love to know the pros and cons of these three methods regarding S+ performance. Thanks
|
1 user thanked randomConstant for this useful post.
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
SendVKey/SendModifiedVKeys/(any of the VKey ones) are the preferred method for a few reasons, mostly international compatibility.
I'm not 100% sure on performance as I haven't benchmarked it, but I would assume it is better because it's not parsing/converting a string to keystrokes. The values passed into the VKey methods are directly resolved to keycodes.
|
2 users thanked Rob for this useful post.
|
|
|
Rank: Advanced Member
Groups: Translators, Approved Joined: 7/17/2021(UTC) Posts: 135
Thanks: 35 times Was thanked: 18 time(s) in 15 post(s)
|
Alright thank you very much Rob.
|
|
|
|
Rank: Newbie
Groups: Approved
Joined: 10/11/2020(UTC) Posts: 1 Location: Santiago
|
Hi Rob I've used s+ for years , although I know very little about scripting. Knowing S+.net, I'm a bit lost... Basic Question: How do I use sp.SendVKey or sp.SendModifiedVKeys to repeat a press key? For example, sp.SendVKey(vk.RMENU) for 3 times? Global Question: To use a command, I have to surf the entire site and then search for many other places After spending several days I have not found an answer to the basic question... Now, Where can I find a manual with the codes used by S+? Sometimes I find something in java forums, sometimes in javascript forums, or in c# etc. What kind of sites should I look at first? I don't know if this will be a good thread for the question, which can be referred to another one less specific and then it can serve more users... My thanks and blessings, Rob
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
It's challenging because S+ exposes so much of the .NET Framework that it's just not practical to reproduce all of Microsoft's documentation. But I do understand it can be challenging to know where to start. In regards to the script engine within S+, the language is JavaScript - which is connected to the .NET Framework via Microsoft ClearScript. So there is a mix of JavaScript syntax and .NET Framework objects/classes. In general, I would say start with seeing if S+ has a built-in function ( sp.) for what you want to do, as it will generally handle most common things. If there isn't something built-in, then look for C# examples and it will usually get you pretty close, with some minor tweak. If you join the Discord server (link on Downloads page), I can usually whip up a quick example script for you pretty quickly. To send a key multiple times, you can just duplicate the line: Code:sp.SendVKey(vk.RMENU);
sp.SendVKey(vk.RMENU);
sp.SendVKey(vk.RMENU);
Or setup a loop: Code:for(var i = 0; i < 3; i++) {
sp.SendVKey(vk.RMENU);
}
|
|
|
|
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