Jump to content

Recognizing if key is pressed


Recommended Posts

Question, i want to write a little bind key program my problem is how to recognize if a certain key is pressed... anyone got an idea on how to do this, just need the recognizing key command thx

;recognize keystroke here

;this is where it enters the text

Send("{ENTER}")

Send(enter text here)

Send("{ENTER}")

Link to comment
Share on other sites

Question, i want to write a little bind key program my problem is how to recognize if a certain key is pressed... anyone got an idea on how to do this, just need the recognizing key command thx

;recognize keystroke here

;this is where it enters the text

Send("{ENTER}")

Send(enter text here)

Send("{ENTER}")

<{POST_SNAPBACK}>

bind key programs can use

_ispressed() ... or _ifispressed()

this is a special function you will have to search the archices for

IF I RUN IN TO IT I WILL POST IT HERE LATER

good luck 8)

Found it here

http://www.autoitscript.com/forum/index.ph...l=_IsPressed()#

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

how would this hotkeyset work ? ill try the other method mentioned above and researc the "hotkeyset" command but let me know...

thx

EDIT1: Hmm i tried the first methode with the shex key but i couldnt figure it out i think some advanced skills are needed :( which i dont posess ima check in on this hotkeyset

thx guys

EDIT2: Alright i tried the hotkeyset which seems to work for me now which is cool thx for that now atleast when i press a numberbutton it presses enter and gets ready to type stuff... the problem is it then doesnt type any thing?!? check my code and tell me whats wrong

;notice when button pressed

HotKeySet("{NUMPAD1}", "testenter")

While 1
Sleep(1)
WEnd

;pressing enter to type text

Func testenter()
Send("{ENTER}")
Send("testing")
Send("{ENTER}")
Endfunc

thx

Edited by rellik88
Link to comment
Share on other sites

;notice when button pressed

HotKeySet("{NUMPAD1}", "testenter")

While 1
Sleep(1)
WEnd

;pressing enter to type text

Func testenter()
WinActivate("Untitled - Notepad");<<<<<<<<<<
WinWaitActive("Untitled - Notepad");<<<<<<<<<<
Send("{ENTER}")
Send("testing")
Send("{ENTER}")
Endfunc
When testing your scripts, you might want to send the info to a specific window... one that is simple and ready to accept what you send to it.

Start the code above

Start Notepad

Press numpad1

This might be what is happening to you with your original code:

Your script sends "Enter" to some application to get it ready to accept text

The application is getting ready......

Your script sends "testing" ... but your application is not ready to accept it yet

Your script sends "Enter" ... but your application is not ready to accept it yet

Your application is now ready to accept the text... bummer.

You might have to add a sleep statement between those two lines of code or find another way to know that the application is ready to take the text. Either way, you might want to call the window into focus before sending keys to it.

[size="1"][font="Arial"].[u].[/u][/font][/size]

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