Jump to content

Hold Key and release


 Share

Recommended Posts

HotKeySet("{F1}", "_hold")
HotKeySet("{F2}", "_release")

  While 1
    Sleep(100)
  WEnd

Func _hold()
   Send("{a down}")
EndFunc

Func _release()
   Send("{a up}")
EndFunc

 

why this wont work how i want ?
I just want press F1 to start hold key "a" and release it later by hit F2

by hit F1 just appear x1 "a" letter 

Link to comment
Share on other sites

  • Developers

That is because that is what you have coded. The character repeat functions is a keyboard function, so you need to code that in the script when you want to simulate that.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Put it in a loop that doesn't end until you hit the F2 key.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

thx bro
i hear. if something is stupid but work thats is not stupid xD sorry formy english
i already got idea but there is a "better" way ?

 


HotKeySet("{F1}", "_switch")
HotKeySet("{F2}", "_switch2")

$x = False

  While 1
    Sleep(100)
  WEnd

Func _switch()
   $x = False
   While 1
      If $x = False Then Send("{a down}")
   WEnd
EndFunc

Func _switch2()
   $x = True
EndFunc

 

if any suggestion to make it more clear 

Link to comment
Share on other sites

ok i cant do better than this for now
 

HotKeySet("{F1}", "_switch")
HotKeySet("{F2}", "_switch2")

$x = False

      While 1
            Sleep(100)
      WEnd

Func _switch()
      $x = Not $x
            While 1
                  If $x = True Then Send("{a down}")
            WEnd
EndFunc

 

but i wanted try like this:


while $x = True

      Send("{a down}")

Wend

but not working

Link to comment
Share on other sites

@Nine was just trying to legitimize the purpose and intent of your script.  Key spamming such as your example is more frequently than not associated with game bots.

So no, it's not trash; and the fact you remain vague and got defensive doesn't bode well.  So how 'bout we ask a different way....what are you trying to automate?

Feel free to report, it may draw the attention this thread is shaping up to warrant either way. ;)

Link to comment
Share on other sites

  • Developers
6 hours ago, Nine said:

What game is this ?

Please don't, just stay out or report in case you are sure it is in violation with our rules.

6 hours ago, Verssuss said:

should i report u or u just bring trash here for fun ??

Please don't react like this either, it doesn't contribute to any fruitful discussion...  but while we are on the subject:
You haven't told us which program needs this many repeats for the letter a yet, so what is it you are doing here?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

i need just hold specyfic keys on my laptop. its not for game... im doing alot simple test code need lern autoit better.
anyway. thets i just lern about holds any keys there are 4 ways to do that.
now my point is make code to hold any kay i want but all ways almost failed.
there is one best way like {shiftdown}{ctrldown}and{altdown} this working perfect but only for this 3 keys

many repeats mean nothink now for me just need hold and release or how just quit loop what holding key

E: im kinda new on this forum i have script like udf i made but dont know where to show it and wait for opinion
 

Edited by Verssuss
Link to comment
Share on other sites

Link to comment
Share on other sites

9 minutes ago, Verssuss said:

i dont understand this forum...

it looks like I'm enter to the shop what immediately means I am a thief.
 

So tell us what is the application you intend to implement with those key sends.  And stop telling us, it is for learning purposes.  Nobody here is searching for this type of knowledge. There is rules in this forum, maybe you don't like it, but you got to live with it.  

Link to comment
Share on other sites

Hence you don't need it.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • Developers
9 hours ago, Nine said:

Sometimes you know but you can't be sure.  So better be honest and say what needs to be say...

No you don't and I asked nicely not to, but the fact remain you simply report or move on without you needing to ask. 

7 hours ago, Verssuss said:

i dont need it for any game

i dont need it for any application

i dont need it for any program
 

So we are done here. Please don't waste my time and the space here when you can't be honest.
*click*

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Jos locked this topic
  • Moderators

To add to what Jos stated above, @Nine you would do well to read the following thread carefully:

 

Pestering newcomers with questions because you think maybe they're doing something against the rules is not good enough. If the OP states something specifically against the rules, report it. If you are unsure whether it is against the rules or not, report it. And don't, as some around here do, report it and then help in the thread or report it and then continue to harangue the poster; report and move on.

We have had sanction forum members in the past for wanting to play detective and grill others over their intentions - no one on the Moderation team wants to go back to having to do that.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...