Jump to content

Auto Hotkey Help


12 replies to this topic

#1 Winterwolf

    Member

  • Pip
  • Ace Of Spades
  • Ace Of Spades
  • 19 posts

Posted 22 September 2013 - 09:55 AM

I am trying to write a simple script for autohotkey to display some pointer to our clan. The problem is I can't convince MWO to pass any input events to autohotkey. I tried 32 and 64 bit versions of autohotkey as well as running in administrator mode. I am currently using Win8 (I know, I know, it came with the machine :) ).

The script I am using:

#InstallMouseHook
#InstallKeybdHook

Numpad6::
{
Send t
Sleep 50
Send Greetings from Clan Foo, http://bar.enjin.com/home
Sleep 50
Send {Enter}
}
return

Any suggestions would be appreciative
--WW

#2 kuangmk11

    Member

  • PipPipPipPipPipPipPip
  • Veteran Founder
  • Veteran Founder
  • 627 posts
  • LocationW-SEA, Cascadia

Posted 22 September 2013 - 07:40 PM

Try this:

Numpad6::
{
send, {t}
sleep, 25
SendRaw Greetings from Clan Foo, http://bar.enjin.com/home
sleep, 25
Send, {Enter}
}
return

Edited by kuangmk11, 22 September 2013 - 07:42 PM.


#3 Winterwolf

    Member

  • Pip
  • Ace Of Spades
  • Ace Of Spades
  • 19 posts

Posted 23 September 2013 - 07:48 AM

Thx for the reply. I tried it and still no luck with MWO (even though it works in other apps like TS or notepad). Not sure if there is anything else I can do to force autohotkey to intercept the keystrokes?

Thx
--WW

#4 RadioKies

    Member

  • PipPipPipPipPipPip
  • The 1 Percent
  • The 1 Percent
  • 419 posts
  • LocationThe Netherlands

Posted 23 September 2013 - 11:56 AM

Oh great, just what we need, more spam at the beginning of the match. Here's a solution: Try deleting your system32.

If only people used these things for quickshouts like "lights go to theta", "Enemy lance spotted at lower city", "Return to base, nobody is going back and I'm too slow" or something like that.

#5 Sharp Spikes

    Member

  • PipPipPipPipPipPip
  • 208 posts
  • LocationSochi, Russia

Posted 23 September 2013 - 12:21 PM

Convert script to executable and run it with administrative privileges. Maybe it'll help.

#6 kuangmk11

    Member

  • PipPipPipPipPipPipPip
  • Veteran Founder
  • Veteran Founder
  • 627 posts
  • LocationW-SEA, Cascadia

Posted 23 September 2013 - 12:51 PM

View PostRadioKies, on 23 September 2013 - 11:56 AM, said:

Oh great, just what we need, more spam at the beginning of the match. Here's a solution: Try deleting your system32.

If only people used these things for quickshouts like "lights go to theta", "Enemy lance spotted at lower city", "Return to base, nobody is going back and I'm too slow" or something like that.

I do.
http://pastebin.com/3uHPUKER

#7 RadioKies

    Member

  • PipPipPipPipPipPip
  • The 1 Percent
  • The 1 Percent
  • 419 posts
  • LocationThe Netherlands

Posted 23 September 2013 - 03:22 PM

View Postkuangmk11, on 23 September 2013 - 12:51 PM, said:



Dude, awesome, thats the usefull stuff I wished people would use (and was integrated in MWO).

#8 kuangmk11

    Member

  • PipPipPipPipPipPipPip
  • Veteran Founder
  • Veteran Founder
  • 627 posts
  • LocationW-SEA, Cascadia

Posted 23 September 2013 - 05:18 PM

View PostWinterwolf, on 23 September 2013 - 07:48 AM, said:

Thx for the reply. I tried it and still no luck with MWO (even though it works in other apps like TS or notepad). Not sure if there is anything else I can do to force autohotkey to intercept the keystrokes? Thx --WW


I looked into it a little. The problem I found is that I had to use the scan code for numpad6 to get it to register in the game. if you bind your chat key to something like F5 you can use it in the beginning and end "lobbys" without it putting the 't' in front of the message.

