Jump to content


Photo

How to make a Keyboard Key autofire while pressed?


  • Please log in to reply
9 replies to this topic

#1 SFJake

SFJake

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 22 June 2008 - 01:15 PM

This program is great and all but I'm not here to learn how to make thousands of Macro for thousands of use... I ended up here because all I want is to make some of my keyboard keys "autofire".

I just want, for example, the A button to do it repeatedly and rapidly (its for gaming) as long as I hold it down, as if I pressed it extremely fast (auto fire).

I have absolutely no idea how this thing works and looking at the tutorials and all just makes me think It'll take me weeks to get this done.

Does anyone know how to do such a command? I figured it shouldn't be THAT hard if you know how that program works. I would "love" any help here.

#2 steveK

steveK

    Advanced

  • Members
  • PipPipPip
  • 110 posts
  • Gender:Male
  • Location:Western Wa
  • Interests:Computers, Freeware, Aikido, Cartooning, Reading non-fiction, My wife and pets

Posted 22 June 2008 - 06:45 PM

Probably a loop with a Text Type in it.
Such as:

Loop
Type "A"
Repeat

YOu'd have to have a way to stop it though, unless you just use the MacExp global hotkey to abort.

Quesiton: Why not just hold down the 'a' button, like this?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa?
Signature Launch: "Steve Kunkel" Parameters: "/eom"

#3 SFJake

SFJake

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 22 June 2008 - 08:04 PM

The point is to make something that works in a game. I'm sure you met game where you need to remove pressure off a key and press it again for it do do "whatever" action.

