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

    • VaishnaviBUtpat
      By VaishnaviBUtpat
      <!DOCTYPE html> <html lang="en" xml:lang="en" style="height: 100%;" xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style> * { margin: 0; padding: 0; } .th-lk { color: #3665d0; font-family: Arial; font-size: small; text-decoration: none; } .th-lk { vertical-align: 0px; } .th-menu2 .th-lk { line-height: 2em; margin-bottom: 0px; margin-right: 0px; overflow: hidden; padding: 0; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; width: 100%; } .th-menu2 .th-lk { color: black; font-weight: bold; } .th-menu2 > li > .th-lk { display: block; padding-left: 8px; width: auto; } .th-menu2 .th-menu2-sub-item .th-lk, .th-menu2 .th-menu2-sub-item-hov .th-lk { margin-right: 20px; } .th-menu2-sub-item { position: relative !important; } .th-menu2 .th-menu2-item, .th-menu2 .th-menu2-item-hov, .th-menu2 .th-menu2-sub-item, .th-menu2 .th-menu2-sub-item-hov { background-repeat: repeat-x; border-left-style: solid; border-left-width: 1px; border-right-style: solid; border-right-width: 1px; border-top-style: solid; border-top-width: 1px; height: 2em; list-style: none; margin-bottom: 0px; padding: 0; width: 100%; } .th-menu2 .th-menu2-item, .th-menu2 .th-menu2-item-hov, .th-menu2 .th-menu2-sub-item, .th-menu2 .th-menu2-sub-item-hov { background-color: #ECECEC; background-image: url(sap_skins/default/styling/lshape/chg_butt_det_nav.gif); border-left-color: #d3d1ce; border-right-color: #d3d1ce; border-top-color: #d3d1ce; border-top-width: 0px; } .th-menu2 { border: 0 solid black; left: 0px; list-style: none; margin: 0; padding: 0; position: relative; } .th-menu2 { z-index: 10006; } .th-menu2 { background-color: white; } div { zoom: 1; } .th-sc-content { left: 0px; position: absolute; top: 0px; } .th-sc-container { left: 0px; overflow: hidden; position: relative; top: 0px; } .th-sc-top { position: relative; } .th-sc-top, .th-sc-content, .th-sc-container, .th-sc-buttondown, .th-sc-buttonup { width: 172px; } .th-sc-buttonup, .th-sc-container { z-index: 10101; } .th-sc-top { z-index: 10100; } body, td, th { font-family: Arial,Helvetica,sans-serif; font-size: small; } .th-l-navcontainer, .th_l_downcontainer { border-right-style: solid; border-right-width: 1px; width: 172px; } .th-l-navcontainer, .th_l_downcontainer { background-color: white; border-right-color: #d3d1ce; } body, html { margin: 0px; border: 0; margin: 0; } </style> </head> <body><form name="myFormId" id="myFormId" action="/sap(ZT1TVVJEWDFWVFVsOWZYMTlmTWpNNU9UWmZXWTlwZG5telZ1RGhBSUFBQ3Nyc2tBPT0=)/bc/bsp/sap/crm_ui_frame/BSPWDApplication.do?sap-client=100&amp;sap-language=EN&amp;sap-domainrelax=min" method="post" target="WorkAreaFrame2"><div class="th-ajax-area" id="rootAreaDiv"><div id="C1_W1_V2" tgt="" dhe="false"><table width="100%" style="table-layout: fixed;" cellspacing="0" cellpadding="0"><tbody><tr><td><table width="100%" style="table-layout: fixed;" cellspacing="0" cellpadding="0"><tbody><tr valign="top"><td class="th-l-navcontainer" id="th_l_navcontainer"><div class="th-sc-top" id="C1_W1_V2_thescroll" style="height: 786px;"><div class="th-sc-container" id="C1_W1_V2_thescroll_scbox" style="height: 786px;"><div class="th-sc-content" id="C1_W1_V2_thescroll_sccontent"><div class="th-ajax-area" id="C1_W1_V2_$navbar"><div id="C7_W35_V36" tgt="" dhe="true" excevt="" intevt="c:C7_W35_V36:C1_W1_V2_C7_W35_V36_MainNavigationLinks.do;" automode="true"><div class="th-ajax-area" id="C1_W1_V2_C7_W35_V36_MainNavigationLinks.do"><ul class="th-menu2" id="C7_W35_V36_mainmenu" style="width: 171px;"><li class="th-menu2-sub-item"><a title="Sales Cycle" class="th-lk" id="C7_W35_V36_UTL-SLS" onclick="htmlbSubmitLib('htmlb',this,'thtmlb:link:click:0','myFormId','C7_W35_V36_UTL-SLS','UTL\x2dSLS\x2dWC',0);return false" onfocus="thSaveKbFocus(this);" oncontextmenu="return false;" href="javascript:void(0)">Sales Cycle</a></li></ul></div></div></div></div></div></div></td></tr></tbody></table></td></tr></tbody></table></div></div></form></body> </html> How to capture above HTML element using AutoIT
    • cu0x
      By cu0x
      Hello guys,
       
      im trying to solved a problem that I have.
       
      Need to get some chinese text from an old Wise script, and in the wise file says f.e. Ù×÷ϵͳ¡£ ÇëÉý¼¶Ä. Is there any way to convert it to traditional chinese?
       
      Already tryied the following code...
       
      #include <MsgBoxConstants.au3> Example() Func Example() ; Define the string that will be converted later. ; NOTE: This string may show up as ?? in the help file and even in some editors. ; This example is saved as UTF-8 with BOM. It should display correctly in editors ; which support changing code pages based on BOMs. Local Const $sString = "Ù×÷ϵͳ¡£ ÇëÉý¼¶Ä" ; Temporary variables used to store conversion results. $dBinary will hold ; the original string in binary form and $sConverted will hold the result ; afte it's been transformed back to the original format. Local $dBinary = Binary(""), $sConverted = "" ; Convert the original UTF-8 string to an ANSI compatible binary string. $dBinary = StringToBinary($sString) ; Convert the ANSI compatible binary string back into a string. $sConverted = BinaryToString($dBinary) ; Display the resulsts. Note that the last two characters will appear ; as ?? since they cannot be represented in ANSI. DisplayResults($sString, $dBinary, $sConverted, "ANSI") ; Convert the original UTF-8 string to an UTF16-LE binary string. $dBinary = StringToBinary($sString, 2) ; Convert the UTF16-LE binary string back into a string. $sConverted = BinaryToString($dBinary, 2) ; Display the resulsts. DisplayResults($sString, $dBinary, $sConverted, "UTF16-LE") ; Convert the original UTF-8 string to an UTF16-BE binary string. $dBinary = StringToBinary($sString, 3) ; Convert the UTF16-BE binary string back into a string. $sConverted = BinaryToString($dBinary, 3) ; Display the resulsts. DisplayResults($sString, $dBinary, $sConverted, "UTF16-BE") ; Convert the original UTF-8 string to an UTF-8 binary string. $dBinary = StringToBinary($sString, 4) ; Convert the UTF8 binary string back into a string. $sConverted = BinaryToString($dBinary, 4) ; Display the resulsts. DisplayResults($sString, $dBinary, $sConverted, "UTF8") EndFunc ;==>Example ; Helper function which formats the message for display. It takes the following parameters: ; $sOriginal - The original string before conversions. ; $dBinary - The original string after it has been converted to binary. ; $sConverted- The string after it has been converted to binary and then back to a string. ; $sConversionType - A human friendly name for the encoding type used for the conversion. Func DisplayResults($sOriginal, $dBinary, $sConverted, $sConversionType) MsgBox($MB_SYSTEMMODAL, "", "Original:" & @CRLF & $sOriginal & @CRLF & @CRLF & "Binary:" & @CRLF & $dBinary & @CRLF & @CRLF & $sConversionType & ":" & @CRLF & $sConverted) EndFunc ;==>DisplayResults Thanks a lot!
    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      I want create retractable bar using autoit
      I tried creating slider, but there's a problem with screen reader for the blind, so is there another retractable tape?
      It is advisable to not accept dragging with the keybord only with  mouse
      note:
      This bar is needed in the process of raising and lowering the volume
      I hope that there is a solution to do that
      i waiting your responses.
      Thanks in advance to all members and administrators
    • XanzyX
      By XanzyX
      Is there a function out there that will edit an existing file witha a "Save" and "Cancel" at the bottom?
      Example: Funcrion("TestFile.txt")
    • HalleMike
      By HalleMike
      Hello to all,
      I've written a script using following part is inserted.
       
      Func _CallFolder() ; .... Local $_hDLL = DllOpen("user32.dll") ; .... ; .... While 1 ; .... ; .... If _IsPressed("1b",$_hDLL) then _Terminate($_hDll,$_iPID,$_hGUI) Sleep(10) WEnd ; .... ; .... EndFunc Func _Terminate($_para1, $_para2, $_para3) DllClose($_para1) ProcessClose($_para2) GUIDelete($_para3) Exit EndFunc The script is working right. But on typing "ESC" not only my script is closing all other open programs using "ESC" for termination too going closed.
      I've no idea why that happens.
      Maybe one of the "profis" can help me on it.
      Please ecxuse my bad English but I'm a German trying his best.
      Thank you and best regards, HalleMike