Jump to content

bug in send key repetition


Recommended Posts

Examples of key repetition:

send("{A 1}") sends the key "A" 1 times

send("{A 2}") sends the key "A" 2 times

send("{A 3}") sends the key "A" 3 times

Similarly:

$quantity = 1

send("{A " & $quantity & "}") sends the key "A" 1 times

$quantity = 2

send("{A " & $quantity & "}") sends the key "A" 2 times

$quantity = 3

send("{A " & $quantity & "}") sends the key "A" 3 times

Now, how many "A" would you expect by the following?

send("{A 0}")

or:

$quantity = 0

send("{A " & $quantity & "}")

I expected it to send the key "A" 0 times. Instead, it sends it 1 time!!

Link to comment
Share on other sites

  • Replies 42
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You expected?

Help file is clear: "The key will be send at least once even if the count is zero."

Ah, ok, I didn't notice it because that sentence was below and spaced...

Anyway, I had a bug in a script because of this.

Wouldn't it be more developer's friendly to consider 0 as 0?

Do you prefer the 0 to act as 1? :huh2:

Link to comment
Share on other sites

Instead of

send("{A 0}")

You could try

 

Or test it

For $i = 10 To 0 Step -1
    If $i = 0 Then
        ExitLoop
    EndIf
    Send($i)
Next
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Instead of

send("{A 0}")

You could try

 

Yeah but I use it with a variable that can be 0 and in this case it should send it 0 times (no times).

I can add an If statement but... I must also try to remember this strange thing for the future... and I don't have good memory...

Link to comment
Share on other sites

Yeah but I use it with a variable that can be 0 and in this case it should send it 0 times (no times).

I can add an If statement but... I must also try to remember this strange thing for the future... and I don't have good memory...

You are to obey the rules of the language you use. Nothing more or less. Otherwise you are misusing it and that's bad regardless of the state of your memory.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

You are to obey the rules of the language you use. Nothing more or less. Otherwise you are misusing it and that's bad regardless of the state of your memory.

Should I fully ready the help page before doing subtractions like 1-1 or 2-2 to see if there are exceptions?

Maybe it can be expressly stated that 1-1=1 or 2-2=1, in this language... :huh2:

Link to comment
Share on other sites

You should read the help file when using a command for the first time. Also, if it doesn't work as expected, reread the help file and see if you did something wrong, or you're assuming something because you didn't read the help file thoroughly enough.

This is a case of the latter, you expected something to work one way, when the help file states it works another way, yes it's buried in there but it's right after the section that explains how to send multiple instances of the same key stroke.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

The fact is that it happened that I created a program for a customer, she encountered a strange and wrong behavior of my program and I lost more than 1 hour and my reputation (because of the bug of my program) to research the problem, until I found that the cause was that when the quantity variable was 0 it didn't send 0 TAB key (as I wanted).

I just read the first lines of the help on this command, thinking that it was so easy in the concept that didn't need further reading.

If I have to fully read the help for all I would take 3x time to create scripts... and I liked AutoIt instead of Visual Basic because of its easiness and speed in programming...

Link to comment
Share on other sites

If I have to fully read the help for all I would take 3x time to create scripts... and I liked AutoIt instead of Visual Basic because of its easiness and speed in programming...

Well, you must have read as far as the section that explains how to send multiple keypresses I'm guessing? Otherwise, how would you have known the proper format for the code? Because, it doesn't mention that functionality until that section, which is quite far down the description, plus the example doesn't show it. You just needed to read one more line and you would have found it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Well, you must have read as far as the section that explains how to send multiple keypresses I'm guessing? Otherwise, how would you have known the proper format for the code? Because, it doesn't mention that functionality until that section, which is quite far down the description, plus the example doesn't show it. You just needed to read one more line and you would have found it.

That page is a very long page and as soon as I've read these two lines I thought that I understood the command and didn't read other paragraphs:

Send("{DEL 4}") ;Presses the DEL key 4 times

Send("{S 30}") ;Sends 30 'S' characters

I tested it with some numbers, it worked, I immediately used it.

I'm not going to sue anyone, I'm now just trying to understand why you prefer 0 = 1 and 1 = 1 and 2 = 2 ... and to not suggest a change to 0 = 0 and 1 = 1 and 2 = 2 ...

Link to comment
Share on other sites

You can always put in a feature request in the Bug Tracker to have it changed.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I could understand an issue due to "that book is a very long book" or even "that chapter was a very long chapter" but

That page is a very long page

:huh2: Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

That page is a very long page and as soon as I've read these two lines I thought that I understood the command and didn't read other paragraphs:

Send("{DEL 4}") ;Presses the DEL key 4 times

Send("{S 30}") ;Sends 30 'S' characters

I tested it with some numbers, it worked, I immediately used it.

I'm not going to sue anyone, I'm now just trying to understand why you prefer 0 = 1 and 1 = 1 and 2 = 2 ... and to not suggest a change to 0 = 0 and 1 = 1 and 2 = 2 ...

The logic could be: 1=1, 2=2, 3=3, 4=4, ...

Anything else is invalid and will be treated as 1 (e.g. try -123)

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Should I fully ready the help page before doing subtractions like 1-1 or 2-2 to see if there are exceptions?

Maybe it can be expressly stated that 1-1=1 or 2-2=1, in this language... :huh2:

For the record and any newbies reading this thread

1-1 = 0 in any language.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I think I lost some IQ points just reading this thread! :huh2:

me too.... -.- I think that noone can blame something that is free and comes whit his own rules... for logic and justice ask for god... man and his creations have their own rules that always was that way and always will be that way
Link to comment
Share on other sites

For the record and any newbies reading this thread

1-1 = 0 in any language.

[alter ego mode = on] How can you be sure? did you read all the help page of AutoIt related to math operators to see if there are exceptions in AutoIt? [alter ego mode = off]
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...