从 VBA 立即窗口移动到代码窗口的快捷键

发布于 2024-12-28 19:59:58 字数 76 浏览 3 评论 0原文

我知道我可以使用 Ctrl + G 将光标移动到立即窗口。是否有其他快捷键可以将光标移回代码?

I know I can use Ctrl + G to move the cursor to the immediate window. Is there a different shortcut key to move the cursor back to the code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

最笨的告白 2025-01-04 19:59:58

假设在Office中使用VBA; F7

Assuming VBA in Office; F7.

ゞ花落谁相伴 2025-01-04 19:59:58

Alt+W1

Alt+W, 1

江挽川 2025-01-04 19:59:58

对于使用 AutoHotKey 的任何人,我将 Alex K 的解决方案合并到每次登录时运行的 Autohotkey 脚本中:

SendMode Input  ; Recommended for new scripts due to its superior speed and reliability

;***  ;VBA IDE
#IfWinActive ahk_class wndclass_desked_gsk ;only execute if VBA IDE is active win
^g::   ; Ctl + g: Toggle immediate window
    WinGet, WindowUniqueID, ID, A
    ControlGetFocus, ControlID, ahk_id %WindowUniqueID%
    ControlGet, ControlHwnd, Hwnd,, %ControlID%, ahk_id %WindowUniqueID%
    ControlTextSize = 16
    VarSetCapacity(ControlText, ControlTextSize)
    SendMessage, 0xD, ControlTextSize, &ControlText,, ahk_id %ControlHWND%  ; 0xD is WM_GETTEXT.
    If (ControlText="Immediate")
        Send {F7}
    Else
        Send ^g
    Return
#IfWinActive

首先,该脚本创建一个上下文相关的 Ctl + G 热键要求 VBA IDE 成为活动窗口 (#IfWinActive ahk_class wndclass_desked_gsk)。

当您按 Ctl + G 时,脚本会检查当前控件的标题是否为“Immediate”。如果是,那么它会发送一个 F7 将焦点发送回代码。否则它会重新发出 Ctl + G

For anyone out there using AutoHotKey, I incorporated Alex K's solution into the Autohotkey script I run whenever I log on:

SendMode Input  ; Recommended for new scripts due to its superior speed and reliability

;***  ;VBA IDE
#IfWinActive ahk_class wndclass_desked_gsk ;only execute if VBA IDE is active win
^g::   ; Ctl + g: Toggle immediate window
    WinGet, WindowUniqueID, ID, A
    ControlGetFocus, ControlID, ahk_id %WindowUniqueID%
    ControlGet, ControlHwnd, Hwnd,, %ControlID%, ahk_id %WindowUniqueID%
    ControlTextSize = 16
    VarSetCapacity(ControlText, ControlTextSize)
    SendMessage, 0xD, ControlTextSize, &ControlText,, ahk_id %ControlHWND%  ; 0xD is WM_GETTEXT.
    If (ControlText="Immediate")
        Send {F7}
    Else
        Send ^g
    Return
#IfWinActive

First, the script creates a context-sensitive Ctl + G hotkey that requires the VBA IDE to be the active window (#IfWinActive ahk_class wndclass_desked_gsk).

When you press Ctl + G, the script checks to see if the title of the current control is "Immediate". If it is, then it sends an F7 which sends the focus back to the code. Otherwise it reissues the Ctl + G.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文