Jump to content
Sign in to follow this  
randomGuy

While a button is pressed

Recommended Posts

randomGuy

Hey everyone! I'm new to these forums and new to scripting. I've been lurking around the site to try and comprehend how to do a simple script. But I've hit somewhat of a roadblock, so I need some help.

Here is what I need my script to do:

If I press the NUMPAD9 button, I want the script to press down and hold NUMPAD4, NUMPAD5 and NUMPAD6 at the same time, and release those three buttons once I release the NUMPAD9 button.

Here's the script that I came up with:

#include <Misc.au3>
Local $hDLL = DllOpen("user32.dll")
While 1
Sleep(10)
    If _IsPressed("69", $hDLL) Then
  Send("{NUMPAD4 down}")
  Send("{NUMPAD5 down}")
  Send("{NUMPAD6 down}")
    Else
  Send("{NUMPAD4 up}")
  Send("{NUMPAD5 up}")
  Send("{NUMPAD6 up}")
    EndIf
WEnd
DllClose($hDLL)

Now here's the problem... The script seems to be doing what it's supposed to. But every now and then, the buttons NUMPAD4, 5 and 6 seem to stop working. After pressing them a few times they work again.

I can't figure out why this is happening, and it's not a keyboard (that is, mechanical) problem.

Also... If there is a way for this script to be written to have minimal delay, that would be great.

Thanks for taking your time to help me.

Share this post


Link to post
Share on other sites
Kidney

put a sleep inbetween the send's. i would put a Sleep(100) but you could try less.

Share this post


Link to post
Share on other sites
randomGuy

That doesn't help me. The script needs to be instant.

Share this post


Link to post
Share on other sites
water

Is this just to excercise or do you need to solve a real problem?

Looks a bit weird to press these 4 keys at the same time.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
randomGuy

It's for a video game. The video game has a move that can only be performed by pushing three buttons at once.

An earlier version of the game had a built-in macro function, but for some reason, the newer version, doesn't.

That's why I need this.

Share this post


Link to post
Share on other sites
Belini
randomGuy

Yes, I know that. But this game has no rules against using scripting. In fact, like I said, one version of the game has the macro built-in, but the other one doesn't, because it's a compact, stripped-down version, so it has no additional options whatsoever (not even for changing the default controls).

So I'm not breaking any rules.

Share this post


Link to post
Share on other sites
water

The rule that doesn't allow to discuss game automation is the forum rule (not the rules of the game).

That's the rule Mods are quite strict here.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Leomund

This is a Macro, not an Automation from what I've deduced.

(Now I'm curious what he's doing to the .dll)

Edited by Leomund

Share this post


Link to post
Share on other sites
water

It's Automation. Call it Macro or whatever.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Leomund

I think you're wrong about that; I don't think hotkeys are automation.

Anyway, RandomGuy, what are you doing? So I can make hotkeys with AutoIt and stuff..?

Share this post


Link to post
Share on other sites
water

(Nearly) everything game related that automates keystrokes by an AutoIt script (using HotKeys or whatever) is "game automation".

There are very few game related automation topics which didn't get locked by the Mods.

Search the forum for locked topics and you'll see what I'm talking about.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Valik

Just because you are stupid and don't understand lingo and terminology does not mean you get to bypass the rules.

Thread locked. Do not argue with me or post on this subject again or you will go away.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×