Keybinding Script

Started by tornado, May 06, 2017, 10:22:58 AM

Previous topic - Next topic

tornado

Note:I put it here because here seems most appropriate. if this needs to be moved, go right ahead.

Back when the CW anniversary editions came out I went off and wrote a script for the unit buttons.
since .AHK files are not supported as attachments were is the code:

+1::6
+2::7
+3::8
+4::9
+5::0


This is written in Autohotjey, so if you aren't aware of it go look it up.
I made this because I am lazy, and don't want to move my hand off the left half of the keyboard to press the unit buttons.
simply put, pressing 1-5 acts normally. pressing Shift 1-5 pressed the button five numbers along(and for you programmers out there, yes i tried to make it do that, but its big and clunky and has too many exceptions[ what if it tires to add five to the key L or something?]).
I put this up here for a few reasons: the main one being: If i find this so handy, wouldn't other people?
the only major downsides is that you can't easily turn it off, without halting the program in the Task manager.
However, this is in beta. I am working on this(adding an Off button of some kind, re-binding the speed up/slow down/pause options, and adding a Techs button[because apparently CW1 doesn't come with a Techs shortcut, so i have to code that manually]).

I'm rambling a bit here, but if you find this useful(or happen to improve it somehow) do say.
If you have any questions, feel free to ask.

-tornado.
PS:this is not a request to retroactively apply Keybinding options to CW1. im having fun with this.
Now CEO of Particular Endeavors. http://knucklecracker.com/forums/index.php?topic=23752.new#new
We apologize for all inconveniences that we caused.
Quotefirst, you have to imagine a very big box, fitting inside a very samll box.
then, you have to build one

tornado

Code


+1::6
+2::7
+3::8
+4::9
+5::0

;note, this currently doesnt work. no error of any kind, just fails.
t::

{
MouseGetPos, currentMouseX, currentMouseY
Click 1064, 1015
MouseMove, currentMouseX, currentMouseY, 0
return
}

+End::ExitApp

[close]
Update:
Added ability to quite program without using TM(Shift+End by default)
Added techs button(In dev, report back if it doesn't work).

now that thats done i think i might go make one for CW2.
Now CEO of Particular Endeavors. http://knucklecracker.com/forums/index.php?topic=23752.new#new
We apologize for all inconveniences that we caused.
Quotefirst, you have to imagine a very big box, fitting inside a very samll box.
then, you have to build one

tornado

#2
Code


;the code that handles 1-5=6-0
+1::6
+2::7
+3::8
+4::9
+5::0

;some extra code for my conviniece. comented out.
;z::Up
;c::Down
;w::p

;techs button.
t::
{
MouseGetPos, currentMouseX, currentMouseY
;MouseClick L, 1060, 1064
Click 1060, 1064
MouseMove, currentMouseX, currentMouseY, 0
return
}

;the exit key. Shift+End by default.
+End::ExitApp

[close]

chnagelog:
-modified techs button to also click the Continue button at the end of a map.
-added a few personal keybinds for my playstyle(disabled by default)

this is pretty much as far as it is going.
for references to the code see:
https://autohotkey.com/docs/AutoHotkey.htm

-tornado
Now CEO of Particular Endeavors. http://knucklecracker.com/forums/index.php?topic=23752.new#new
We apologize for all inconveniences that we caused.
Quotefirst, you have to imagine a very big box, fitting inside a very samll box.
then, you have to build one

tornado

Minor request to anyone out there:
if you could happen to get me the pixel sizes for the various units it would be much appreciated,
Now CEO of Particular Endeavors. http://knucklecracker.com/forums/index.php?topic=23752.new#new
We apologize for all inconveniences that we caused.
Quotefirst, you have to imagine a very big box, fitting inside a very samll box.
then, you have to build one

Karsten75

Quote from: tornado on May 07, 2017, 09:18:54 AM
Minor request to anyone out there:
if you could happen to get me the pixel sizes for the various units it would be much appreciated,

For which game? They ae mostly a few standard sizes in each game. the full images are on the wiki (mostly, I think) for each game and you should be able to get the pixel sizes from there.

tornado

#5
Hadn't though of that. I was actually going to set up a test level in the editor to i could see how large one pixel of terrain was on my monitor, then fiddle with those numbers a bit- the end goal being can I make it place certain units in a certain configuration(if i ever had the spare time).
also, I only ever planned on making this for CW1. CW2 has 6 weapons and systems, but has keys for swapping, so I'm will to move my hand to reach. CW3 has control customization(which I never got around to using), and PF does have keybindings, although admittedly some really strange ones(why would i ever want to set a waypoint? And why does it only work for omnis?). the most I might do is set some ship selection buttons, though the last time i counted there were 24 slots. This literally started out as a bodge for me to be lazy, I've just been adding to it because.

edit:turns out there are no given sizes on the wiki. makes sense give the size/position would change on different resolutions(mines 192081080, which probably changes a few things. also, due to the ubiquity of CW flash games(Such as Evermore, Training Sim, and User Space) which therefore have the button in different places, I'm trying to change the code that clicks on the upgrade button to instead click on the first thing it finds that is the right color(305030). this may come back to bite me later).

Edit:Ok, sorry. it seemed obvious to me that I was referring to CW1. also, this currently only works for CW1 in fullscreen. not for the flash games. sorry.
Now CEO of Particular Endeavors. http://knucklecracker.com/forums/index.php?topic=23752.new#new
We apologize for all inconveniences that we caused.
Quotefirst, you have to imagine a very big box, fitting inside a very samll box.
then, you have to build one