kbd_event 在某些 GDI 上无法正确工作
我正在尝试将密钥发送到 IE 地址栏。我在 IE 上打开网页,但是当我向该网页发送密钥时,它会删除地址栏以前的内容。 如何将字符串发送到 IE 地址栏或搜索框?
I am trying to send key to IE address bar. I open web page on IE but when I send key to that it removes previous content of address bar.
How to send string to IE address bar or search box ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,当您向地址栏发送密钥时,它会删除那里已经显示的内容。如果您按下物理键盘上的某个键,也会发生同样的情况。原因是地址栏中的文本被选中(或突出显示),这意味着当您键入哪怕只是一个键时,所有内容都会被删除。它的目的是为了方便,但显然在这里妨碍了你。
在发送按键之前,您需要先取消选择地址栏中的文本。
另请注意,
kbd_event
函数已被您可能需要的SendInput
取代来代替使用。Yeah, when you send a key to the address bar, it's going to remove what's already displayed there. The same thing happens if you press a key on the physical keyboard. The reason is that the text in the address bar is selected (or highlighted), meaning that everything gets erased when you type even so much as a single key. It's intended for convenience, but obviously getting in your way here.
You need to deselect the text in the address bar first before sending the key press.
Also note that the
kbd_event
function has been superseded bySendInput
, which you might want to use instead.如果您需要取消选择文本并将某些内容附加到其末尾,请尝试在 kbd_event/SendInput 的帮助下先发送 End 键。
If you need to deselect a text and append something to the end of it, try sending the End key press first, with the help of kbd_event/SendInput.