Autohotkey 编辑控件的自动热键ControlFocus失败

Autohotkey 编辑控件的自动热键ControlFocus失败,autohotkey,Autohotkey,我有一个由AutoHotkey创建的窗口,上面有一个按钮和一个编辑控件。 我试图做的是在单击按钮后将输入焦点带回编辑控件。通过WinSpy(非常感谢Robert Kuster),我获得了关于编辑控件的以下信息 Handle : 0x00330786 (changes every time I start the application) Control ID : 4 Class : Edit Window Title : some window title Parent Window Class

我有一个由AutoHotkey创建的窗口,上面有一个按钮和一个编辑控件。 我试图做的是在单击按钮后将输入焦点带回编辑控件。通过WinSpy(非常感谢Robert Kuster),我获得了关于编辑控件的以下信息

Handle : 0x00330786 (changes every time I start the application)
Control ID : 4
Class : Edit
Window Title : some window title
Parent Window Class : AutoHotkeyGUI
下面是我在脚本中使用的语句

ControlFocus, MyEdit, some window title

顺便说一句,AutoHotkey帮助建议保留控件名称,并用目标控件的HWND替换窗口标题作为替代。请指导如何完成此操作。

下面是一段使用

GuiControl, Focus, ControlName
为了在点击“显示我的进度”按钮后将输入焦点更改为编辑控件(即完成)

%WinTitle% = some window title
Gui, Add, Text, vLabel cWhite, Reading Completion
Gui, Add, Edit, vCompletion ym w40  ; The ym option starts a new column of controls.
Gui, Add, Progress, vMyProgress w300 h30 xp+50  yp-5
Gui, Add, Button, xp yp+50, Show My Progress
GuiControl,, Completion, %iniCompletion%
Gui, Show, h140, %WinTitle%
ControlClick, Show My Progress, %WinTitle%
**GuiControl, Focus, Completion**
return

ButtonShowMyProgress:
Gui, Submit, NoHide  ; Save the input from the user to each control's associated variable.
MyCompletionPercentage:=(Completion / (PageEnd-PageStart+1)) * 100
PercentageRounded:=Round(MyCompletionPercentage,0)
GuiControl,, MyProgress, %PercentageRounded%
**GuiControl, Focus, Completion**
return
非常感谢MCL和BGM的评论


如果我理解正确,您有自己的GUI,它是用AHK构建的。为什么? 你不使用GuiControl吗,焦点MCL

MCL有道理。GuiControl是autohotkey处理自己控件的方式。只有在使用的控件时,才能使用ControlFocus 外部窗口。MCL-也许你应该把它作为一个答案呈现出来BGM


下面是一段使用

GuiControl, Focus, ControlName
为了在点击“显示我的进度”按钮后将输入焦点更改为编辑控件(即完成)

%WinTitle% = some window title
Gui, Add, Text, vLabel cWhite, Reading Completion
Gui, Add, Edit, vCompletion ym w40  ; The ym option starts a new column of controls.
Gui, Add, Progress, vMyProgress w300 h30 xp+50  yp-5
Gui, Add, Button, xp yp+50, Show My Progress
GuiControl,, Completion, %iniCompletion%
Gui, Show, h140, %WinTitle%
ControlClick, Show My Progress, %WinTitle%
**GuiControl, Focus, Completion**
return

ButtonShowMyProgress:
Gui, Submit, NoHide  ; Save the input from the user to each control's associated variable.
MyCompletionPercentage:=(Completion / (PageEnd-PageStart+1)) * 100
PercentageRounded:=Round(MyCompletionPercentage,0)
GuiControl,, MyProgress, %PercentageRounded%
**GuiControl, Focus, Completion**
return
非常感谢MCL和BGM的评论


如果我理解正确,您有自己的GUI,它是用AHK构建的。为什么? 你不使用GuiControl吗,焦点MCL

MCL有道理。GuiControl是autohotkey处理自己控件的方式。只有在使用的控件时,才能使用ControlFocus 外部窗口。MCL-也许你应该把它作为一个答案呈现出来BGM


下面是一段使用

GuiControl, Focus, ControlName
为了在点击“显示我的进度”按钮后将输入焦点更改为编辑控件(即完成)

%WinTitle% = some window title
Gui, Add, Text, vLabel cWhite, Reading Completion
Gui, Add, Edit, vCompletion ym w40  ; The ym option starts a new column of controls.
Gui, Add, Progress, vMyProgress w300 h30 xp+50  yp-5
Gui, Add, Button, xp yp+50, Show My Progress
GuiControl,, Completion, %iniCompletion%
Gui, Show, h140, %WinTitle%
ControlClick, Show My Progress, %WinTitle%
**GuiControl, Focus, Completion**
return

