Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 Bug Report: control + c ,老是复制出问题 #608

Open
6 tasks done
xiaoboJoin opened this issue Jul 12, 2024 · 28 comments
Open
6 tasks done

🐞 Bug Report: control + c ,老是复制出问题 #608

xiaoboJoin opened this issue Jul 12, 2024 · 28 comments
Labels
bug Something isn't working fixed in next release The issue will be closed once next release is available rare issue

Comments

@xiaoboJoin
Copy link

Please confirm the following:

  • Be sure to check out FAQ
  • I have carefully read the README
  • I have searched through the issues page but couldn't find a solution.(Including issue that has been closed)
  • Easydict has been upgraded to the latest version
  • I understand and agree to the above, and understand that the project maintainer has limited energy, issues that do not follow the rules may be ignored or closed directly

Problem description

打开这个软件的时候,control + c ,老是复制出问题,有时候复制不了,剪切板还是上次复制的内容,有时候要control+c好几次,才能复制到内容,啥原因?

Is the issue consistently reproducible?

Reproducible

Steps to Reproduce

打开这个软件的时候,control + c ,老是复制出问题,有时候复制不了,剪切板还是上次复制的内容,有时候要control+c好几次,才能复制到内容,啥原因?

Screenshot

打开这个软件的时候,control + c ,老是复制出问题,有时候复制不了,剪切板还是上次复制的内容,有时候要control+c好几次,才能复制到内容,啥原因?

Expected result

打开这个软件的时候,control + c ,老是复制出问题,有时候复制不了,剪切板还是上次复制的内容,有时候要control+c好几次,才能复制到内容,啥原因?

Proposed solution (optional)

No response

Device type and OS version

M2 PRO

Are you willing to submit a PR to fix this issue?

  • I'm willing to submit a PR
@xiaoboJoin xiaoboJoin added the bug Something isn't working label Jul 12, 2024
Copy link

Hello xiaoboJoin, Thank you for your first issue contribution 🎉

@tisfeng tisfeng changed the title 打开这个软件的时候,control + c ,老是复制出问题,有时候复制不了,剪切板还是上次复制的内容,有时候要control+c好几次,才能复制到内容,啥原因?🐞 Bug Report: Please fill in the title, don't leave it blank 🐞 Bug Report: control + c ,老是复制出问题 Jul 12, 2024
@tisfeng
Copy link
Owner

tisfeng commented Jul 12, 2024

和这个 #503 类似,可能是 Easydict 强制划词导致的问题,目前没有很好的解决方法,请尝试在设置中关闭这个选项。

电脑上其他类似划词应用也可能导致这个问题,例如 PopClip,有道词典,欧路词典等。

@JackeyLov5
Copy link

和这个#503类似,可能是Easydict 强制划词导致的问题,目前没有很好的解决方法,请尝试在设置中关闭这个选项。

电脑上其他类似的划词也值得关注,例如PopClip,有道词典,欧路词典等。

大哥。我又来了。我最近也发现了这个问题。但是我发现我并没有开启强制划词
image

@tisfeng
Copy link
Owner

tisfeng commented Jul 17, 2024

自动复制也可能会导致这种问题,可以闭关试试。

如果不是以上两种情况,那可能和 Easydict 无关。

92348

@JackeyLov5
Copy link

自动复制也可能会导致这种问题,可以闭关试试。

如果不是以上两种情况,那可能和 Easydict 无关。

92348

我没开这个自动复制 但是当我退出Easydict后 并没有出现类似情况orz

@tisfeng
Copy link
Owner

tisfeng commented Jul 18, 2024

这就比较奇怪了,,Easydict 某些地方确实使用了剪贴板,不确定你有没有触发到。由于一些奇怪的原因,这可能会导致污染剪贴板 😓

但这种问题比较难测试,也不好解决。

@xiaoboJoin
Copy link
Author

image 目前关闭自动复制,不会出错

@JackeyLov5
Copy link

image 目前关闭自动复制,不会出错

我一直关闭 也总是复制不了呢

@tisfeng
Copy link
Owner

