AHK turn off loop when Key is pressed - Stack Overflow

文章推薦指數: 80 %
投票人數:10人

I created a code that should send the "E" key until i press the "T" key. Right now the loop only stops when I hold the "T" key. Home Public Questions Tags Users Companies Collectives ExploreCollectives Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Collectives™onStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. LearnmoreaboutCollectives Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. LearnmoreaboutTeams AHKturnoffloopwhenKeyispressed AskQuestion Asked 7monthsago Modified 7monthsago Viewed 1ktimes 0 Icreatedacodethatshouldsendthe"E"keyuntilipressthe"T"key.RightnowthelooponlystopswhenIholdthe"T"key.Couldsomeonehelpmewiththis. F12:: loop { Sende Sleep3500 if(GetKeyState("t")){ break } } return autohotkey Share Follow askedJan1at21:11 SzymonDragSzymonDrag 333bronzebadges Addacomment  |  1Answer 1 Sortedby: Resettodefault Highestscore(default) Trending(recentvotescountmore) Datemodified(newestfirst) Datecreated(oldestfirst) 1 Iwouldsuggesttousethefollowingcode: F12:: Loop{ Send,e Sleep3500 ifbreak break } return T:: break:=!break return Theabovescriptwillstopinaintervalbetween0and3500msafteryoupressthe"T"becauseyouhavea"Sleep3500"ineachevaluation. YourscriptonlystopwhenyouHOLDthe"T",becausethe"T"MUSTbepressedwhiletheloopISONtheGETKEYSTATEfunction. P.S: Myenglishisaworkinprogress.. Share Follow answeredJan1at21:40 DieissonSilvadosSantosDieissonSilvadosSantos 37611silverbadge44bronzebadges Addacomment  |  YourAnswer ThanksforcontributingananswertoStackOverflow!Pleasebesuretoanswerthequestion.Providedetailsandshareyourresearch!Butavoid…Askingforhelp,clarification,orrespondingtootheranswers.Makingstatementsbasedonopinion;backthemupwithreferencesorpersonalexperience.Tolearnmore,seeourtipsonwritinggreatanswers. Draftsaved Draftdiscarded Signuporlogin SignupusingGoogle SignupusingFacebook SignupusingEmailandPassword Submit Postasaguest Name Email Required,butnevershown PostYourAnswer Discard Byclicking“PostYourAnswer”,youagreetoourtermsofservice,privacypolicyandcookiepolicy Nottheansweryou'relookingfor?Browseotherquestionstaggedautohotkeyoraskyourownquestion. TheOverflowBlog WhyAIishavinganon-premmoment(Ep.476) Opensourceandaccidentalinnovation FeaturedonMeta Recentsiteinstability,majoroutages–July/August2022 PleasewelcomeValuedAssociate#1301-Emerson The[maintenance]tagisbeingburninated StagingGroundWorkflow:QuestionLifecycle Whatshouldwedowithimproperlycitedposts? Related 1 AutoHotkey:While2keysarepressed=press3rdkey? 7 AutohotkeyHowtoholdamousebuttonwhileakeyispressed? 1 ReplaceLeftandRightClickforAlt+1andAlt+2(Autohotkey) 1 AHKScripttoturntogglebuttonsintoholdbuttons 0 AHKHoldButtonToggle 1 Makingakeybepressedwhenanotherisunpressed(AHK) 0 Multiplefunctionsononehotkey(keyholddownandrelease) 0 AHKwon'tstopsendingkey 0 autohotkey:Howtomakerightmousekeymimicitselfandthefunctionsofleftmousekeyatsametime? 0 AHK,howtocaptureRbuttoninloop HotNetworkQuestions HowdoChristiansrespondtothecriticismthatJesusofNazarethdidnotbringworldpeace? QGis3.22-PixelisedMapBackground StartabatfileonremotePC Canaphotonorbitaroundagalaxy? ----AddColours---- Intercolumnstatisticsbetweencolumnsinadataframe Ismymacfilevaultencrypted? Howdothe"Vorpal"and"Merciful"magicweaponspecialabilitiesinteractonacrit? HowcanIidentifyanembeddedLinuxdistribution? Sampletwonumbersfrom1to10;maximizetheexpectedproduct Analgorithmtofindevensublimenumbers Howtociteapaperwithauthorsinnon-alphabeticalorder? WhatisthelowerlimitofNiCdcellvoltage? Whatdoes"rightupclose"meaninthiscontext? Factoringapolynomialintolinearfactorsbyringextension 1940sphototubecollectormaterial/datasheetforatube Doplanetsloseenergywhilerotating? Whatisthesignificanceofreachingmajorversion1.0.0? Whydopeoplegenerallydopostdoc? Abouttheconsecutivedimensionsofk-eigenspaces WhyisiteasiertoraiseACcurrenttohighvoltage? Whatisthiselectricalcomponentcalled? Oldceilinglightfixturewith9wires(5black/4white)-howtoinstallanewfixture? WhencanaPhDstudentremovesomeoneasaco-authorfromapaper? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?