Jump to content

Send not working for us anymore


Recommended Posts

We use OtsAV to run our community radio station and we have used AutoIt scripts to automate some things in OtsAV for many years. We just updated our OS to Windows 10 after our system crashed and now AutoIt scripts that have worked for years no longer work.  Specifically they don't Send the characters to OtsAV that we're trying to send.  Here's a sample of a script that used to work but now doesn't:

#include <MsgBoxConstants.au3>
WinWait("OtsAV", "")
If Not WinActive("OtsAV", "") Then WinActivate("OtsAV", "")
WinWaitActive("OtsAV", "")
; send the shortcut keys to get to the Import/Refresh Album Files dialog box
Send("!f")
Sleep(500)
Send("f")
Sleep(500)
Send("i")
Sleep(500)
Send("{ENTER}")
; get the Import/Refresh Album Files dialog box active
WinWait("Import/Refresh Album Files", "")
MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10)

I threw in the MsgBox call to try and figure out what was going on. If I run this script it activates the OtsAV window but doesn't seem to send the characters and the script hangs at the WinWait call. I can tell this because if after running the script I manually type in the characters that were supposed to be sent, the message box pops up. I'm not an AutoIt expert and I only hacked these scripts together years ago because it was the only way to update certain things in OtsAV.  Any help/suggestions would be appreciated. You can stream our station at kpup.rocks if you want a good mix of eclectic music!

Link to post
Share on other sites

@MarkNich

Send() is not a reliable function like ControlSend(), for example.

You have to make sure that all the previous functions are working correctly, so, put some error checking and debug your script.

Use the code tags <> in the bar above when you post the code, and let us know how it goes with your debugging :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to post
Share on other sites
13 hours ago, MarkNich said:

Specifically they don't Send the characters to OtsAV that we're trying to send.

One of the most common causes of the Send() function not sending keys after switching to Windows 10 is because of Windows 10's enhanced security features. 

A non-elevated process cannot send keys to an elevated process.  To see if that's the issue you're having, you can try one of the following:

  1. Add the #RequireAdmin directive to the top of your script.
    or
  2. If the script is compiled, right-click it and select the "Run As Admin" option

 

On a side note when using WinWait or WinWaitActive, if you set a timeout, then you can gracefully exit/return if the windows does not appear or become active instead of your script waiting forever.  For example:

;Wait up to 3 seconds for the window to appear
If Not WinWait("Some title", "", 3) Then
    MsgBox($MB_ICONWARNING + $MB_TOPMOST, "WARNING", "Timed out waiting for some title.")
    Exit 1
EndIf

 

Edited by TheXman
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...