tisfeng commented Jul 26, 2024

确定是 Easydict 导致的这个问题吗?关闭后就没有出现了?

如果确定是 Easydict 的问题,还请提供更详细的上下文信息。

@JackeyLov5
Copy link

确定是 Easydict 导致的这个问题吗?关闭后就没有出现了?

如果确定是 Easydict 的问题,还请提供更详细的上下文信息。

确定了 就是easydict的问题。。
当我设置是下图时:
image

我在一个协同表格里滑动选中两个格里的数据 会提示复制成功 其实我并没有任何其他操作,但并没有复制成功,因为当我粘贴时还是上一次的数据

当我设置是下图时:

image 就不会出现复制问题

@tisfeng
Copy link
Owner

tisfeng commented Aug 1, 2024

对比看了一下,似乎只有【划词后自动显示查询图标】选项可能导致问题,但如果不开启强制划词(Cmd + C 取词),默认只会使用 Accessibility 取词,这个是系统的常规 API,按理说它应该是安全的,不太可能导致剪贴板问题。。

很难分析,这个我暂时也看不出哪里有问题 😓

@JackeyLov5
Copy link

对比看了一下,似乎只有【划词后自动显示查询图标】选项可能导致问题,但如果不开启强制划词(Cmd + C 取词),默认只会使用 Accessibility 取词,这个是系统的常规 API,按理说它应该是安全的,不太可能导致剪贴板问题。。

很难分析,这个我暂时也看不出哪里有问题 😓

烦请您多关注该bug 挺折磨的😩

@tisfeng
Copy link
Owner

tisfeng commented Aug 7, 2024

检查代码发现,目前即使未开启【强制划词】选项,Easydict 某些地方也会调用 Cmd + C,我尝试对此进行了修复 #632 ,不确定是否能解决这个问题 🤔

@JackeyLov5
Copy link

检查代码发现,目前即使未开启【强制划词】选项,Easydict 某些地方也会调用 Cmd + C,我尝试对此进行了修复 #632 ,不确定是否能解决这个问题 🤔

thx!

@tisfeng tisfeng added the fixed in next release The issue will be closed once next release is available label Aug 10, 2024
@tisfeng
Copy link
Owner

tisfeng commented Aug 12, 2024

2.8.0 版本已修复该问题。

如果后续还有问题,再来观察。

@JackeyLov5
Copy link

建议重启该问题。经过几天使用 我发现还是有50概率会复制失败 orz

@tisfeng
Copy link
Owner

tisfeng commented Aug 17, 2024

这问题太麻烦了,可能是还没找到根本原因 😥

ok,那就先打开,再观察看看,希望能提供更多有用的信息。

@tisfeng tisfeng reopened this Aug 17, 2024
@tisfeng tisfeng removed the fixed in next release The issue will be closed once next release is available label Aug 18, 2024
@oxoxoxox
Copy link

oxoxoxox commented Sep 2, 2024

我也遇到了相同的问题,在macOS Sonoma 14.6.1 / Safari 17.6上,访问stackoverflow这个网站,没有开强制取词,但系统粘贴板里面会出现待翻译的文本:
image
image

Alfred粘贴板上能看到被取词的文本("English is a West Germanic language in the Indo-European language family")排在我主动CMD+C的文本("tccutil reset AppleEvents com.izual.Easydict")的下面:
image

这是当前的日志:
com.izual.Easydict 2024-09-02--10-23-21-531.log

在测试之前,我已经执行 tccutil reset AppleEvents com.izual.Easydict,重新运行EasyDict,并在弹出窗口中添加了AppleEvent权限:
image

@oxoxoxox
Copy link

oxoxoxox commented Sep 2, 2024

我也遇到了相同的问题,在macOS Sonoma 14.6.1 / Safari 17.6上,访问stackoverflow这个网站,没有开强制取词,但系统粘贴板里面会出现待翻译的文本:

而且,我这里在Safari里面开启了 允许 Apple 事件中的 JavaScript 选项,并重启了Safari,但log里面还是能看到报错"Not authorized to send Apple events to Safari"

