Imbuter2000 0 Posted June 20, 2011 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!! Share this post Link to post Share on other sites
trancexx 1,013 Posted June 20, 2011 You expected? Help file is clear: "The key will be send at least once even if the count is zero." ♡♡♡ . eMyvnE Share this post Link to post Share on other sites
Imbuter2000 0 Posted June 20, 2011 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? Share this post Link to post Share on other sites
JohnOne 1,603 Posted June 20, 2011 (edited) 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 June 20, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
Imbuter2000 0 Posted June 20, 2011 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... Share this post Link to post Share on other sites
trancexx 1,013 Posted June 20, 2011 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 Share this post Link to post Share on other sites
Imbuter2000 0 Posted June 20, 2011 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... Share this post Link to post Share on other sites
BrewManNH 1,305 Posted June 20, 2011 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 GudeHow 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 Share this post Link to post Share on other sites
Imbuter2000 0 Posted June 20, 2011 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... Share this post Link to post Share on other sites
whim 1 Posted June 20, 2011 @Imbuter2000 Right... and I assume you'd also sue your local hardware store if you hit your thumb with a hammer ? Share this post Link to post Share on other sites
BrewManNH 1,305 Posted June 20, 2011 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 GudeHow 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 Share this post Link to post Share on other sites
Imbuter2000 0 Posted June 20, 2011 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' charactersI 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 ... Share this post Link to post Share on other sites
BrewManNH 1,305 Posted June 20, 2011 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 GudeHow 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 Share this post Link to post Share on other sites
iamtheky 927 Posted June 20, 2011 (edited) I could understand an issue due to "that book is a very long book" or even "that chapter was a very long chapter" butThat page is a very long page Edited June 20, 2011 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Share this post Link to post Share on other sites
trancexx 1,013 Posted June 20, 2011 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' charactersI 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 Share this post Link to post Share on other sites
JohnOne 1,603 Posted June 21, 2011 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... For the record and any newbies reading this thread1-1 = 0 in any language. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
Fubarable 1 Posted June 21, 2011 I think I lost some IQ points just reading this thread! Share this post Link to post Share on other sites
monoscout999 10 Posted June 21, 2011 I think I lost some IQ points just reading this thread! 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 Share this post Link to post Share on other sites
Imbuter2000 0 Posted June 21, 2011 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] Share this post Link to post Share on other sites
Imbuter2000 0 Posted June 21, 2011 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)I would find more logic <1=error then, like when you do 1/0. Share this post Link to post Share on other sites