This mean you HAVE to press the key over and over to do it (you can't just hold it, its not like text). This is the point of what I'm trying to do.


It needs to be literally like a turbo key, having to shut it down manually would make it overcomplicated for gaming purpose. I guess the basic of what you posted wold works, just need a way to stop it when you don't press the key anymore. I'll try and see but I don't think I will figure it out alone. But thanks for your post.

EDIT: I can't even find the Loop command... :/ Well, there are Repeats commands but I don't know how they work I can't make them work.

#4 steveK

steveK

    Advanced

  • Members
  • PipPipPip
  • 110 posts
  • Gender:Male
  • Location:Western Wa
  • Interests:Computers, Freeware, Aikido, Cartooning, Reading non-fiction, My wife and pets

Posted 23 June 2008 - 10:41 AM

This mean you HAVE to press the key over and over to do it (you can't just hold it, its not like text). This is the point of what I'm trying to do.


Yes, I see what you mean....

EDIT: I can't even find the Loop command... :/ Well, there are Repeats commands but I don't know how they work I can't make them work.


Sorry, it actually *is* the "Repeat" command that I meant.

First do this:
Make a new macro that has a 'Hotkey' for the "Choose Default Activation."
Choose a key that's easy to press with one hand like 'Alt-A' (It must be a key combination that doesn't conflict with other game controls.)
Open the Macro Express Editor to 'Scripting Editor.'
Go to the 'Repeat' commands and choose "Repeat Until."
Set it up so it has Repeat until Variable T1 <> T1. This means "until T1 does not equal T1." In computer terms this means "repeat forever."
Now go to the 'Text' commands and "Type Text." Have it type "a."
Go back to the 'Repeat' one and add "Repeat End."
Save.
This is basically it. Open ( and click in) Notepad and try out the macro. **IMPORTANT** This loop will keep going forever! YOu have to kill it using MacExp's global abort key: Scroll Lock+Pause. (or just Right-click on the system tray icon of the little running man--which is what I do.) (note also that you can change the global abort key in Tools>Prefs)

After you've made sure it works, do this:
Open your game.
Open the MacExp editor.
On the "Scope" tab, and checkmark "Program Specific."
NOw click on 'Select' and find YOUR-GAME.EXE from the list and click 'add.'
Now the hotkey will only activate the macro when your game is running.

===========
A more complex version could be made like this:

Set Integer Variable N1 = 1
Repeat Until N1 = 100
Type "a"
Modify Variable N1 = N1+1
Repeat End.

This one would run the loop 100 times then stop on it's own.

========
Good luck. Let us know how it works! -steve :P
=============
EDIT: Actually the setting to change the MacEx global abort key is at
Options>Preferences>Playback.

If you go to Options>Preferences>Delays you can change the 'Text Type' speed... I THINK this will make the loop run faster or slower...
Signature Launch: "Steve Kunkel" Parameters: "/eom"

#5 SFJake

SFJake

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 23 June 2008 - 11:00 AM

Thank you.

Is it absolutely impossible to do it so it stops automatically when not pressing the key anymore? I really, really appreciate the help but that specific part is a "must" for it to be of any use to me.

Well, the worse is I tried if this worked in my game and it just doesn't and I did everything well. It just doesn't detect any input in game. The macro does active but nothing happens here (although if I leave it to run globally it will work on, say, notepad).

So again, thanks for the help, but if what I'm precisely asking for is impossible, just say so!

#6 steveK

steveK

    Advanced

  • Members
  • PipPipPip
  • 110 posts
  • Gender:Male
  • Location:Western Wa
  • Interests:Computers, Freeware, Aikido, Cartooning, Reading non-fiction, My wife and pets

Posted 23 June 2008 - 05:08 PM

Dang it! I just wrote a big long reply, then accidentally hit Ctrl-F in Firefox and it lost my entire post !!!!
Argh.

We anyway. To summarize: To the best of my knowledge it is not possible for a macro to only fire while the trigger is being pressed. Also, you can't have just "a" as a trigger. It has to be a hotkey combo (Alt-A, etc) or a series of shortkeys (##a, etc.).

There are other ways to automate macros though ....
Check out this thread.
http://pgmacros.invi...?showtopic=3126

Something as simple as pixel color can be a trigger or can be set in the middle of the loop as a "break-out condition." (i.e. keep looping until 'this' part of the screen turns 'this' color.)


Lastly, the "a" should work in any program. If your game is not able to tell when MacEx is doing aaaaaaa, then try to slow down the repeat loop. ...Options>Preferences>Delays

Gotta go. -steve
Signature Launch: "Steve Kunkel" Parameters: "/eom"

#7 SFJake

SFJake

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 24 June 2008 - 03:58 PM

Oh well.. if its impossible, I'll just have to find another program.. if it even exists. I've been looking for this for a long time. Anyway. Thanks again.

#8 steveK

steveK

    Advanced

  • Members
  • PipPipPip
  • 110 posts
  • Gender:Male
  • Location:Western Wa
  • Interests:Computers, Freeware, Aikido, Cartooning, Reading non-fiction, My wife and pets

Posted 24 June 2008 - 07:07 PM

Oh well.. if its impossible, I'll just have to find another program.. if it even exists. I've been looking for this for a long time. Anyway. Thanks again.


I'd be surprised if you can't find something, there's a lot of stuff out there..
Try a google search for keywords like "freeware keyboard utility."
Be careful... THere's a lot of spyware out there. I recommend only downloading from a website if you also do a google search OF THE SITE, and make sure it's been around for a while and is safe.
Good luck.
-steve
Signature Launch: "Steve Kunkel" Parameters: "/eom"

#9 MacroPolo

MacroPolo

    Member

  • Members
  • PipPip
  • 26 posts

Posted 24 June 2008 - 11:08 PM

The point is to make something that works in a game. I'm sure you met game where you need to remove pressure off a key and press it again for it do do "whatever" action.

This mean you HAVE to press the key over and over to do it (you can't just hold it, its not like text). This is the point of what I'm trying to do.


It needs to be literally like a turbo key, having to shut it down manually would make it overcomplicated for gaming purpose. I guess the basic of what you posted wold works, just need a way to stop it when you don't press the key anymore. I'll try and see but I don't think I will figure it out alone. But thanks for your post.

EDIT: I can't even find the Loop command... :/ Well, there are Repeats commands but I don't know how they work I can't make them work.


I've written many macro express macros for games. Sometimes it takes a little work to get the macro to do the function you need. If you could provide more information regarding which game, and which function you are trying to do, I would be happy to help out further.

I have a macro that can do what you are asking, but I have a better macro that uses the mouse instead of the keyboard.

In the example above, it asks you to assign the hotkey to something like ALT+A. For games, I always try to use an F key, (ie: F1 or F2). It's just one keyboard key to activate the macro.

The keyboard version of what you are asking would go something like the example below (assuming you've set up the scope to be program specific to the name of your game) [i used dots to help indent and make the code look easier to read]:


Variable Set Integer %N5% to 0
Repeat Until %N5% <> 0
.....Wait for Key Press: A
.....Text Type: a
Repeat End


That's pretty much it. If you assign the macro to F1, once you hit F1, the macro is waiting for you to press and hold the 'A' button. The macro will wait forever for you to press 'A'. When you press A, or while the 'A' button is held down, the macro will type the letter A over and over and over. When you let go of the 'A' button, the macro stops typing 'A', and waits again.

The only problem with this macro is that its not as 'turbo' as you might like, depending on the game. Additionally, one of the shortcomings of Macro Express is that you can only have 1 macro running at any time. Since this macro is always on, always waiting for the letter 'A', you can't have any other macros running or activating until this one ends.

The macro below, gets away from the keyboard and uses the mouse. This macro checks the mouse position. If the mouse is in the upper left corner, it stops turbo firing the 'A' key. If you move the mouse away from the upper left corner, it goes balistic, and SUPER turbo's the 'A' over and over (Much faster than the example above). Also, if you need the macro to stop (so you can use your mouse for something else in the game, just move the mouse down to the lower left corner, and the macro quits immediately... no questions asked. To get the macro to run again, just type F1 (or whatever activation you set it. You can even set the activation to be Shift+Mouse click if you want to):

Variable Set Integer %N5% to 0
Get Mouse Position Window: %N1%, %N2%
Repeat Until %N5% <> 0
.....Get Mouse Position Window: %N1%, %N2%
.....If Variable %N1% < 15
..........AND
.....If Variable %N2% < 15
.....Else
..........Text Type: a
.....End If
.....
.....If Variable %N1% < 15
..........AND
.....If Variable %N2% > 999
..........Macro Stop
.....End If
Repeat End


Anyways, I hope these examples are more in line with what you were expecting. If I had more time tonight, I think it would be possible to use the letter 'A' as a shortkey activation with no prefix key assigned. (ie: everytime the letter 'A' button was pressed, it would activate the macro). This isn't recommended, especially if you also chat or type other things in the game that involve the letter 'A'. But to set the shortkey to NOT have a prefix, go to "Options", then click on "Shortkeys". In the "prefix Keys" window, there is probably 2 ##'s. Just remove all text in this window, and there you go.

Let me know which games you are designing this macro for, and I will see if i have more time later to improve it.

#10 SFJake

SFJake

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 25 June 2008 - 12:42 AM

Thanks. Indeed it was more useful. Not quite there yet, though.

I found out that if it worked or not depends on the game or not, since I want to use it for multiple games.. well I won't be more specific.

"It works" to 2 extent. The autofire is too slow, no matter how I change the delays in the settings, it takes at least 1 second to do it again etc... More so, if I press anything else, it doesn't work (for example, right arrow + A and suddenly it doesn't work. The macro seems to expect A and A alone, other key conflicts with it).

Of course, this is excluding the problem that I can only have one of them on at a time... I don't understand why any of this is happening, most likely you do. I could live with having only one of them active at a time but.. the 2 other problems are too big, I'm afraid.