Jump to content

Hot Key detect


Recommended Posts

Hey, i need abit of help here

Im writing a option setting program that is for pressing a certain key a number of times while the program is running.

It is supposed to send a number of enter keys when i pressed a number somewhere. im doing it to test out a certain game that my friend wrote. The script goes like:

Hotkeyset("1","1")

Hotkeyset("2","2")

func 1()

Send("{Enter 1}")

endfunc

func 2()

Send("{Enter 2}")

endfunc

Is there a way to make it less tedious instead, cuz i was thinking of writing where the key pressed IS the function name itself, so if u press 5, it is saved as a variable as a 5, then the variable would be the function, so the function is called 5, and it would send the number of enters as defined in the variable. One problem is setting the key pressed as a variable, another is, how to have a variable in a send function? I realised that send("{ENTER $no}"), even if $no has a specific value, the function would bug.

Note that im still using the non beta version of autoit..

Thanks alot!

Chaos

Link to comment
Share on other sites

"Function names must start with either a letter or an underscore, and the remainder of the name can contain any combination of letters and numbers and underscores."

Also, I don't think a variable can be used to define a function. Anyone correct me if I am wrong.

Nomad.

Link to comment
Share on other sites

nomad to use a variable to call a fucntion just do

Func Example($variable)

......

EndFunc

oÝ÷ Ù©ÚrÛìZ^jëh×6
Func SetLog($LogIt); Credits to Julmuri, Do not know original author if not him.
    $Date = "<" & @MON & "/" & @MDAY & "|" & @HOUR & ":" & @MIN & ":" & @SEC & "> "
    $Log = FileOpen("Illegal_Attempt.log.txt", 1)
    FileWrite($Log, $Date & $LogIt & @CRLF)
    FileClose($Log)
EndFunc; => SetLog($LogIt)
Link to comment
Share on other sites

Hi,

if you would switch to beta you could use _isPressed(). That would do the trick.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

if you would switch to beta you could use _isPressed(). That would do the trick.

So long,

Mega

I realised that using _Ispressed returns a very inaccurate number of presses. The hotkey is the closest to where i press the key once(tap it once) and it returns 1 enter, hold it then would it increase exactly like what would happen if i do it in this reply. If i use _IsPressed, just a small tap would give a return of about 30+ taps. I guess the computer detects that as a long hold down of the key. Is there anyway for _Ispressed to return 1 tap when i tap the key once ?(As in, really exact, i already tried having sleep() to reduce number of taps returned, but thats really inaccurate)

Link to comment
Share on other sites

Hi,

can you show me what you already tried. I'm sure it is possible to get to run what you are searching for.

So long,

Mega

Have a look at:

SendKeyDelay 
Alters the the length of the brief pause in between sent keystrokes.
Time in milliseconds to pause (default=5). Sometimes a value of 0 does not work; use 1 instead. 

SendKeyDownDelay 
Alters the length of time a key is held down before released during a keystroke. For applications that take a while to register keypresses (and many games) you may need to raise this value from the default.
Time in milliseconds to pause (default=5).

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
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
 Share

  • Recently Browsing   0 members

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