Jump to content

Action on pressing a key


vkey
 Share

Recommended Posts

Hi, I try to let the programm Autoit do something, when I press a key.

For example, when I press the 1, I want the programm to do the following:

MouseClick("left", 550, 332, 1)

MouseClick("left", 550, 375, 1)

I red something in the FAQ, but there was only an example about when a key is held down. So, can someone please help me and make a simple script of it? That would be great!

Link to comment
Share on other sites

Well, I also looked at the helpfile about hotkeys. ;)

But, I do not know what I have to put in place of "TogglePause" (See example) when I want Autoit to click somewhere.

HotKeySet("{ENTER}", "TogglePause")

Link to comment
Share on other sites

I modified the example from the helpfile, maybe this help you understand?

; Press Esc to terminate script

HotKeySet("{ESC}", "Terminate")
HotKeySet("1", "PressMouseButtons") ;First parameter is the button and second which function that should be run when pressed

;;;; Body of program would go here;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func Terminate()
    Exit
EndFunc

Func PressMouseButtons()
    MouseClick("left", 550, 332, 1)
    MouseClick("left", 550, 375, 1)
EndFunc
Link to comment
Share on other sites

I modified the example from the helpfile, maybe this help you understand?

; Press Esc to terminate script

HotKeySet("{ESC}", "Terminate")
HotKeySet("1", "PressMouseButtons");First parameter is the button and second which function that should be run when pressed

;;;; Body of program would go here;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func Terminate()
    Exit
EndFunc

Func PressMouseButtons()
    MouseClick("left", 550, 332, 1)
    MouseClick("left", 550, 375, 1)
EndFunc
Oke, thanks, I'll try this. But I didn't knew what the function was called for clicking the mouse buttons. ;)
Link to comment
Share on other sites

Oke, thanks, I'll try this. But I didn't knew what the function was called for clicking the mouse buttons. :D

I don't understand what you mean there, you had your MouseClick() on your first post so how can you now don't know the function?? ;)

Or are you mixing things up with the HotKeySet()?? It can point to any function you have created yourself!

O, and one more question. How can I make more mouseclickfunctions, with each a different hotkey?

Like, when I press 1 click here and when I press 2 click there...

Simplest would be to copy+paste the HotKeySet() a bunch of times and create 1 func for each. It maybe wouldn't look the best but would be fully okay for a noobie.
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...