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

Notification

Icon
Error

Options
Go to last post Go to first unread
2014218866  
#1 Posted : Tuesday, December 8, 2020 11:31:45 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
Put the script under X2, once the script is triggered, it will be executed twice.
But if the code is placed in a global gesture, the script will only be executed once. I do not know why?


Code:
if (clr.System.Diagnostics.Process.GetProcessesByName('天若OCR文字识别').Length){
sp.Sleep(1200)
sp.SendKeys("{F4}")
sp.Sleep(500)
sp.SendVKey(vk.VK_E);
}else{sp.RunProgram(String.raw`D:\Software\天若OCR文字识别\天若OCR文字识别.exe`, "", "", "", false, true, false);
sp.Sleep(1200)
sp.SendKeys("{F4}")
sp.Sleep(500)
sp.SendVKey(vk.VK_E);
}


UserPostedImage
2014218866  
#2 Posted : Tuesday, December 8, 2020 11:55:20 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
It’s easier to repeat this question by quickly pressing the right mouse button or ESC after pressing the X2 key
Rob  
#3 Posted : Tuesday, December 8, 2020 1:59:09 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
The click events are executed on press and release, that is why it is happening twice.

Use the click.Down property to control the script if you only want it to happen when you press X1 down or when X1 is released.
Code:
//use if(!click.Down) to execute when X1 is released, instead of when pressed as shown below
if(click.Down) {
	if (clr.System.Diagnostics.Process.GetProcessesByName('天若OCR文字识别').Length){
		sp.Sleep(1200)
		sp.SendKeys("{F4}")
		sp.Sleep(500)
		sp.SendVKey(vk.VK_E);
	} else {
		sp.RunProgram(String.raw`D:\Software\天若OCR文字识别\天若OCR文字识别.exe`, "", "", "", false, true, false);
		sp.Sleep(1200)
		sp.SendKeys("{F4}")
		sp.Sleep(500)
		sp.SendVKey(vk.VK_E);
	}
}
thanks 2 users thanked Rob for this useful post.
2014218866 on 12/8/2020(UTC), shoichit on 1/31/2021(UTC)
Users browsing this topic
Guest
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.