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

Notification

Icon
Error

Options
Go to last post Go to first unread
randomConstant  
#1 Posted : Tuesday, November 23, 2021 2:13:56 PM(UTC)
randomConstant

Rank: Member

Reputation:

Groups: Approved
Joined: 7/17/2021(UTC)
Posts: 20

Thanks: 5 times
Was thanked: 1 time(s) in 1 post(s)
Hi all,

Following are some of the ways to send keystrokes in S+:

SendKeys:
Code:
sp.SendKeys("^c");


SendVKey:
Code:
sp.SendVKey(vk.CONTROL);


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
Rob  
#2 Posted : Tuesday, November 23, 2021 3:52:40 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 22 times
Was thanked: 315 time(s) in 276 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.
thanks 1 user thanked Rob for this useful post.
randomConstant on 11/23/2021(UTC)
randomConstant  
#3 Posted : Tuesday, November 23, 2021 5:12:27 PM(UTC)
randomConstant

Rank: Member

Reputation:

Groups: Approved
Joined: 7/17/2021(UTC)
Posts: 20

Thanks: 5 times
Was thanked: 1 time(s) in 1 post(s)
Alright thank you very much Rob.
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.