JustinZandee

Stop repeating after pressing a key

17 posts in this topic

#1 ·  Posted

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



#3 ·  Posted

@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

#4 ·  Posted (edited)

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

#5 ·  Posted

@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

#7 ·  Posted

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

#8 ·  Posted

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

#9 ·  Posted

@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

#10 ·  Posted

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                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#11 ·  Posted

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

#12 ·  Posted

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

#13 ·  Posted

he's just digesting it for him now :)

1 person likes this

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

Share this post


Link to post
Share on other sites

#14 ·  Posted

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

#15 ·  Posted

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

#16 ·  Posted

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

#17 ·  Posted (edited)

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

    • sree161
      By sree161
      Hi,
      i have a code which generates two numeric outputs.i have to save them in excel.
      Is there any way to export them to specific cells in excel???
    • TotalAuto
      By TotalAuto
      Howdy All
      I've gone around and around in circles wasting hours trying to fix this problem to no avail so I thought I would try posting for help given there are some real smart people in this forum.
      Background
      I have 5 separate .au3 scripts that all do different basic tasks. For example:
      1.au3 = opens Chrome browser to obtain information from a specific website then closes
      2.au3 = opens an Excel workbook to run a macro then saves and closes
      3.au3 = Open two seperate workbooks and transfers data from one to the other then saves and closes
      4.au3 = .......etc
      5.au3 = .......etc
      These 5 separate scripts, doing completely different tasks, need to each run once per day at 5 different designated times within a day and then close. For example:
      1.au3 = 10am
      2.au3 = 12pm
      3.au3 = 2pm
      4.au3 = 4pm
      5.au3 = 5pm
      Problem
      I can not get these different scripts to reliably run at their designated times. When I manually run these scripts individually by using 'Go F5' they work perfectly. If I convert these scripts to an .exe and manually run each one they work about 98% of time.
      How can I schedule these different .au3 files or associated .exe files to reliably run each day at different times?
      Attempts To Fix The Issue
      1. I have tried converting each .au3 script into their own .exe file and use Window's Task Scheduler to run these .exe files at their designated time but the success rate  of running each .exe in full, to completion, without error is very low at about 30%. Things that commonly go wrong include a browser not opening but movement still continues on the desk top. Other times things just do not happen at all.
      2. I have Windows 7 64 bit and have tried creating and running both (x86) and (x64) .exe files but again reliability problems exist;
      3. I have also tried moving each .exe file to the My Documents folder as I read someone that keeping your files on your desktop ties your files to individual Windows user profiles which can cause AutoIt operating errors. Not sure if this is correct but thought I would try it anyway. It did not fix my issue.
      4. I installed a program called AlwaysUp which supposedly always reliably runs in the background and will reliably execute your AutoIt script or .exe files. Still have significant reliability issues.
      Therefore, can someone please provide advice on how I can get my 5 different .au3 files to run at 5 designated times through the day, every day, without fail? Overtime I will be creating more and more different .au3 files to run certain tasks throughout the day and do not want to create one large AutoIt file that continually runs and attempts to do all the different tasks itself.
      Any help is very appreciated.
      Thanks
      Dan
       
       
    • hugomito
      By hugomito
      Hi all,
      I built an AutoIt application that interacts with several other applications/software. Now, it's turn to interfact with Visual Studio Team Services (VSTS).
      Does anyone has a blog, demo, script to share?
      Thanks!
    • Viki
      By Viki
      This is my first time here so please dont bombard me that what a silly question I am asking!!
      I have 500 rows (A1:A500) in a spreadsheet and I just want to copy one by one row and then paste into another application and then press enter, loop should repeat this until finishes all 500 rows.
      I have looked at clipget(), clip(put() but dont know how to select next row in next turn. I also looked at Array to store but again no luck. Can some guide me please..
    • DineshPawar
      By DineshPawar
      0down votefavorite   In my current project, Excel macro open AutoIt script using a function Call Shell("location of autoit script").
      For proper functioning of AutoIt script it's need to be close parent Excel workbook, so this closing Excel action is written in AutoIt script itself.
      But as soon as AutoIt script close parent Excel workbook then script get pause and it do nothing.
      How open the AutoIt script from Excel workbook and after that parent Workbook get close?