try this:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Recommended for catching common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance Force
#InstallKeybdHook
SC04D::
{
BlockInput, On
SetCapsLockState, off
send, {t}
sleep, 25
SendRaw Hello World http://mwomercs.com/forums
sleep, 25
Send, {Enter}
BlockInput, Off
}
return


#9 Winterwolf

    Member

  • Pip
  • Ace Of Spades
  • Ace Of Spades
  • 19 posts

Posted 23 September 2013 - 06:02 PM

Thx that finally worked!

#10 Lucas the Bounty Hunter

    Member

  • PipPip
  • Overlord
  • Overlord
  • 33 posts
  • LocationNorthwestern Ontario, Canada

Posted 24 November 2013 - 05:27 PM

Hi all,
Looking for some help with an Autohotkey key-bind.
I'm trying to get the WheelLeft/WheelRight buttons (left and right tilt on my scroll-wheel) to work in MWO to fire weapon groups 5 and 6. Below is what I've got so far:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
________

#InstallMouseHook
#InstallKeyBDHook

#IfWinActive MechWarrior Online

SetKeyDelay, 0
WheelLeft::Send {5 down}
Sleep, 0
Send {5 up}
return


WheelRight::6

_______

Both options work and fire the desired weapon-groups, but both also cause the weapon to keep firing as if the 5/6 button were being held down. Also, if I hit 5 or 6 while the weapon is constant-firing, the firing stops and the script seems to reset (pressing the WheelLeft/WheelRight again doesn't have any effect). Is that clear and understandable? It might work fine for a TAG toggle, but not for missiles or a backup alpha. I have tried a few fixes, but have had no luck. Anyone have any ideas?

#11 evilC

    Member

  • PipPipPipPipPipPipPipPip
  • Legendary Founder
  • Legendary Founder
  • 1,298 posts
  • LocationLondon, UK

Posted 05 December 2013 - 03:52 AM

The quirk is with MWO - It will not fire unless the key is held for 50ms

I recommend the following lines in your code:

SendMode, Event
SetKeyDelay, 0, 50

You should then not need to send the down, sleep then send the up.

Also, when declaring hotkeys in AHK, you should probably prefix them thus:

*WheelLeft::
Send {5}
return

The * tells the hotkey to work in any combination, so if holding it in combination with other keys, it would still fire.

I have no idea what the point of a Sleep 0 is, maybe it sleeps indefinitely. That could be the source of weirdness in your code.

With regards to a chat macro, I have already written one and posted it on GitHub.

It uses my ADHD macro writing library, which makes writing AHK macros with a GUI very easy.

#12 evilC

    Member

  • PipPipPipPipPipPipPipPip
  • Legendary Founder
  • Legendary Founder
  • 1,298 posts
  • LocationLondon, UK

Posted 05 December 2013 - 04:02 AM

Oh, and I forgot. Do not try and hook into the up event for the mouse wheel actions as they do not exist.

WheelLeft up::
; this code will never fire.
return
Also:

Also, this code is probably not doing what you think it is:

SetKeyDelay, 0
WheelLeft::Send {5 down}
Sleep, 0
Send {5 up}
return

the line "WheelLeft::Send {5 down}" is bad.
When you declare the binding on one line like that, that is the hotkey.
The rest of the lines (Sleep, 0 etc) are not part of the hotkey!

instead you would want:

SetKeyDelay, 0
WheelLeft::
Send {5 down}
Sleep, 0
Send {5 up}
return

Which, as I mentioned before, should be this anyway:

SetKeyDelay, 0, 50
*WheelLeft::
Send {5}
return

Edited by evilC, 05 December 2013 - 04:05 AM.


#13 Lucas the Bounty Hunter

    Member

  • PipPip
  • Overlord
  • Overlord
  • 33 posts
  • LocationNorthwestern Ontario, Canada

Posted 06 December 2013 - 12:33 PM

EvilC, you are a genius. Here is the final product, and yes it works:
___
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.


#InstallMouseHook
#InstallKeyBDHook

#IfWinActive MechWarrior Online

SendMode, Event
SetKeyDelay, 0, 50

*WheelLeft::
Send {6}
return

*WheelRight::
Send {5}
return
___

I now have weapon groups 5 and 6 on my mouse where they belong, perfect for a last-ditch alpha or for LRMs. Thanks for the help.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users