Jump to content

Stop repeating after pressing a key


Recommended Posts

I want to create a loop which loops a code until for example f2 is pressed.

So I tried something with _IsPressed but it doesn't work.

Local $test = 

WinActivate("Notepad")
Do
    Send("hi")
Until _IsPressed("72", $test)

 

I don't know how I can do nothing when pressing f2 because it says "error: _IsPressed(): undefined function.".

I did put 

Send("hi")

after Local $test = but it gives the same error.

Does anyone know how to solve this problem? 

Maybe I am wrong and I need to use a whole other Function.. I am new to AutoIT so I am sorry..

 

Link to comment
Share on other sites

@Jos I looked at it but I am not the best at English so I don't get it. I asked one more question.

I want to create a loop which loops a code until f2 is pressed.

Please show some example code and don't always say "Open the helpfile" or "Try something out" because I just don't get it.

Link to comment
Share on other sites

  • Moderators

If you cannot be bothered with looking at the help file or actually trying something, you're not going to get very far. This forum is dedicated to helping people with their scripts; it is not a place where you put in an order and someone barfs up the code for you.

This error:

Quote

 "error: _IsPressed(): undefined function.".

means you are missing the include file for that function at the top of your script. As Jos stated, look in the help file at _IsPressed() and it shows you right at the very top what include file to add. 

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

I understand just fine, and see that you have a couple of issues in your script (like calling _IsPressed incorrectly), which is why we keep pointing you back to the help file. Written correctly, the script works just fine with _IsPressed. Here is what I will offer you:

  • Again, and as clearly as I can - you have to have the right include file at the top of your script for _IsPressed to work.
  • Your second parameter in _IsPressed is not correct, which is why it won't stop
  • 72 is not even the right key for "F2" as you claim to want.

All three items are clearly explained if you simply look at the example under _IsPressed.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators
2 minutes ago, Trong said:

 

HotKeySet("{F2}", "StopTYPE")

Global $StopTYPE = False

;~ WinActivate("Notepad")
WinActivate("Untitled - Notepad")

While 1
    Send("hi ")
    Sleep(500)
    If $StopTYPE Then ExitLoop
WEnd

Func StopTYPE()
    $StopTYPE = True
EndFunc

 

I guess I was wrong, wait around long enough and someone will barf up code - albeit at triple the length it needs to be :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Developers
1 hour ago, JustinZandee said:

I looked at it but I am not the best at English so I don't get it.

Gezwets en je weet het. ;)

Bullshit and you know it. ;)

JOs

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

30 minutes ago, JustinZandee said:

@Trong Thank you so much! I looked at the code and now I know how it works! Thanks!

You need to learn how to use help files to use AutoIT.

With Function AutoIT on SciTE.  there are 3 colors of the function for name!
- Dark blue: is a function is designed as available as Sleep (), Run (), ..
- Blue: is a user-defined function in officially recognized UDFs. Like _IP (), ..
- Black: is a function you write yourself!

For functions in UDF or functions you write yourself you can put anywhere in your script or different file, you simply declare the filename containing that function with the #include "FilePath\Name.au3" command. With built-in UDF functions with AT you only need to declare the name without the path (if placed in the same directory as the script does not need the path) #include <FileName.au3>

From here, to use the _IsPressed() function and learn how to use it,
type in the name of the function (_IsPressed) on SciTE, and click on the name (any part |_I|s|P|r|e|s|s|e|of the function and press F1 to open the HELP file and view the usage instructions and Library is required! So  _IsPressed()  need #include <Misc.au3>

Src: 

#include <Misc.au3>

WinActivate("Untitled - Notepad")

Do
    Send("hi")
    Sleep(100)
Until  _IsPressed("71") ; F2

 

Regards,
 

Link to comment
Share on other sites

  • Moderators
20 minutes ago, Trong said:

You need to learn how to use help files to use AutoIT.

Kind of nonsensical to say this after you spoon feed it to them ;)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

he's just digesting it for him now :)

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

Link to comment
Share on other sites

12 minutes ago, JLogan3o13 said:

Kind of nonsensical to say this after you spoon feed it to them ;)

For novices, coming to AutoIt usually comes from something (personal issues) not to learn, they want to be resolved soon and fast! I myself too!

The moment of initial confusion is inevitable. Depending on how you behave each person will have a different way of looking at it!

The problem is solved, and after that they will see AutoIT is great, they continue to apply it to the issues of work and personal life.
Continuing Study and apply. I believe it is not nonsense!

Regards,
 

Link to comment
Share on other sites

You are just picking random beginner facts and spouting them.  And this attracts useful members to the community? 

By all means answer 101 questions to people who have zero clue wtf they are doing, but that social assessment is idyllic at best (and omg ridiculous at worst).

Maybe instead of handing the whole thing completed, step through each problem with the OP. This could have been a useful 3-page thread based on the number of issues it started with.  The first correct answer should come from the OP, your solution impresses nobody.

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

Link to comment
Share on other sites

22 minutes ago, iamtheky said:

your solution impresses nobody.

I'm not a good coder! So it is not surprising that my code does not impress.

All my programs are released or the code I post, is all edited or rewritten from others people on this forum and other sources.
I always self-conscious about my bad code, so I rarely release them.

I do not need attention or impress anyone.
Participating in this forum is only for obtaining the code and code that can serve my problem.

And I can help someone, also need help like me!



-----------------------
Sorry to talk about issues not related to thread topic!

Regards,
 

Link to comment
Share on other sites

11 minutes ago, Trong said:

I'm not a good coder! So it is not surprising that my code does not impress.

There are only three lines in my reply, no need to take things out of context.  The "You" in that sentence is anyone other than the OP handing out code under the pretense that they are teaching.

Again, being charitable and dispensing with answers is fine, I just dont believe it is accomplishing what you believe it to be accomplishing.

Edited by iamtheky

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

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

×
×
  • Create New...