Visual Basic 中的 SendKeys() 权限被拒绝错误 [英] SendKeys() permission denied error in Visual Basic
问题描述
我正在尝试使用 SendKeys()
命令到另一个窗口和我的 VB6 应用程序.
I am trying to use the SendKeys()
command to another window with my VB6 app.
我想要的是单击一个按钮,然后在应用程序向该窗口发送一些键之前有 10 秒钟的时间转到另一个窗口.我把所有东西都整理好了,但出于某种原因,当我打电话给这样的东西时:
What I wanted is to click a button, and then have 10 seconds to go to the other window before the app sends some keys to that window. I got everything sorted but for some reason when I call something like this:
SendKeys ("A")
我收到此错误:
Run-time error '70':
Permission denied
有没有人知道解决这个问题的方法?谢谢.
Does anyone know a way around this? Thanks.
推荐答案
对于 Windows 7:将 UAC 设置更改为从不通知.
For Windows 7: Change the UAC settings to never notify.
对于 Windows 8 和 10:
将此方法添加到任何模块:
For Windows 8 and 10:
Add this method to any module:
Public Sub Sendkeys(text as variant, Optional wait As Boolean = False)
Dim WshShell As Object
Set WshShell = CreateObject("wscript.shell")
WshShell.Sendkeys cstr(text), wait
Set WshShell = Nothing
End Sub
它在 Windows 10 中运行良好.
It's worked fine for me in windows 10.
这篇关于Visual Basic 中的 SendKeys() 权限被拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!