@oxoxoxox
Copy link

oxoxoxox commented Sep 2, 2024

我按照 Whisky-App/Whisky#378 这里说的,在iterm里面手动运行 /Applications/Easydict.app/Contents/MacOS/Easydict,结果在取词的时候,可以弹出Safari的权限申请,同意之后,可以正常取词了,而且没有报错"Not authorized to send Apple events to Safari"。

[2024-09-02 19:05:44.587 ● EZEventMonitor ● 395 ● ℹ️] -[EZEventMonitor autoGetSelectedText:] ● auto get selected text
[2024-09-02 19:05:44.589 ● EZEventMonitor ● 519 ● ℹ️] -[EZEventMonitor getSelectedTextByAccessibility:] ● Unsupported Accessibility error: -25212 (kAXErrorNoValue)
[2024-09-02 19:05:44.596 ● EZScriptExecutor ● 124 ● ℹ️] -[EZScriptExecutor runAppleScript:completionHandler:]_block_invoke ● run AppleScript cost: 7.3 ms
[2024-09-02 19:05:44.596 ● EZAppleScriptManager ● 94 ● ℹ️] -[EZAppleScriptManager getSafariSelectedText:]_block_invoke ● Safari selected text: I had the same issue, but if you run the app through terminal (/Applications/Whisky.app/Contents/MacOS/Whisky), then you can run the winetricks
[2024-09-02 19:05:44.979 ● EZWindowManager ● 707 ● ℹ️] -[EZWindowManager selectTextTranslate] ● selectTextTranslate
[2024-09-02 19:05:44.980 ● EZEventMonitor ● 585 ● ℹ️] -[EZEventMonitor isAccessibilityEnabled] ● accessibilityEnabled: 1
[2024-09-02 19:05:44.981 ● EZWindowManager ● 720 ● ℹ️] -[EZWindowManager selectTextTranslate] ● selectTextTranslate windowType: 2
[2024-09-02 19:05:44.983 ● EZEventMonitor ● 519 ● ℹ️] -[EZEventMonitor getSelectedTextByAccessibility:] ● Unsupported Accessibility error: -25212 (kAXErrorNoValue)
[2024-09-02 19:05:44.996 ● EZScriptExecutor ● 124 ● ℹ️] -[EZScriptExecutor runAppleScript:completionHandler:]_block_invoke ● run AppleScript cost: 12.6 ms
[2024-09-02 19:05:44.996 ● EZAppleScriptManager ● 94 ● ℹ️] -[EZAppleScriptManager getSafariSelectedText:]_block_invoke ● Safari selected text: I had the same issue, but if you run the app through terminal (/Applications/Whisky.app/Contents/MacOS/Whisky), then you can run the winetricks
[2024-09-02 19:05:44.996 ● EZWindowManager ● 310 ● ℹ️] -[EZWindowManager showFloatingWindowType:queryText:autoQuery:actionType:atPoint:completionHandler:] ● show floating windowType: 2, queryText: I had the same issue, but if you run the app through terminal (/Applications/Whisky.app/Contents/MacOS/Whisky), then you can run the winetricks, autoQuery: 1, actionType: shortcut_query, atPoint: NSPoint: {1032, 944}

我尝试 tccutil reset All com.izual.Easydict,然后重新运行Easydict,并授权所有的权限申请,但还是报错"Not authorized to send Apple events to Safari"。

com.izual.Easydict 2024-09-02--10-23-21-531(2).log

@oxoxoxox
Copy link

oxoxoxox commented Sep 2, 2024

翻了一下stackoverflow上别人的提问, 可能是需要在plist里面添加 NSAppleEventsUsageDescription 这个key,明天我在本地用xcode编译出来试试看 。

@oxoxoxox
Copy link

oxoxoxox commented Sep 2, 2024

翻了一下stackoverflow上别人的提问, 可能是需要在plist里面添加 NSAppleEventsUsageDescription 这个key,明天我在本地用xcode编译出来试试看 。

