JustinZandee

Stop repeating after pressing a key

17 posts in this topic

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



@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

@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

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

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

he's just digesting it for him now :)

1 person likes this

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

Share this post


Link to post
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,
 

Share this post


Link to post
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.


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

Share this post


Link to post
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,
 

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

    • JSmith312
      By JSmith312
      Hello Everyone! 
      I'm attempting to create a checklist app that performs other functions. For performance, I would like to check the box, then have the button to the right enabled. After that button is pressed, the second checkbox is enabled, and ready to be checked, allowing the second button to be pressed. After the second button is pressed, the completion/exit button is enabled/shown. I have my code that currently creates the GUI, creates the checkbox, but when you check it it enables the button and the next checkbox. Can't seem to figure out a Case for GUISetOnEvent. Any assistance would be appreciated!
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> ; Below is the GUI interface _DeploymentProcess() Func _DeploymentProcess() $aStep1 = GUICreate("Deployment Process", 475, 345, 500, 175) $CBcStep1 = GUICtrlCreateCheckbox("1. Step 01.", 15, 25, 300, 25) $BTNS1 = GUICtrlCreateButton("Email 01", 365, 25, 90, 20) $CBcStep2 = GUICtrlCreateCheckbox("2. Step 02.", 15, 50, 300, 25) $BTNS2 = GUICtrlCreateButton("Email 02", 365, 50, 90, 20) GUICtrlSetState($CBcStep2, $GUI_DISABLE) GUICtrlSetState($BTNS1, $GUI_DISABLE) $CBcStep3 = GUICtrlCreateButton("Hurray! You're Complete!", 85, 276, 300, 60) GUICtrlSetState($CBcStep3, $GUI_SHOW) ; Below are the button and checkbox enables/disables. GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($aStep1) Return ; Step 1 Case $CBcStep1 If GUICtrlRead($CBcStep1) = $GUI_CHECKED Then GUICtrlSetState($BTNS1, $GUI_ENABLE) GUICtrlSetState($CBcStep2, $GUI_ENABLE) Else GUICtrlSetState($BTNS1, $GUI_DISABLE) GUICtrlSetState($CBcStep2, $GUI_DISABLE) EndIf ; Step 2 Case $CBcStep2 If GUICtrlRead($CBcStep2) = $GUI_CHECKED Then GUICtrlSetState($BTNS2, $GUI_ENABLE) GUICtrlSetState($CBcStep3, $GUI_ENABLE) Else GUICtrlSetState($BTNS2, $GUI_DISABLE) GUICtrlSetState($CBcStep3, $GUI_DISABLE) EndIf Case $CBcStep3 If GUICtrlRead($CBcStep2) = $GUI_CHECKED Then GUICtrlSetState($BTNS10, $GUI_ENABLE) GUICtrlSetState($CBcStep3, $GUI_SHOW) Else GUICtrlSetState($CBcStep3, $GUI_EVENT_CLOSE) EndIf Case $GUI_EVENT_CLOSE, $CBcStep3 #comments-end Exit EndSwitch WEnd EndFunc  
    • RoundChecker
      By RoundChecker
      Hi everyone,

      Is there a way to determine whether the script that is running, is already running, without using;
       
      If WinExists ?

      Or is there a way to use "If WinExists" to determine the script itself?

      The reason I am asking this is because if I want someone to run the .Exe I have and they rename it to whatever they want, how could I then determine in the script to check if there's already an .Exe open, or the script itself is already open?

      Should I use Class, or how do I achieve this?

      Thanks in advance.
    • svenjatzu
      By svenjatzu
      Id like to build a little helpertool for my boss in office but i dont know how to sart it.
      thats no complicated task. im working for an insurancecenter and have to search the customers in different orders and different tags.
      due to my boss is old and not really commen with pc he saves the customers without system.
      eg, customer andreas statham got an insurenca for his car then i got to search for
      andreas statham car, andreas car statham, car andreas statham, statham andreas car, statham car andreas, car statham andreass etc to find all the files from this customer in the harddrive.
      some customers also are fmiliarnamed in one file like andreas statam and monika rog are married an both got a carinsurance then i got to earch for
      andreas statham monika rog car, andreas statham monika car rog,.... this can take real long to find the right customer if i do it from hand.
      how can i realise this someone in here got an excamlple script or has any sugestion?
       
       
    • X_xkijux_x
      By X_xkijux_x
      Ok so im using this program. clarify for school. I would like to have a program that takes every word i type in microsoft word and searches on it in claryfi. is this possible. I would like to have the program not stopping me from typing more after that word. Like when i type a word it auto search it on clarify without making me stop typing and if i want to change i can do that and if im fine that word i can just keep typing and it will search after the next word. 
    • Miliardsto
      By Miliardsto
      Is this possible to make program works like in diagram? There is so much encryption methods and UDFs are they give security? If the $Address will be crypted with some encryption algorithm could be possible to get the value of $Address in easy way? Of course We know its easy too look into autoit code and get value of variable and so We dont want to anyone see $Address value - there are functions Could func1.au3, func2.au3.. be for example func1.php or other type of file? As we know .php files are unnable to see. For example func1 would be read by FileRead() and then Execute() Is this generally possible to do?
      Will it give secure?
      What do you think about? Maybe there is something wrong in this concept or missed.