Skip to content

Commit

Permalink
Removed some code, bump version to 1.7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
cary-rowen committed Sep 18, 2023
1 parent ccde7ff commit b1cb391
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 124 deletions.
49 changes: 3 additions & 46 deletions addon/appModules/wechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class AppModule(appModuleHandler.AppModule):
ReportOCRResultTimer=None
OCRResult=None
SOUND_LINK = join(dirname(__file__), "link.wav")
SOUND_UNREAD = join(dirname(__file__), "unread.wav")

SOUND_POPUP = join(dirname(__file__), "popup.wav")
confspec = {
Expand Down Expand Up @@ -48,6 +47,7 @@ def event_nameChange(self, obj, nextHandler):
nextHandler()

def event_gainFocus(self, obj, nextHandler, isFocus=False):
# 读出被转发的消息
try:
if obj.name==None:
if obj.role==role.LISTITEM:
Expand All @@ -56,27 +56,19 @@ def event_gainFocus(self, obj, nextHandler, isFocus=False):
if not speech.isBlank(child.name): ui.message(child.name)
return
except AttributeError: pass

if not obj.windowClassName in ("SelectContactWnd", "CMenuWnd") and obj.name in ("导航", "多选"):
obj.role=role.TOOLBAR

# 消息列表中特殊消息音效提醒
try:
if obj.role==role.LISTITEM and obj.parent.name=="消息":
if obj.value != None:
playWaveFile(self.SOUND_LINK)
except AttributeError: pass

# 群组中成员昵称的报告方式
try:
if obj.role==role.BUTTON and obj.simpleParent.role==role.LISTITEM:
if obj.next.firstChild.firstChild.role==role.STATICTEXT:
obj.name = obj.next.firstChild.firstChild.name
except AttributeError: pass

try:
if obj.name==None:
if obj.role==role.CHECKBOX:
obj.name=obj.simpleFirstChild.simpleNext.simpleNext.name
except AttributeError: pass
nextHandler()


Expand All @@ -97,8 +89,6 @@ def event_foreground(self, obj, nextHandler):
if obj.windowClassName == "ImagePreviewWnd":
wx.CallLater(800, self.clickButton, "提取文字", 0)
wx.CallLater(100, self.ReportOCRResult)
elif obj.windowClassName in("CefWebViewWnd", "SubscriptionWnd"):
wx.CallLater(100, self.FindDocumentObject)
else:
if self.ReportOCRResultTimer:
self.ReportOCRResultTimer.Stop()
Expand All @@ -117,39 +107,6 @@ def ReportOCRResult(self):
except: pass
self.ReportOCRResultTimer = wx.CallLater(100, self.ReportOCRResult)

@script(
description="定位网页文档控件",
category="PC微信增强",
gesture="kb:f6"
)
def script_setWindow(self,gesture):
self.FindDocumentObject()


def FindDocumentObject(self):
fg=api.getForegroundObject()
if fg.simpleFirstChild:
child=fg.simpleFirstChild
elif child.name=="后退":
child = child.simpleParent.simpleFirstChild.simpleNext
api.setNavigatorObject(child)
obj=api.getNavigatorObject()
if obj.role==role.DOCUMENT:
eventHandler.executeEvent("gainFocus",obj)

@script(
description="微信内置浏览器后退到上一页,折叠的群聊返回会话列表",
category="PC微信增强",
gesture="kb:alt+leftArrow"
)
def script_back(self,gesture):
windowClassName = api.getForegroundObject().windowClassName
if windowClassName == "CefWebViewWnd":
self.clickButton("后退", 0)
wx.CallLater(100, self.FindDocumentObject)
elif windowClassName == "WeChatMainWndForPC":
self.clickButton("返回", 36)

@script(
description="关闭微信内置浏览器窗口",
category="PC微信增强",
Expand Down
32 changes: 0 additions & 32 deletions addon/appModules/wechatapp.py

This file was deleted.

31 changes: 0 additions & 31 deletions addon/appModules/wechatappex.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,3 @@ def event_gainFocus(self, obj, nextHandler, isFocus=False):
except: pass
nextHandler()


@script(
description="后退到上一页",
category="PC微信增强",
gesture="kb:alt+leftArrow"
)
def script_back(self,gesture):
self.clickButton("后退")


@script(
description="关闭窗口",
category="PC微信增强",
gesture="kb:control+w"
)
def script_close(self,gesture):
self.clickButton("关闭")

def clickButton(self, name):
obj = api.getForegroundObject()
if not obj:
return
for child in obj.recursiveDescendants:
if child.role == role.BUTTON and child.name == name:
self.click(child)
def click(self, obj):
l, t, w, h = obj.location
x, y = int(l + w / 2), int(t + h / 2)
winUser.setCursorPos(x, y)
mouseHandler.executeMouseMoveEvent(x, y)
mouseHandler.doPrimaryClick()
1 change: 0 additions & 1 deletion addon/appModules/wechatbrowser.py

This file was deleted.

2 changes: 1 addition & 1 deletion buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _(arg):
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
"addon_description": _("""增强 PC微信的使用体验,修复因PC微信无障碍缺陷导致的多处列表项朗读问题,支持朗读公众号留言,修正错误的按钮标签,添加快速键等。"""),
# version
"addon_version": "1.7.0",
"addon_version": "1.7.5",
# Author(s)
"addon_author": "沉浮, Cary-Rowen <manchen_0528@outlook.com>",
# URL for the add-on documentation support
Expand Down
20 changes: 7 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@

* 作者: 沉浮 & Eureka
* NVDA 兼容版本: NVDA2021.2 及以上
* 兼容微信版本: 微信 3.9.5.39
* 兼容微信版本: 微信 3.9.7+

**注: 使微信支持 NVDA 对象文本查看的思路来源于“NV宝盒”。**

## 增强特性
1. 修复因PC微信无障碍缺陷导致的消息转发选择联系人列表无法朗读的问题。
2. 公众号文章留言的朗读支持(需按 NVDA+大键盘8 “打开焦点自动跳转到可聚焦元素”)。
3. Alt+左方向键: 微信内置浏览器/小程序网页后退到上一页,折叠的群聊返回到会话列表。
4. Ctrl+W: 关闭微信内置浏览器/小程序窗口。
5. F3键: 开启/关闭自动朗读新消息(默认关闭)。
6. 消息列表内浏览非普通文本消息时增加音效提示。
7. 支持使用 NVDA 的对象文本查看浏览微信的控件信息。
8. 针对群成员昵称朗读的改进: 开启了“显示群成员昵称”则只读群成员昵称,关闭该选项则只读微信昵称。
9. 微信内置网页文档控件支持自动获取焦点,例如,当微信订阅号文章阅读窗口重新聚焦时,网页文档控件会被设置为系统焦点。
- F6键: 手动定位到网页文档控件。
10. 当在微信中打开包含文字的图片时会自动提取文字并读出结果。
11. 个别场景的控件类型提示,如”工具栏“。
1. 公众号文章留言的朗读支持(需按 NVDA+大键盘8 “打开焦点自动跳转到可聚焦元素”)。
2. F3键: 开启/关闭自动朗读新消息(默认关闭)。
3. 消息列表内浏览非普通文本消息时增加音效提示。
4. 支持使用 NVDA 的对象文本查看浏览微信的控件信息。
5. 针对群成员昵称朗读的改进: 开启了“显示群成员昵称”则只读群成员昵称,关闭该选项则只读微信昵称。
6. 当在微信中打开包含文字的图片时会自动提取文字并读出结果。

0 comments on commit b1cb391

Please sign in to comment.