Jump to content

Help with key bindings


Recommended Posts

I'm new to autoit and havent been able to find how to run a script inside of another program. I would like to bind it to some key on my keyboard F5 for example I'd like to be able to press F5 and have the script run. If this is possible please tell me how

If the program you are using is an AutoIt program you can use HotKeySet. Failing that you could write a script to start the program and still use HotKeySet.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

i still cant get it to work like i said im new to autoit so you need to treat me like an idiot

here is the script i have basically all i want it to do is shoot 3 times EXTREMELY fast with a semi-auto shotgun

; ----------------------------------------------------------------------------

;

; AutoIt Version: 3.1.0

; Author: A.N.Other <myemail@nowhere.com>

;

; Script Function:

; Template AutoIt script.

;HotKeySet ( "V" )

; ----------------------------------------------------------------------------

; Script Start - Add your code below here

MouseClick ( "left" )

Sleep (150)

MouseClick ( "Left" )

Sleep (150)

MouseClick ( "left" )

Link to comment
Share on other sites

well thats not what you asked before but...

Hotkeyset( "v", "Shoot") ;HotKey(v) to perform Function "Shoot"

Func Shoot() ;Starts Function "Shoot" for HotKey 
    $pos = MouseGetPos() ;Sets a Variable for $Pos making it Equal to what the current mouse postion is.
    MouseClick("Left", $pos[0], $pos[1], 3) ;Clicks the Current Mouse positon 3 times which reading the help files says that the return value for MouseGetPos() is the VariableName($pos) with [0] for X and [1] for Y.
EndFunc ;Ends Function
 
While 1 ;Starts a loop
    Sleep(100) ;Sleeps(This is to keep autoit running)
Wend ;End loop

First off you should get scite and Beta... then open the help file in scite... thats all you would need for something this simple.

Second you must know that anything that follows a ; is comment or inother words is not use autoit will skip over and thing after a ; (on each line)

So ;HotKeySet("v") was not only roung but would do nothing...

Edited by lopolop
Link to comment
Share on other sites

Still not working. Dont I need a Send/ControlSend command in there somewhere to make it run INSIDE the program. If the window I want it to run in is "BF2 (v1.1.2551.0, pid: 1756)" where do i put this in my script to make it run in the program and do i use Send or ControlSend

Link to comment
Share on other sites

Not too sure if this is what you're looking for, but someone helped me before so I'll give you an example of what I have.

When you press Divide on the Numpad it will say "Hey, it is working!"

When you press the Escape key, it will quit the script.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

AutoItSetOption ( "SendKeyDelay", 0 ) ; The key delay 0 = instant, 1 = fastest

HotKeySet("{ESC}", "Terminate")

HotKeySet("{NUMPADDIV}", "one")

While 1

Sleep(100)

WEnd

Func Terminate()

Exit 0

EndFunc

Func one()

Send("Hey, it is working!", 1)

EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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