VK6 SendKeys () rejection error

I am trying to use the SendKeys() command in another window with my VB6 application.

I want to press a button and then go to another window 10 seconds before the application sends some keys to this window. Everything is sorted out for me, but for some reason I call something like this:

 SendKeys ("A") 

I get this error:

 Run-time error '70': Permission denied 

Does anyone know about this? Thanks.

+7
vb6 sendkeys
source share
10 answers

Take a look at the fact that Karl Peterson worked as a fix for this in Vista:

Sendinput

+8
source share

The replacement for VB6 SendKeys is WScript.Shell SendKeys, for example:

 Set WshShell = CreateObject("WScript.Shell") WshShell.SendKeys "1{+}" 

Contact MSDN for help.

+3
source share

In Windows 7:

  • Open control panel
  • Change account management settings
  • Change to NEVER NOTIFY
  • Reboot the computer.
+2
source share

Delete msvbvm60.dll file from application

Follow the next step.

  • Right-click on the application .exe file and click "Property"
  • Click the Compatibility tab
  • Click "Run this program in compatibility mode and select Windows" Xp SP2 from it.
  • Click "Run this program as administrator"
  • Click Apply, then OK.
  • Remove "msvbvm60.dll" from the application folder.

Everything is ready, now your application starts without any error, like a denial of access

+2
source share

In the public add module:

 Public Sub Sendkeys(text$, Optional wait As Boolean = False) Dim WshShell As Object Set WshShell = CreateObject("wscript.shell") WshShell.Sendkeys text, wait Set WshShell = Nothing End Sub 

This will overwrite the SendKeys function.

+2
source share

For Windows 7: Change the UAC settings to never notify.

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 

It worked great for me on Windows 10.

+2
source share

You can use this code in the module.

 Public Sub SendKeyTab(CForm As Form) On Error Resume Next Dim G As Single For G = 0 To CForm .Controls.Count - 1 If CForm .Controls(G).TabIndex = CForm .ActiveControl.TabIndex + 1 Then CForm .Controls(G).SetFocus Next End Sub 

At every level of form

 If KeyCode 
+1
source share

the problem is with the vb6 IDE context menu and Windows Desktop, and you will do as described here:

http://www.vbforums.com/showthread.php?747425-SendKeys-and-Windows-8

and the main link is here:

http://www.vbforums.com/showthread.php?745925-RESOLVED-How-to-trigger-the-desktop-context-menu

0
source share

Use this API:

 Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) 

and

 keybd_event keycode, 0, 0, 0 'KEY DOWN keybd_event keycode, 0, KEYEVENTF_KEYUP, 0 'KEY UP 

when key code is 32 for space, 35 for keyend, 8 for vbKeyBack, etc.

0
source share

sendkeys statement: sendkeys "{KeyName}"

check this out: https://msdn.microsoft.com/en-us/library/aa266279(v=vs.60).aspx

-one
source share

All Articles