Jump to content
newbieauuser

My code does not send underscores

Recommended Posts

Hi all!

Im newbie and get some problem with my code.

I need to send text to the program. Tried to send using "send" and "controlsend", but they do not work in it. It was possible to send only with "DllCall", but it was not without problems. The problem is that the text is sent incorrectly.

Here is my test code:

#include <Array.au3>

$StringToSplit = "AZ _TEX UNV-T"

$Split = StringSplit($StringToSplit, "", 2)

Run("notepad.exe")

Sleep(1000)

Global Const $KEYEVENTF_EXTENDEDKEY = 0x0001
Global Const $KEYEVENTF_KEYUP = 0x0002

For $i = 0 To UBound($Split) -1
    Sleep(100)
    DllCall('user32.dll', 'Int', 'keybd_event', 'byte', StringToBinary(StringUpper($Split[$i])), 'dword', '0x45' , 'dword', 0x0, 'int', 0)
    Sleep(100)
    DllCall('user32.dll', 'Int', 'keybd_event', 'byte', StringToBinary(StringUpper($Split[$i])), 'dword', '0x45' , 'dword', $KEYEVENTF_KEYUP, 'int', 0)
Next

 

What i want to get:

AZ _TEX UNV-T

What i get:

az tex unvt

 

Share this post


Link to post
Share on other sites

Why "Send" did not Work for you?

This does what you want:

#include <Array.au3>

Local $StringToSplit = "AZ _TEX UNV-T"
Local $Split = StringSplit($StringToSplit, "", 2)

Run("notepad.exe")

Sleep(1000)

For $i = 0 To UBound($Split) -1
    Send($Split[$i])
Next

 

Starts notepad and writes "AZ _TEX UNV-T"

Or do I miss something?


Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Share this post


Link to post
Share on other sites
27 minutes ago, Nine said:

It is normal that you get that because you are sending Vitual-Key Codes not characters.  Look at this list you will understand what is your problem...

Thank! Can you please advise an alternative to "DllCall"?

The program for which I am writing code is not a notebook. In a notebook, I'm just testing.

Share this post


Link to post
Share on other sites
3 minutes ago, newbieauuser said:

Can you please advise an alternative to "DllCall"?

Depends on the program you want to send text to, on what kind of controls there is, etc...Sorry but crystal ball is at repair shop.

Share this post


Link to post
Share on other sites
51 minutes ago, Nine said:

Depends on the program you want to send text to, on what kind of controls there is, etc...Sorry but crystal ball is at repair shop.

The program for the office, specific and private. "send" and "controlsend" work in it incorrectly. The only thing that worked in it is "DllCall", but also such a problem ...
I will try now to explain the problem associated with the "send" and "controlsend". When I try to send text with them, it just turns on and off "CapsLock". In the code there is no manipulation with "CapsLock", the text is simply not sent. I tried the trick with "space", it did not help either.

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

×
×
  • Create New...