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

[功能请求] 输入状态提示 #52

Open
photkey opened this issue Jan 21, 2024 · 13 comments
Open

[功能请求] 输入状态提示 #52

photkey opened this issue Jan 21, 2024 · 13 comments

Comments

@photkey
Copy link

photkey commented Jan 21, 2024

现在已经利用nssm设置了开机自启动+隐藏cmd窗口,在输入的时候有些不踏实,所以希望能够加入输入状态提示;

按下启动热键 开始语音识别时,获取当前光标位置,并在该位置 显示一个gif图片,这样更加有确认感:

  • 确认CapsWriter已启动,且当前正在进行语音输入;
  • 确认当前语音输入的位置
@HaujetZhao
Copy link
Owner

键盘上的 caps lock 状态灯,不就是指示吗,如果按下亮起,松开灭掉,那就是表明录音成功

@photkey
Copy link
Author

photkey commented Jan 21, 2024

caps lock 状态灯 只能确认是否按下capslock键,无法确认CapsWriter已启动 且当前正在语音输入状态,也无法确认当前输入位置;我觉得capslock状态灯 不能解决这个需求;而且看状态灯 需要低头看。

@photkey
Copy link
Author

photkey commented Jan 21, 2024

主要是没有这个状态提示,没有反馈,心里不踏实;如果按下按键就弹出图标提示,会有个即时的反馈,我觉得体验是会更好一些的。

@HaujetZhao
Copy link
Owner

在可见的未来两年内,我无法添加图形提示

@H1DDENADM1N
Copy link

@photkey 试试我这个,在tray有图标会不会安心点 #53

start_server_and_client_in_tray

@photkey
Copy link
Author

photkey commented Jan 22, 2024

自己折腾了一个,虽然效果不完美,但是比没有还是好一些的,这个效果还可以
capswriter

@photkey
Copy link
Author

photkey commented Jan 22, 2024

@photkey 试试我这个,在tray有图标会不会安心点 #53

@H1DDENADM1N 你这个项目挺好的,用起来挺方便,但是对我这个需求帮助不大,一个是看托盘图标还是不够方便,另外一个是对于这个用途来说 跟下图的托盘图标其实效果也差不太多
Snipaste_2024-01-23_04-37-47

期待你的GUI 能更新更多功能。

@H1DDENADM1N
Copy link

自己折腾了一个,虽然效果不完美,但是比没有还是好一些的,这个效果还可以

capswriter

哇,这效果不错,代码能发下吗?

@photkey
Copy link
Author

photkey commented Jan 23, 2024

哇,这效果不错,代码能发下吗?

#Requires AutoHotkey v2.0
CoordMode("ToolTip", "Screen")


~CapsLock::{
    if hwnd := GetCaretPosEx(&x, &y, &w, &h){
        ; 能够获取到文本光标时,提示信息在光标位置,且x坐标向右偏移5
        x := x + 5
    }
    else{
        ; 获取不到文本光标时,提示信息在当前窗口的位置
        WinGetPos &X, &Y, &W, &H, "A"
        x := X + W * 0.25
        y := Y + H * 0.7
    }
    ToolTip("✦语音输入中‧‧‧", x, y) ; 提示信息内容
    KeyWait("CapsLock")
    ToolTip()
    return
}


