Sign in to follow this  
Followers 0
qwert

What could possibly cause this?

11 posts in this topic

I've been experimenting with the AutoIt capability to send text from one scripted GUI to another. But I've encountered a situation that makes no sense. When sending "shifted" characters (i.e., uppercase or special characters like #, @, *, etc.) the unshifted versions of the characters are sometimes received (example is of sending asterisks). Here are the Send and Receive scripts.

; this is the send task
#include <GuiConstants.au3>
HotKeySet("{ESC}", "QuitApp")
$Main_Gui = GUICreate("Sender", 400, 400, 600, 200)
$But1 = GUICtrlCreateButton(" Send ", 100, 100, 80, 21)
$But2 = GUICtrlCreateButton(" Exit ", 100, 200, 80, 21)
GUISetState(@SW_SHOW,$Main_Gui)
While 1
  $Msg = GUIGetMsg()
if $Msg = $But1 Then SendChars()
if $Msg = $But2 Then QuitApp()
Sleep(200)
WEnd
Func SendChars()
    ControlSend("Display", "", "Edit1", "****" & @CRLF)
EndFunc
Func QuitApp()
    Exit
EndFunc

; this is the receive task
#include <GuiConstants.au3>
HotKeySet("{ESC}", "QuitApp")
$BG = GUICreate("Window",400,400,0,0)
$Main_Gui = GUICreate("Display", 400, 400, 100, 200)
$But1 = GUICtrlCreateButton(" Exit ", 100, 100, 80, 21)
$Info_Edit = GUICtrlCreateEdit("", 80, 150, 300, 220, $ES_RIGHT + $WS_VSCROLL)
GUICtrlSetFont($Info_Edit, 20, 600)
GUISetState(@SW_SHOW,$Main_Gui)
While 1
  $Msg = GUIGetMsg()
if $Msg = $But1 Then Exitloop
Sleep(200)
WEnd
Func QuitApp()
    Exit
EndFunc

I hope someone can explain this because I'm completely baffled. I'm running the latest AutoIt3 release on XP Service Pack 2.

Help is much needed -- and will be appreciated. Thanks in advance.

post-29172-1205409680_thumb.png

Share this post


Link to post
Share on other sites



Use the "Raw Flag" on ControlSend() or the special characters will be interpreted as meta-keys (i.e. !=Alt, +=Shift, ^=Ctrl, #=WinKey). Check out the last parameter in the help file under ControlSend().

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks for the response.

I tried this:

ControlSend("Display", "", "Edit1", "****" & @CRLF, 1)
and got the same result.

Have I misunderstood what you are saying?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for the response.

I tried this:

ControlSend("Display", "", "Edit1", "****" & @CRLF, 1)
and got the same result.

Have I misunderstood what you are saying?

No, you got the flag I was talking about.

The "*" is not one of the meta-key flags, so it shouldn't have mattered for that. I was responding to this:

When sending "shifted" characters (i.e., uppercase or special characters like #, @, *, etc.) the unshifted versions of the characters are sometimes received...

Exactly what are you getting instead of "****"? (Deleted for stupidly not checking the screen shot.)

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Exactly what are you getting instead of "****"?

:)

@PsaltyDS - the screen capture in the first post shows you.

@qwert I tried your code and did not get your problem. I even tried pressing the shift key while the characters were being sent.

I don't know if it will help,but see what happens if you increase the key delay using AutitSetOption("SendKeyDelay",...

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Exactly what are you getting instead of "****"?

Take a look at the PNG at the end of my original post.

Share this post


Link to post
Share on other sites

It looks like a shift state bug.

This shows it also

; this is the send task

HotKeySet("{ESC}", "QuitApp")
$Main_Gui = GUICreate("Sender", 400, 400, 600, 200)
$But1 = GUICtrlCreateButton(" Send ", 100, 100, 80, 21)
$But2 = GUICtrlCreateButton(" Exit ", 100, 200, 80, 21)
GUISetState(@SW_SHOW,$Main_Gui)

While 1
    $Msg = GUIGetMsg()
    if $Msg = $But1 Then
        SendChars()
    ElseIf $Msg = $But2 Then
        QuitApp()
    EndIf
WEnd

Func SendChars()
    ControlSend("Display", "", "Edit1", "%%%%" & @CRLF)
EndFunc

Func QuitApp()
    Exit
EndFuncoÝ÷ Ù«­¢+ØìÑ¡¥Ì¥ÌÑ¡É¥ÙÑͬ()±½°
½¹ÍÐÀÌØíM}I%!PôÈ)±½°
½¹ÍÐÀÌØí]M}YM
I=10ôÁàÀÀÈÀÀÀÀÀ()!½Ñ-åMÐ ÅÕ½ÐííM
ôÅÕ½Ðì°ÅÕ½ÐíEÕ¥ÑÁÀÅÕ½Ðì¤(ÀÌØí    ôU%
ÉÑ ÅÕ½Ðí]¥¹½ÜÅÕ½Ðì°ÐÀÀ°ÐÀÀ°À°À¤(ÀÌØí5¥¹}Õ¤ôU%
ÉÑ ÅÕ½Ðí¥ÍÁ±äÅÕ½Ðì°ÐÀÀ°ÐÀÀ°ÄÀÀ°ÈÀÀ¤(ÀÌØí  ÕÐÄôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðìá¥ÐÅÕ½Ðì°ÄÀÀ°ÄÀÀ°àÀ°ÈĤ(ÀÌØí%¹½}¥ÐôU%
Ñɱ
ÉѥРÅÕ½ÐìÅÕ½Ðì°àÀ°ÄÔÀ°ÌÀÀ°ÈÈÀ°   ¥Ñ=H ÀÌØíM}I%!P°ÀÌØí]M}YM
I=10¤¤)U%
ÑɱMѽ¹Ð ÀÌØí%¹½}¥Ð°ÈÀ°ØÀÀ¤)U%MÑMÑÑ¡M]}M!=°ÀÌØí5¥¹}Õ¤¤()]¡¥±Ä($ÀÌØí5ÍôU%Ñ5Í ¤(%¥ÀÌØí5ÍôÀÌØí    ÕÐÄQ¡¸á¥Ñ±½½À)]¹()Õ¹EÕ¥ÑÁÀ ¤(á¥Ð)¹Õ¹

%%%5

%%%5

%%%5

5%%5

%%%5

%%%5

Shift+5 = %

So sometimes it shifts the key and sometimes it does not.

Share this post


Link to post
Share on other sites

see what happens if you increase the key delay using AutitSetOption("SendKeyDelay",...

Thanks, martin -- you are on to something there.

I first increased the delay to 50ms and got NO errors. So I started decreasing it and got all the way to 10ms with no errors. However, at 5ms (the default) errors started. Strangely, though, the error rate didn't seem to increase when I put it to 1ms -- and I certainly expected it to.

Is this anything someone should look at since it's only dropping the "shift" state? If it was dropping characters entirely, I would agree it's timing only. But this is different.

post-29172-1205426659_thumb.png

Share this post


Link to post
Share on other sites

If I use 20 for SendKeyDelay then output is good. If I use 15 then output is bad and even carriage returns are missed. Output improves using 10 rather then 15 but is still bad but at least carriage returns seem to work more often. I seem to get better performance leaving SendKeyDelay at default and setting SendKeyDownDelay at 10.

Share this post


Link to post
Share on other sites

I'm having this issue too - has a fix ever been found?

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