Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 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);
}
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 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
|
|
|
|
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)
|
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);
}
}
|
2 users thanked Rob for this useful post.
|
|
|
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