A thank you and a Hotkey Script

Which race do you like most? What do you like - what you don't like? Discuss it here.
posted on January 24th, 2011, 3:34 am
Last edited by d4m on January 24th, 2011, 8:21 pm, edited 1 time in total.
Love this mod.  I can finally play this game again on my Win7 machine w/o having to do all the VirtualBox stuff and having to run in a window, etc.

My one big critique is the hotkey system.  Very clunky and doesn't function completely, so.. I fixed it in a round about way.

I wrote a script for autohotkey which hotkeys every, every button in the game and simplifies it to a pattern scheme.

It uses the left side of the keyboard only.  Basically, Q is the 1st button for any ship or station.  W is the 2nd, E 3rd, ... T 5th, A the 6th ... G the 10th, Z the 11th, and so on to V the 14th button, assuming all the buttons only appear on a single row.  If it goes to 2 rows, which I haven't seen yet since I've only been playing this mod for maybe 3 hours, it wont work on that higher row, or lower, which ever direction it expands to.

The script moves the mouse to the location of the button, regardless of your resolution (it calculates mouse position on the fly using your screen resolution) clicks the button and then returns to the mouse to its previous location near instantly, maybe 1ms might pass. Very quick.  It overshadows any other normal hot keys which use Q-T, A-G, Z-V which means trying to type into a text window will be next to impossible.  Luckily, the script can be toggled on or off with Ctrl-Alt-A and it give you some beeps to indicate which state it is in.  1 beep for on, 2 beeps for off.  Additionally, the script will only execute if Armada II Fleet Ops is the top window so if you alt-tab or something or forget to end the script, it wonder hinder any other program.

I give the code openly so you can see there is nothing sinister in this.  Please feel free to use it and let me know if there are any issues you run into. 

Thanks again for making this mod.

Key Pattern
Image


Just copy and paste this code into a .ahk file and double click to execute once you have autohotkey installed.  Remember, the script begins in the off state.
Code: Select all
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance, Force
suspend

;;================GLOBALS====================

;;BUTTON LOCATIONS
;;button locations are done on a 0-1 and then scaled to the
;;global width and height parameters of the resolution being used
;;Button placements
;;q
X_q := 0.25
Y_q := 0.82
;;w
X_w := 0.30
Y_w := 0.82
;;e
X_e := 0.36
Y_e := 0.82
;;r
X_r := 0.41
Y_r := 0.82
;;t
X_t := 0.47
Y_t := 0.82
;;a
X_a := 0.52
Y_a := 0.82
;;s
X_s := 0.58
Y_s := 0.82
;;d
X_d := 0.63
Y_d := 0.82
;;f
X_f := 0.68
Y_f := 0.82
;;g
X_g := 0.74
Y_g := 0.82
;;z
X_z := 0.80
Y_z := 0.82
;;x
X_x := 0.85
Y_x := 0.82
;;c
X_c := 0.91
Y_c := 0.82
;;v
X_v := 0.96
Y_v := 0.82

;; END BUTTON LOCATIONS

;;global for screen dimensions
width := 0
height := 0

;;Mouse pixel position Vars
oldX := 0
oldY := 0

newX := 0
newY := 0
;;================END GLOBALS===================

;;=========Functions

;;Plays a single beep when the script is activated
;;Plays 2 beeps when deactivated
PlayActivationTone()
{
   if not (A_IsSuspended)
   {
      SoundPlay *-1
   }   
      else
   {
      SoundPlay *-1
      sleep 200
      SoundPlay *-1
   }
   return
}

;;THis function move the mouse to the calculated mouse position and clikcs it
PressButton()
{
   newX := X_%A_ThisHotkey% * A_ScreenWidth
   newY := Y_%A_ThisHotkey% * A_ScreenHeight
   MouseGetPos, oldX, oldY
   MouseMove, newX, newY, 0
   Send {Lbutton}
   MouseMove, oldX, oldY, 0
   return
}

;;HOTKEY ACTIVATIONS
;activate with ctrl-alt-a
;1 ping = ON
;2 pings = OFF
^!a::  ;ctrl-alt a
Suspend, Toggle
PlayActivationTone()
return

#IfWinActive, Star Trek Armada II Fleet Operations
{
   ;;for ingame chat
   ~*Enter::
   Suspend, Toggle
   PlayActivationTone()
   return

   ;;Hokey Assignments
   q::PressButton()
   w::PressButton()
   e::PressButton()
   r::PressButton()
   t::PressButton()
   a::PressButton()
   s::PressButton()
   d::PressButton()
   f::PressButton()
   g::PressButton()
   z::PressButton()
   x::PressButton()
   c::PressButton()
   v::PressButton()
}
posted on January 24th, 2011, 10:10 am
Just want to say, wow that is impressive :)

By the way, might be cool to make Enter the toggle, since enter brings up the chat window, which people do use a lot in online games.
posted on January 24th, 2011, 11:56 am
nice work mate. and welcome to the forums :)
posted on January 24th, 2011, 12:17 pm
Last edited by d4m on January 24th, 2011, 8:09 pm, edited 1 time in total.
Unleash Mayhem wrote:Just want to say, wow that is impressive :)

By the way, might be cool to make Enter the toggle, since enter brings up the chat window, which people do use a lot in online games.


Now that is a great idea.

[edit]Enter key activation added.  If someone who is 16:9 could try this and let me know would appreciate it.
Reply

Who is online

Users browsing this forum: No registered users and 23 guests

cron