Sign in to follow this  
Followers 0
sl_alagappan

Controlsend

22 posts in this topic

Is there any plan to udpate controlsend() to send special characters like enter key, control key, etc?

If that is not possible, atleast will there be any option to send the special characters to a specific window ( not specific control )?

Since send() only sends to current active window, an option of updated controlsend() or winsend() would be much useful.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

ControlSend already supports those keys and has done IIRC since March - even before the recent update to AutoItX.

; VBScript example
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

WScript.Echo oAutoIt.Run("notepad.exe", "")
oAutoIt.WinWaitActive("Untitled")
oAutoIt.ControlSend "Untitled -", "", "Edit1", "This is a line 1 of text{ENTER}"
oAutoIt.ControlSend "Untitled -", "", "Edit1", "This is a line 2 of text{ENTER}"

Edited by Jon

Share this post


Link to post
Share on other sites

1) With latest version of AutoitX, my application crashes when used {ENTER} to an edit box.

any idea?

2) Also, when I try to invoke a menu item via AutoitX, it invokes wrong menu. But if I invoke the correct menu item once manually, and then subsequent try to invoke the same correct menu item via AutoitX is found Ok.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

1) With latest version of AutoitX, my application crashes when used {ENTER} to an edit box.

any idea?

2) Also, when I try to invoke a menu item via AutoitX, it invokes wrong menu. But if I invoke the correct menu item once manually, and then subsequent try to invoke the same correct menu item via AutoitX is found Ok.

Do you have example code? What language?

Edit: Can you get code to work with notepad?

Edited by Jon

Share this post


Link to post
Share on other sites

Language is Visual Basic 6.0 (SP5).

in the below code, when I have strCusCode="A001{ENTER}" or "A001" & "{ENTER}", the application crashes.

Whereas, when I remove the {ENTER}, it goes fine.

I use the control names like EDIT3... to identify the controls.

'set customer code [Edit3]
    intResult = cAutoit.ControlSetText(strReceiptWindowName, strReceiptWindowText, strCusCodeControlName, "")
    intResult = cAutoit.ControlSend(strReceiptWindowName, strReceiptWindowText, strCusCodeControlName, strCusCode)
    If intResult <> 1 Then
        PostEDIData = False
        Exit Function
    End If

Share this post


Link to post
Share on other sites

hv attached the screen shots of the application and the screen shot of the window where I am passing data via AutoitX.

If Jon could remember, this is the same application I had problems earlier during the initial stages of AutoIT Version 3.0.85.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

1. Does the same code work if you try and send that text to notepad.exe? (Edit1)

2. How are you creating the autoitX object (the rest of the VB code)

3. Have you tried using it as a standard DLL rather than activex?

4. Does it work if you write the script in normal AutoIt?

5. Does this AutoIt script work:

WinWaitActive("Receipts", "Bank")
ControlSend("Receipts", "Bank", "Edit3", "A001{ENTER}")

6. Does this VBScript using AutoItX work:

' VBScript example
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
WinWaitActive "Receipts", "Bank"
ControlSend "Receipts", "Bank", "Edit3", "A001{ENTER}"

7. When you say the application crashes. which application?

8. Have you definately registered AutoItX using regsvr32.exe to make sure you are not using some old version?

9. Are you using AutoItX3.Control as the control name rather than the old v2 version of AutoItX.Control?

Basically you need to take your application out of this testing process to work out if everything else is OK. The best way is to test the same commands on other applications like notepad and write to make sure.

Anyone else using AutoItX in VB? How are you declaring things, and does it work OK as both ActiveX and DLL?

Edited by Jon

Share this post


Link to post
Share on other sites

1. Does the same code work if you try and send that text to notepad.exe? (Edit1)

Same code works fine with Notepad.

2. How are you creating the autoitX object (the rest of the VB code)

I declare as below in VB6:

Dim cAutoit As New AUTOITX3Lib.Control

(or)

Dim a As New AutoItX3

3. Have you tried using it as a standard DLL rather than activex?

No. Not yet..  Not sure on how to use it as standard DLL in VB6.

4. Does it work if you write the script in normal AutoIt?

Yet to test it..

5. Does this AutoIt script work:

WinWaitActive("Receipts", "Bank")
ControlSend("Receipts", "Bank", "Edit3", "A001{ENTER}")

No.. same error pops up.

6. Does this VBScript using AutoItX work:

' VBScript example
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
WinWaitActive "Receipts", "Bank"
ControlSend "Receipts", "Bank", "Edit3", "A001{ENTER}"

7. When you say the application crashes. which application?

my user application ( Ramco e.Application )

8. Have you definately registered AutoItX using regsvr32.exe to make sure you are not using some old version?

Yes.. Registered the AutoItX using regsvr32 and using 3.0.103 version.

