Jump to content

Press a key and get message?


Recommended Posts

Hi,

I wanna make a simple program if I pressed the 'D' key here, the program sends me information about that:

#include <GUIConstants.au3>
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3>
#include <Misc.au3>


#include <GUIConstants.au3>
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3>
#include <Misc.au3>

$button = InputBox("abc" ,"Write","")
If  _IsPressed("44") Then
    MsgBox(0,'a',"Press x key")

 ConsoleWrite("X")
EndIf

Thank you in adance your help

Link to comment
Share on other sites

  • Developers
1 minute ago, DannyJ said:

Thank you in adance your help

Help on what as you haven't described what your problem is? ;) 

Guess the program ends right away as you have no loop in there?

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

34 minutes ago, Jos said:

Help on what as you haven't described what your problem is? ;) 

Guess the program ends right away as you have no loop in there?

Jos

My problem is that when I press the button no MsgBox appears.
For example, I wanna make a button with: Press D to continue.

If it is pressed MsgBox appears . 

 

Link to comment
Share on other sites

  • Developers
1 minute ago, DannyJ said:

How to make it run?

What do you mean by this question? I assume you know how to Run a script .... right?
Just add logic in the script to keep it running and do this by adding a loop .....  something like While...Wend (check in the helpfile.)

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'll feed you the fish 🙂

 

#include <Misc.au3>
#include <MsgBoxConstants.au3>
;Opt("SendKeyDelay", 0)
Local $hDLL = DllOpen("user32.dll")

While 1
    If _IsPressed("44", $hDLL) Then
        MsgBox(0,'a',"Press x key")
        ExitLoop
    EndIf
    Sleep(25)
WEnd
DllClose($hDLL)

 

Edited by Xenobiologist

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