本地xcode编译验证,确认添加 NSAppleEventsUsageDescription 后,没有出现"Not authorized to send Apple events to Safari"了。

@tisfeng
Copy link
Owner

tisfeng commented Sep 4, 2024

是这个吗 https://stackoverflow.com/a/55295234/8378840 ,我之前看过,但没人 check 这一点,也就忽略了。

AppleScript 脚本的执行权限很奇怪, 最开始在我电脑上测试时,使用 NSAppleScript 执行取词脚本会失败,直接报没有权限,也不会自动弹窗申请权限,后面我就改用更底层的 NSTask 了,这个初次使用会自动申请权限,大部分用户也都运行正常,我以为就解决了。

这个问题我电脑上无法复现,但既然你测试 NSAppleEventsUsageDescription 有效,那我们就先添加试试看。

@oxoxoxox
Copy link

oxoxoxox commented Sep 5, 2024

是这个吗 https://stackoverflow.com/a/55295234/8378840 ,我之前看过,但没人 check 这一点,也就忽略了。

AppleScript 脚本的执行权限很奇怪, 最开始在我电脑上测试时,使用 NSAppleScript 执行取词脚本会失败,直接报没有权限,也不会自动弹窗申请权限,后面我就改用更底层的 NSTask 了,这个初次使用会自动申请权限,大部分用户也都运行正常,我以为就解决了。

这个问题我电脑上无法复现,但既然你测试 NSAppleEventsUsageDescription 有效,那我们就先添加试试看。

我这边测试,添加NSAppleEventsUsageDescription之后,第一次运行时会弹窗申请权限,我reset所有的权限,然后去掉NSAppleEventsUsageDescription重新编译,第一次运行的时候就不弹窗了,只弹出了shortcuts的申请(这个一直都能正常弹出)。
所以看起来是有效果的,至少在我的MacBook环境下有效。😅

@tisfeng
Copy link
Owner

tisfeng commented Sep 5, 2024

检查了一下代码,其中苹果翻译 shortcuts 脚本是使用 NSTask 执行的,但取词部分浏览器脚本是用 NSAppleScript (这个比 NSTask 速度快一些),这两种类型是不一样的。

测试发现,如果是使用 NSTask 执行脚本,不要 NSAppleEventsUsageDescription 也行,但 NSAppleScript 必须添加 NSAppleEventsUsageDescription,不然会直接报错,并且不会弹窗申请权限。

下个版本将会修改这个问题。

你可以用 #669 测试一下。

27313 88539

@oxoxoxox
Copy link

oxoxoxox commented Sep 6, 2024

检查了一下代码,其中苹果翻译 shortcuts 脚本是使用 NSTask 执行的,但取词部分浏览器脚本是用 NSAppleScript (这个比 NSTask 速度快一些),这两种类型是不一样的。

测试发现,如果是使用 NSTask 执行脚本,不要 NSAppleEventsUsageDescription 也行,但 NSAppleScript 必须添加 NSAppleEventsUsageDescription,不然会直接报错,并且不会弹窗申请权限。

下个版本将会修改这个问题。

你可以用 #669 测试一下。

我本地编译打包release版本安装到/Applications下面,现在Safari下取词正常了,查看log没有权限报错,粘贴板也不会出现被取词的文本了。

@oxoxoxox
Copy link

oxoxoxox commented Sep 6, 2024

@tisfeng 对了,和这个问题关联,有一个bug,在Safari中取词的时候,如果Accessibility取词失败,AppleScript取词也失败的时候(比如没有权限,或者是其他限制),即使设置项中关闭了“允许强制取词”,还是会模拟快捷键 ⌘ + C 强制取词。
代码实际运行没有遵守设置项中的设定。

@tisfeng
Copy link
Owner

tisfeng commented Sep 7, 2024

感谢反馈,查了一下,这里代码确实有问题,已提交 PR 修复 #670

@tisfeng tisfeng added the fixed in next release The issue will be closed once next release is available label Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next release The issue will be closed once next release is available rare issue
Projects
None yet
Development

No branches or pull requests

4 participants