Jump to content

While a button is pressed


Recommended Posts

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.

Link to comment
Share on other sites

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 (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

It's Automation. Call it Macro or whatever.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

(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 (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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.

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...