Jump to content
JustinZandee

Stop repeating after pressing a key

Recommended Posts

JustinZandee

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..

 

Share this post


Link to post
Share on other sites
JustinZandee

@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.

Share this post


Link to post
Share on other sites
JLogan3o13

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

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
JustinZandee

@JLogan3o13 Than you guys don't get me. I need to stop my script when I press f2.

As I said:

Quote

Maybe I am wrong and I need to use a whole other Function

So I don't think _IsPressed is the right Function

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
JLogan3o13
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 :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
JustinZandee

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

Share this post


Link to post
Share on other sites
Jos
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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
VIP
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,
 

Share this post


Link to post
Share on other sites
JLogan3o13
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 ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
iamtheky

he's just digesting it for him now :)

  • Like 1

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

Share this post


Link to post
Share on other sites
VIP
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,
 

Share this post


Link to post
Share on other sites
iamtheky

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.


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

Share this post


Link to post
Share on other sites
VIP
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,
 

Share this post


Link to post
Share on other sites
iamtheky
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

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

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

  • Similar Content

    • DynamicRookie
      By DynamicRookie
      Hey There!
       
      So, what i need to do is an app that can read text in a image (I.e. a png that has text saying "This is a png" and return the text to a variable)
      I'm pretty much a newbie on AutoIt, my purpose is doing that but i don't know any function that can

      Any help is much appreciated
    • WoodGrain
      By WoodGrain
      Hi All,
      I've bought a Ergodox EZ programmable keyboard with layers of key maps (eg, layer 0 = dvorak, layer 1 = numberpad & nav, layer 2 = qwerty, etc), I've also got a small USB screen that can pull information from the registry. What I would like to determine is a way to pull the value of each current key from the keyboard, I can then write the values to the registry and pull them into my USB screen so I can see the keyboard key layout.
      I'm stuck with retrieving the key values, I've looked at _IsPressed(), _WinAPI_GetKeyState(), _WinAPI_GetKeyboardState(), _WinAPI_GetKeyboardType(), _WinAPI_GetKeyNameText(), but none of them appear to be able to pull the keyboard key values without user interaction.
      The idea being, in pseudo code, bear in mind no error checking etc in this code, "GetKeyValue()" is what I'm needing help with and is a made up function, as is "HardwareKey1" etc:
      $keyOnePrev = "" $numOfKeys = 76 While 1 $keyOneCurrent = GetKeyValue(HardwareKey1) If $keyOneCurrent <> $keyOnePrev Then For $key = 1 To $numOfKeys $keyToWrite = GetKeyValue(HardwareKey & $key) RegWrite("HKEY_CURRENT_USER\Software\myKeyboard", "key" & $key, "REG_SZ", $keyToWrite) Next EndIf $keyOnePrev = $keyOneCurrent Sleep(5000) WEnd Thanks guys!
    • santoshM
      By santoshM
      How can i exit from a procedure in auto
      Func test() if x=o then     return endif endFunc  
    • Valnurat
      By Valnurat
      Hi
      Small question.
      I trying to find all index in an array with value higher than 7.
      How can that be possible?
    • TrashBoat
      By TrashBoat
      Could someone help me create or give an idea of how to do a incrementing for loop that would do this: https://i.imgur.com/YFUt47H.gifv
      I'm having a hard time figuring it out :S
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.