Jump to content

Send() is not working


Recommended Posts

Hi, I haven't used Autoit in like 3 years so I'm not sure if something has changed and I'm doing something wrong but the Send() function is not working for me. I'm trying to send 4 Tabs then 2 Enters then some text. I thought it could be the window I'm working with so I just did a simple test and the keys are not being sent.

Run("C:\WINDOWS\system32\notepad.exe")
WinWait("Untitled - Notepad",0.0)
WinActivate("Untitled - Notepad",0.0)
WinWaitActive("Untitled - Notepad",0.0)
Sleep(3)
Send("{TAB}",0)
Send("test",0)
Send("t",0)
Send("e",0)
Send("s",0)
Send("t",0)

Notepad opens fine but then it just sits there. This is the output log:

 

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "E:\AutoIt Projects\test.au3" /UserParams    
+>16:03:41 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0   Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\User\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\User\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:E:\AutoIt Projects\test.au3
+>16:03:41 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "E:\AutoIt Projects\test.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop

>Process failed to respond; forcing abrupt termination...
>Exit code: 1    Time: 11.86

I have to stop it because it doesn't do anything at all.

I already tried to use sleep thinking it was sending the keys too fast but no dice.

Thanks for your help.

Link to comment
Share on other sites

Just now, Earthshine said:

Notepad on windows 10 isn’t easy to automate as it once was. What operating system are you using

Windows 10. But notepad is not really the problem, I just used it as test. any program any window the keys are not being send. it gets stuck at 

+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
Link to comment
Share on other sites

2 minutes ago, Earthshine said:

I don’t see anywhere in the code where you’re setting hotkeys.

Exactly, I'm not setting hotkeys, should I? last time I wrote a script that involved sending keys I didn't have to set any hotkey. I even opened one of my old scripts ran it and same thing happened. 

Link to comment
Share on other sites

Use [CLASS] instead of title.  With different languages and OS versions, it is more of a robust approach.  And get handle at the first call to Win* () so you can use it afterward.  Also, can you give us the REAL application you are trying to interact to ?

Edited by Nine
Link to comment
Share on other sites

6 minutes ago, Nine said:

Use [CLASS] instead of title.  With different languages and OS versions, it is more of a robust approach.  And get handle at the first call to Win* () so you can use it afterward.  Also, can you give us the REAL application you are trying to interact to ?

The application is called FlirCloud and it is a CCTV application. I just tried using the class but didn't work either.

Link to comment
Share on other sites

8 minutes ago, Nine said:

Show us the code you have so far, along with the control info you want to interact to...

Run("flircloud.exe")
Local $flir = WinWait("[CLASS:Qwidget]", "",0)
WinActivate($flir, "",0)
WinWaitActive($flir, "", 0)
sleep(5000)
Send("{TAB 4}")
Send("{ENTER}")

Title: Flir Cloud Client

Class: QWidget

Instance: 287

ClassnameNN: QWidget287

Name, ID and Text are empty.

 

But again I don't think the applications are the problem, I even ran one that I used to use before and it is not happening.

If ProcessExists("POS22.exe") Then
    ProcessClose("POS22.exe")
EndIf
ProcessWaitClose("POS22.exe")
Run("C:\POS\POS22.exe")
ProcessWait("POS22.exe")
WinWait("","0.00")
WinActivate("","0.00")
WinWaitActive("","0.00")
Send("{ALT}")
Send("{RIGHT 2}")
Send("{DOWN}")
Send("{ENTER}")
WinWait("","Customer info")
WinActivate("","Customer info")
WinWaitActive("","Customer info")
Sleep(2)
Send("{TAB 2}")
Send("+{END}")
Send("{DEL}")
Send("P:\\PM229.mdb")
#cs
Send("C:\Program Files\DiGital WorkShop\POS Panic\PM229.mdb")
#CE
MouseMove(1162,742)
MouseClick("right")
Send("{ENTER}")

I know that one worked when I used it about 3 years ago. Not working today.

Link to comment
Share on other sites

13 hours ago, Nine said:

WinActivate doesn't have a 3rd parameter. So it is impossible that you could run that script. What are you up to ?

oh yeah you're right I didn't see that. but believe me it worked at that time lol.

Maybe the older version of Autoit was more permissible of mistakes like this? I don't know.

Anyway I removed the 3rd parameter and that was it, it is sending the keys now. thanks.

 

Link to comment
Share on other sites

13 hours ago, Werty said:

Qwidgets are a pain to automate, read this thread about qwidgets, not a solution as the zip in the example is missing, but will give you an idea of what you are up against...

 

Thanks I'll read it, Hopefully since the automation I want to do is quite simple it doesn't give me such hard time.

Link to comment
Share on other sites

  • 4 years later...

I'm having a similar issue.  The setup I'm running works fine. The /S opperator is for silent install however the installer leaves a window open that requires a user input to close. I'm trying to deploy this script in my MDT os deployments but can't for the life of me get a simple TAB then ENTER to close the window so my scripted deployment can continue.

Can anyone see a reason the following code would not work?

I know the #include's are'n't needed here, they're from various things I was trying/testing.   On that topic, I was using an If/Then section with message boxes to tell me if the window with [CLASS:#32770] exists. Oddly I got my popup window telling me that it does exist, but it appears several seconds before the software installer even appears.

I've tried ControlCommand, MouseMove and MouseClick and nothing I do will have any interaction with this window.   The script finishes without any errors or drama but it never seems to be executing anything below the WinWaitActive line.

#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>

CPSI_installer()

Func CPSI_installer()
    ShellExecute("\\<servername>\e$\Software\CPSI\cpsetup.exe","-host=0.0.0.0 /S","")
    Sleep(12000)
    WinWaitActive("[CLASS:#32770]", "")
       Sleep(3000)
       Send("{TAB}")
       Sleep(200)
       Send("{ENTER}")

EndFunc
Link to comment
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
 Share

×
×
  • Create New...