9. Are you using AutoItX3.Control as the control name rather than the old v2 version of AutoItX.Control?

Yes.

Basically you need to take your application out of this testing process to work out if everything else is OK.  The best way is to test the same commands on other applications like notepad and write to make sure.

Anyone else using AutoItX in VB?  How are you declaring things, and does it work OK as both ActiveX and DLL?

<{POST_SNAPBACK}>

May be any other method of using AutoitX in VB?

Share this post


Link to post
Share on other sites

May be any other method of using AutoitX in VB?

As you have just said it fails with normal AutoIt, so it's nothing to do with AutoItX or the way you are using it - it's the application not liking the fact that an {ENTER} key is being sent directly to a control. Which is very odd because the code to send 'A' is the same as the code that sends 'ENTER' :ph34r:

Share this post


Link to post
Share on other sites

Just to rule out something try these two AutoIt scripts (you must make sure that the focus is already on your control - Edit3 - before you run these!)

Opt("SendAttachMode", 1)
WinWaitActive("Receipts", "Bank")
Send("A001{ENTER}")

and then this:

WinWaitActive("Receipts", "Bank")
Send("A001{ENTER}")

Do both work?

Share this post


Link to post
Share on other sites

Just to rule out something try these two AutoIt scripts (you must make sure that the focus is already on your control - Edit3 - before you run these!)

Opt("SendAttachMode", 1)
WinWaitActive("Receipts", "Bank")
Send("A001{ENTER}")

and then this:

WinWaitActive("Receipts", "Bank")
Send("A001{ENTER}")

Do both work?

When I replaced WinWaitActivate with WinActivate, both works fine without any problem.

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

What about the menu problem that I face ( also faced during Version 3.0.85 )..

When I choose a menu item, it selects a wrong menu item ( Help menu ) all the time ( a particular wrong menu item is selected ).

If I once choose manually the correct item, then there is no problem in selecting

the correct menu item via AutoitX.

Edited by sl_alagappan

Share this post


Link to post
Share on other sites

Hmm, so it's not the attachmode that is causing problems (ControlSend implicitly does the SendAttachMode thing above which I thought your app may not like).

:ph34r:

What about sending {LEFT} instead of {ENTER}? Does that do anything?

Share this post


Link to post
Share on other sites

Since the application converts all character inputs to Upper case, unable to identify the difference on the screen.

but when used with {LEFT}, the application didn't crash.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Also, any idea on why a wrong menu item is selected when selecting via Autoit for the first time.

As mentioned, once I manually selected the correct menu item for the first time using either keyboard shortcuts or mouse, thereafter, Autoit correctly opens the required menu item.

Any link on these two problems?

Edited by sl_alagappan

Share this post


Link to post
Share on other sites

Since the application converts all character inputs to Upper case, unable to identify the difference on the screen.

but when used with {LEFT}, the application didn't crash.

Ok, well the extact same code is used to send a {LEFT} that is used for {ENTER} which seems to discount any bugs in AutoIt. The application seems to dislike a simulated enter key and I'm out of ideas for any workarounds.

As for the menu thing I have no idea, the code looks OK and I've had no similar problems reported.

Share this post


Link to post
Share on other sites

have contacted the application vendor ( Ramco Systems, Chennai, India ). Hv referenced this forum so as to enable them to trouble-shoot.

If this problem is overcome successfully, AutoIT can be used by most of Ramco Systems Customers to automate data entry.

Share this post


Link to post
Share on other sites

Ramco systems has given an alternative solution:

When you send the {ENTER} key alone, there is no problem. The problem is when you send {ENTER} keystroke along with data only.

With one alternative, awaiting for the wrong menu selected to be resolved.

Share this post


Link to post
Share on other sites

Ramco systems has given an alternative solution:

When you send the {ENTER} key alone, there is no problem. The problem is when you send {ENTER} keystroke along with data only.

With one alternative, awaiting for the wrong menu selected to be resolved.

<{POST_SNAPBACK}>

Are you 100% positive that the class of the menu is #32768 (You may have to download some other utility to check this, I don't believe Au3_Spy will)? Does it work with regular AutoIt (I can't remembered if you answered that or not already)? Is the application available for others to try (Even in trial mode)?

Share this post


Link to post
Share on other sites

Are you 100% positive that the class of the menu is #32768 (You may have to download some other utility to check this, I don't believe Au3_Spy will)?  Does it work with regular AutoIt (I can't remembered if you answered that or not already)?  Is the application available for others to try (Even in trial mode)?

<{POST_SNAPBACK}>

The class name of the main menu is :

( classname=Afx:400000:b:10011:6:16058f )

Even with regular Autoit, I can't send data with {ENTER}. But separately.

The application is a downsized version of ERP and hence not available as trial ( it involves SQL 2000 as back-end)

Share this post


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
Sign in to follow this  
Followers 0