ButtonShowMyProgress:
Gui, Submit, NoHide  ; Save the input from the user to each control's associated variable.
MyCompletionPercentage:=(Completion / (PageEnd-PageStart+1)) * 100
PercentageRounded:=Round(MyCompletionPercentage,0)
GuiControl,, MyProgress, %PercentageRounded%
**GuiControl, Focus, Completion**
return
非常感谢MCL和BGM的评论


如果我理解正确,您有自己的GUI,它是用AHK构建的。为什么? 你不使用GuiControl吗,焦点MCL

MCL有道理。GuiControl是autohotkey处理自己控件的方式。只有在使用的控件时,才能使用ControlFocus 外部窗口。MCL-也许你应该把它作为一个答案呈现出来BGM


下面是一段使用

GuiControl, Focus, ControlName
为了在点击“显示我的进度”按钮后将输入焦点更改为编辑控件(即完成)

%WinTitle% = some window title
Gui, Add, Text, vLabel cWhite, Reading Completion
Gui, Add, Edit, vCompletion ym w40  ; The ym option starts a new column of controls.
Gui, Add, Progress, vMyProgress w300 h30 xp+50  yp-5
Gui, Add, Button, xp yp+50, Show My Progress
GuiControl,, Completion, %iniCompletion%
Gui, Show, h140, %WinTitle%
ControlClick, Show My Progress, %WinTitle%
**GuiControl, Focus, Completion**
return

ButtonShowMyProgress:
Gui, Submit, NoHide  ; Save the input from the user to each control's associated variable.
MyCompletionPercentage:=(Completion / (PageEnd-PageStart+1)) * 100
PercentageRounded:=Round(MyCompletionPercentage,0)
GuiControl,, MyProgress, %PercentageRounded%
**GuiControl, Focus, Completion**
return
非常感谢MCL和BGM的评论


如果我理解正确,您有自己的GUI,它是用AHK构建的。为什么? 你不使用GuiControl吗,焦点MCL

MCL有道理。GuiControl是autohotkey处理自己控件的方式。只有在使用的控件时,才能使用ControlFocus 外部窗口。MCL-也许你应该把它作为一个答案呈现出来BGM


如果我理解正确,您有自己的GUI,它是用AHK构建的。为什么不使用
GuiControl,Focus
?MCL是有道理的。
GuiControl
是autohotkey使用自己控件的方式。只有在使用外部窗口的控件时,才能使用
ControlFocus
。MCL-也许你应该把它作为一个回答。谢谢你的观点。顺便说一句,这个论坛(stackoverflow)是否像微软论坛一样,用户提问时应该选择一个最佳答案?如果是这样的话,这个函数在哪里?是的,差不多是这样…:P但stackoverflow更好;)看来我们都很有礼貌;)MCL和BGM有最好的答案。不幸的是,我的名声还不足以让你投票。如果我理解正确的话,你有自己用AHK构建的GUI。为什么不使用
GuiControl,Focus
?MCL是有道理的。
GuiControl
是autohotkey使用自己控件的方式。只有在使用外部窗口的控件时,才能使用
ControlFocus
。MCL-也许你应该把它作为一个回答。谢谢你的观点。顺便说一句,这个论坛(stackoverflow)是否像微软论坛一样,用户提问时应该选择一个最佳答案?如果是这样的话,这个函数在哪里?是的,差不多是这样…:P但stackoverflow更好;)看来我们都很有礼貌;)MCL和BGM有最好的答案。不幸的是,我的名声还不足以让你投票。如果我理解正确的话,你有自己用AHK构建的GUI。为什么不使用
GuiControl,Focus
?MCL是有道理的。
GuiControl
是autohotkey使用自己控件的方式。只有在使用外部窗口的控件时,才能使用
ControlFocus
。MCL-也许你应该把它作为一个回答。谢谢你的观点。顺便说一句,这个论坛(stackoverflow)是否像微软论坛一样,用户提问时应该选择一个最佳答案?如果是这样的话,这个函数在哪里?是的,差不多是这样…:P但stackoverflow更好;)看来我们都很有礼貌;)MCL和BGM有最好的答案。不幸的是,我的名声还不足以让你投票。如果我理解正确的话,你有自己用AHK构建的GUI。为什么不使用
GuiControl,Focus
?MCL是有道理的。
GuiControl
是autohotkey使用自己控件的方式。只有在使用外部窗口的控件时,才能使用
ControlFocus
。MCL-也许你应该把它作为一个回答。谢谢你的观点。顺便说一句,这个论坛(stackoverflow)是否像微软论坛一样,用户提问时应该选择一个最佳答案?如果是这样的话,这个函数在哪里?是的,差不多是这样…:P但stackoverflow更好;)看来我们都很有礼貌;)MCL和BGM有最好的答案。不幸的是,我的名声还不足以投票支持你。