GetCaretPosEx(&x?, &y?, &w?, &h?) {
    x := h := w := h := 0
    static iUIAutomation := 0, hOleacc := 0, IID_IAccessible, guiThreadInfo, _ := init()
    if !iUIAutomation || ComCall(8, iUIAutomation, "ptr*", eleFocus := ComValue(13, 0), "int") || !eleFocus.Ptr
        goto useAccLocation
    if !ComCall(16, eleFocus, "int", 10002, "ptr*", valuePattern := ComValue(13, 0), "int") && valuePattern.Ptr
        if !ComCall(5, valuePattern, "int*", &isReadOnly := 0) && isReadOnly
            return 0
    useAccLocation:
    ; use IAccessible::accLocation
    hwndFocus := DllCall("GetGUIThreadInfo", "uint", DllCall("GetWindowThreadProcessId", "ptr", WinExist("A"), "ptr", 0, "uint"), "ptr", guiThreadInfo) && NumGet(guiThreadInfo, A_PtrSize == 8 ? 16 : 12, "ptr") || WinExist()
    if hOleacc && !DllCall("Oleacc\AccessibleObjectFromWindow", "ptr", hwndFocus, "uint", 0xFFFFFFF8, "ptr", IID_IAccessible, "ptr*", accCaret := ComValue(13, 0), "int") && accCaret.Ptr {
        NumPut("ushort", 3, varChild := Buffer(24, 0))
        if !ComCall(22, accCaret, "int*", &x := 0, "int*", &y := 0, "int*", &w := 0, "int*", &h := 0, "ptr", varChild, "int")
            return hwndFocus
    }
    if iUIAutomation && eleFocus {
        ; use IUIAutomationTextPattern2::GetCaretRange
        if ComCall(16, eleFocus, "int", 10024, "ptr*", textPattern2 := ComValue(13, 0), "int") || !textPattern2.Ptr
            goto useGetSelection
        if ComCall(10, textPattern2, "int*", &isActive := 0, "ptr*", caretTextRange := ComValue(13, 0), "int") || !caretTextRange.Ptr || !isActive
            goto useGetSelection
        if !ComCall(10, caretTextRange, "ptr*", &rects := 0, "int") && rects && (rects := ComValue(0x2005, rects, 1)).MaxIndex() >= 3 {
            x := rects[0], y := rects[1], w := rects[2], h := rects[3]
            return hwndFocus
        }
        useGetSelection:
        ; use IUIAutomationTextPattern::GetSelection
        if textPattern2.Ptr
            textPattern := textPattern2
        else if ComCall(16, eleFocus, "int", 10014, "ptr*", textPattern := ComValue(13, 0), "int") || !textPattern.Ptr
            goto useGUITHREADINFO
        if ComCall(5, textPattern, "ptr*", selectionRangeArray := ComValue(13, 0), "int") || !selectionRangeArray.Ptr
            goto useGUITHREADINFO
        if ComCall(3, selectionRangeArray, "int*", &length := 0, "int") || length <= 0
            goto useGUITHREADINFO
        if ComCall(4, selectionRangeArray, "int", 0, "ptr*", selectionRange := ComValue(13, 0), "int") || !selectionRange.Ptr
            goto useGUITHREADINFO
        if ComCall(10, selectionRange, "ptr*", &rects := 0, "int") || !rects
            goto useGUITHREADINFO
        rects := ComValue(0x2005, rects, 1)
        if rects.MaxIndex() < 3 {
            if ComCall(6, selectionRange, "int", 0, "int") || ComCall(10, selectionRange, "ptr*", &rects := 0, "int") || !rects
                goto useGUITHREADINFO
            rects := ComValue(0x2005, rects, 1)
            if rects.MaxIndex() < 3
                goto useGUITHREADINFO
        }
        x := rects[0], y := rects[1], w := rects[2], h := rects[3]
        return hwndFocus
    }
    useGUITHREADINFO:
    if hwndCaret := NumGet(guiThreadInfo, A_PtrSize == 8 ? 48 : 28, "ptr") {
        if DllCall("GetWindowRect", "ptr", hwndCaret, "ptr", clientRect := Buffer(16)) {
            w := NumGet(guiThreadInfo, 64, "int") - NumGet(guiThreadInfo, 56, "int")
            h := NumGet(guiThreadInfo, 68, "int") - NumGet(guiThreadInfo, 60, "int")
            DllCall("ClientToScreen", "ptr", hwndCaret, "ptr", guiThreadInfo.Ptr + 56)
            x := NumGet(guiThreadInfo, 56, "int")
            y := NumGet(guiThreadInfo, 60, "int")
            return hwndCaret
        }
    }
    return 0
    static init() {
        try
            iUIAutomation := ComObject("{E22AD333-B25F-460C-83D0-0581107395C9}", "{30CBE57D-D9D0-452A-AB13-7AC5AC4825EE}")
        hOleacc := DllCall("LoadLibraryW", "str", "Oleacc.dll", "ptr")
        NumPut("int64", 0x11CF3C3D618736E0, "int64", 0x719B3800AA000C81, IID_IAccessible := Buffer(16))
        guiThreadInfo := Buffer(A_PtrSize == 8 ? 72 : 48), NumPut("uint", guiThreadInfo.Size, guiThreadInfo)
    }
}

需要安装:autohotkey V2

@H1DDENADM1N
Copy link

需要安装:autohotkey V2

感谢,用上了,发现新天地呀

@H1DDENADM1N
Copy link

需要安装:autohotkey V2

我把它封装exe并加到GUI里了,跟随start_client_gui.exe一起启动停止,美滋滋🥰

@Cirsth
Copy link

Cirsth commented Jan 26, 2024

需要安装:autohotkey V2

我把它封装exe并加到GUI里了,跟随start_client_gui.exe一起启动停止,美滋滋🥰

好像有个BUG,运行start.exe的时候hint_while_recording.exe并不会自动启停,要单独运行start_client_gui.exe才行。

@H1DDENADM1N
Copy link

好像有个BUG,运行start.exe的时候hint_while_recording.exe并不会自动启停,要单独运行start_client_gui.exe才行。

就是这样设计的,start.exe调用的start.py就没写启停hint_while_recording.exe相关功能的代码😂。
另转录功能相关的代码也是只有start_client_gui.exe才有哈。
这里有提到 服务端、客户端分离 的原因。start.exe也不会再更新加入更多功能。
不过如果有需要你可以自己修改下start.py,把相关代码段抄过去。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants