Log in

View Full Version : Keyboard Hotkey set to do a Mouse Click Action - Autohotkey



ichybon
10-22-2007, 01:10 AM
Hi, I am trying to use Autohotkey and set up a script that would make a keyboard key do a mouse click to a minimized window.
EX: Clicking on a characters portrait.

The only thing that I have found was this:

#IfWinActive World of Warcraft
~LButton::
CoordMode, Mouse, Relative
MouseGetPos, x, y
ControlClick, X%x% Y%y%, ahk_id %wowid2%
ControlClick, X%x% Y%y%, ahk_id %wowid3%
return

#IfWinActive World of Warcraft
~RButton::
CoordMode, Mouse, Relative
MouseGetPos, x, y
ControlClick, X%x% Y%y%, ahk_id %wowid2%,, R
ControlClick, X%x% Y%y%, ahk_id %wowid3%,, R
return

But that does every coordinate on both screens, and I just want to set a keyboard key to send the mouse click to just the one.
What do you guys think?
I will continue to mess around with the script and do more endless forum searches in the mean time :shock:

jdraughn
10-22-2007, 01:30 AM
So you want to use a keyboard instead of a mouse to initate the clicking?
Replace "~LButton" with whatever key you want to use. And since your not getting your click values from your current mouse cursor position, you have to specify where they are manually. You could also simply replace the "~LButton" with your hotkey, but still use the mouse cursor position to position the cursor on the other screens.

I don't know whats up with the X%x%, that to me means there are two x values, when there is only one X and Y. I just realized, one X% and the other x% are simply relative and fixed mouse positions. Still not exactly sure how it works. The script code for AHK is incredibly cryptic to me.

Asking on the AHK forums will you get you a much more knowledgable and probably better answer then asking on here.

But anyway, your new code would look something like this:

[code:1]
~F1::
ControlClick, 200 300, ahk_id %wowid2%
ControlClick, 200 300, ahk_id %wowid3%
return
[/code:1]

ichybon
10-22-2007, 01:35 AM
Thanks for the reply, really helped me out to know the difference between ControlSend & ControlClick :D
It ended up looking like this when I was done
ControlClick,x112 y255, ahk_id %idClone%, , LEFT

Had trouble figuring out where to put the "LEFT or RIGHT" in the script but I figured it out :) "Leaving it blank defaults it to a left click"

Lost Ninja
10-22-2007, 09:03 AM
Would it be possible to do a ctrl+alt+left click sends it to other screens? (or some variation of that)

Djarid
10-22-2007, 11:05 AM
potentially yes... I haven't looked at this but there should be no reason why...

^!LBUTTON::


shouldn't work