C
C#3y ago
Foxtrek_64

SendKeys() Access Denied

I'm using UiPath's SendKeys activity which maps to the SendKeys() function. For some reason, I am experiencing an intermittent access denied error when trying to send F8 to an application. Pressing F8 manually when this error is experienced does not open the F8 window. Restarting the application fixes the error. When researching this error, the only suggestions online are to disable UAC or run as administrator, neither of which are options due to company policy. Are there any other suggestions?
5 Replies
Foxtrek_64
Foxtrek_64OP3y ago
Correction: this is calling System.Windows.Forms.SendKeys.SendWait("{F8}")
Henkypenky
Henkypenky3y ago
did some research for you, seems that it is susceptible to timing issues are u using the new or old implementation? https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys?view=windowsdesktop-6.0 If your application relies on consistent behavior regardless of the operating system, you can force the SendKeys class to use the new implementation by adding the following application setting to your app.config file. The SendKeys class has been updated for the .NET Framework 3.0 to enable its use in applications that run on Windows Vista. The enhanced security of Windows Vista (known as User Account Control or UAC) prevents the previous implementation from working as expected. <appSettings> <add key="SendKeys" value="SendInput"/> </appSettings>
jcotton42
jcotton423y ago
@Foxtrek_64 is the app running as admin? The app you're trying to SendKeys that is
jcotton42
jcotton423y ago
Foxtrek_64
Foxtrek_64OP3y ago
I was reading that too and honestly I don't know. UiPath doesn't have this document to be able to configure that so I'm at their mercy. That said, this isn't timing sensitive. Neither application is running as administrator. This is a non-administrative service account that logs in with an interactive session, opens a terribly-written WinForms application, and then sends the F8 keystroke to open a window to perform financial functions. Oh, to make this more interesting, it will work probably 90% of the time But then 10% of the time we'll get this access denied error which will cause the finance app we're using to restart, then it's fine again. I have been able to reduce it a bit by having it click on the finance app before it sends the F8 keystroke to make sure it hasn't lost focus for any reason, but it doesn't get rid of the issue entirely.
Want results from more Discord servers?
Add your server