[UTILITY] SM Helper - current ver 1.10, new features

Discuss all things Battleships Forever that aren't Ships and Shipmaker - Missions, Development, etc.!

Moderators: th15, Moderators

Kaelis
Moderator
Posts: 1590
Joined: Fri Dec 14, 2007 4:46 am

[UTILITY] SM Helper - current ver 1.10, new features

Post by Kaelis »

Hey there folks, anyone remember me? Im still lurking around, checking what ships people make.

Ive recently seen an increase in activity here, saw quite a few good ships/fleets and good builders. Always nice to see BSF shipbuilding isnt dead, despite lack of game development.

Also recently, ive discovered Autohotkey. Its a macro player/recorder with its own high-level scripting language, which turned out to be quite powerful. So, without much thinking, i decided to write a few hopefuly helpful scripts that recreate some of the features SM Alternative was supposed to have. A few hours of coding, and this is what i have.





INSTALLATION AND RUNNING:

First off, youll need the Autohotkey executable. Download it from here:
http://www.autohotkey.com/download/

Now download my script:
http://www.autohotkey.net/~Kaelis/SMHelper1.10.rar

Install Autohotkey, then extract SBHelper.rar. It has two .ahk files and a colors.txt file, they all need to be in the same directory.

To start SM Helper, simply double-click on SMHelper.ahk. You can terminate it by either closing the window or right-clicking the icon in tray menu (white H on green background) and choosing 'Exit'.


OVERVIEW:

Screenshot:
Image

Features:
- Nudging pieces by specified amount of pixels with a single mouse click or key combination
- Mirroring one piece around another
- Changing custom color of pieces with a single mouse click or key
- Several alterable color fields to use for color changing, with hotkeys and saving


USAGE INSTRUCTIONS:

* Moving:

You can nudge selected piece by amount of pixels (offset) specified with +/- buttons in Move Mode. To do this, use the combination of windows key+movement arrow. So if offset is 10 and you press Win+Left arrow, selected piece will move 10 pixels to the left.

You can also go into move mode by pressing Up/Down/Left/Right button or by using [ (left square bracket key)+ movement arrow combination. This allows you to move pieces in specified direction with a single left click, without the need to select it first. To exit out of move mode, press space.

There are two methods for moving: Edit, the default one, moves pieces by going into the edit tab of shipmaker and changing x/y coordinates there. Second one, Keys, simply simulates keystrokes (shift+arrow), but is limited in number of pixels to move - itll always move by 10, disregarding current offset setting.

While in move mode (or color mode), do not experiment; don't try to do anything other than clicking on pieces to move them/change their colors, because you may experience some unexpected behaviour. If you need to do something else (especially with mouse), simply exit out of relevant mode.

* Mirroring:

SMHelper has an ability to mirror piece A around piece B, using piece C as parent. To do this, first select the piece you want mirrored and press , (comma), this will mark it for mirroring. Next, select a piece you want to mirror around and press . (dot), this will mark it as mirror center. Now just select a piece you want to be a parent for the new mirrored piece, and press / (slash) in order to perform the mirroring. You can also select the mirror point first, and mirroring target after that, the order doesn't matter.

* Changing color:

By pressing ' (apostrophe key) you can change the custom color of selected piece to the color thats currently active. You can also use windows key + left mouse button to change the color of a piece thats under mouse cursor.

To go into Color Mode, press the corresponding button or ] (right square bracket key). In color mode, you change piece colors by simply clicking on them. To exit out of color mode, press space or ].

To switch active colors, first press numeric dot/del key to toggle color hotkeys on, then press corresponding numeric key to activate that color. Five stars in color field will indacate currently selected color. You will now 'paint' with that color. You can also use - (minus/underscore) and = (equals/plus) keys to cycle through active colors.

To change colors, click on their corresponding buttons. The default starting colors are defined in colors.txt file.

* Other hotkeys:

~ (tilde key) suspends (toggles off) all hotkeys except alt+r. Tray icon will change from H to S to indicate that hotkeys are currently suspended.

Alt+r reloads the script. Due to the nature of macros, sometimes they can get messed, lock up, etc. Should this happen, try reloading the script (note that colors will revert to their defaults, reloading is just like closing and running it again).






There you go. Hope someone can benefit from it.

You can post your ideas/requests, ill see what i can do. Id also be happy to help with explaining/modifying my script.
Last edited by Kaelis on Mon Jan 26, 2009 9:19 am, edited 9 times in total.
BoVinE
Commodore
Commodore
Posts: 603
Joined: Fri Jan 18, 2008 2:37 am

Post by BoVinE »

I am required by law to love you now.
Venator
Captain
Captain
Posts: 423
Joined: Sun Feb 10, 2008 12:07 pm

Post by Venator »

You, sir, are awesome.

I'll try this out shortly.
[url=http://www.wyrdysm.com/phpBB2/viewtopic.php?t=2921][img]http://i30.photobucket.com/albums/c348/DraTuicichNovae/AESig.png[/img][/url]
BoVinE
Commodore
Commodore
Posts: 603
Joined: Fri Jan 18, 2008 2:37 am

Post by BoVinE »

For some reason none of the controls are working. Is there any order to which needs to be powered up?

I can't switch out of color mode, switch the active color, or get switch colors of parts using it. Am I just missing something?
Kaelis
Moderator
Posts: 1590
Joined: Fri Dec 14, 2007 4:46 am

Post by Kaelis »

Im assuming youve read the instructions.

Do this: Run the shipmaker, then run SMHelper. In shipmaker, make a new section and select it. Now press win+up or ' (apostrophe key). Tell me what happens.

Mind you, it probably doesn't work on Vista.
Wolfbrother
Lieutenant Commander
Lieutenant Commander
Posts: 69
Joined: Sat Apr 19, 2008 7:23 am

Post by Wolfbrother »

When I turn on the colour mode it locks the mouse so using the left mouse button does right clicking on anything but the shipmaker and in the ship maker it makes me continuosly build my current weapon selection. I see alot of potential in this though and if this can be solved it'd be great.

I use Windows XP by the way.
Kaelis
Moderator
Posts: 1590
Joined: Fri Dec 14, 2007 4:46 am

Post by Kaelis »

Wolfbrother wrote:When I turn on the colour mode it locks the mouse so using the left mouse button does right clicking on anything but the shipmaker and in the ship maker it makes me continuosly build my current weapon selection. I see alot of potential in this though and if this can be solved it'd be great.
The color mod scripts works by right clicking where mouse is, then sending 7 and 2 to open the custom color dialog. Thats pretty simple and straightforward. So i have no idea what could go wrong. Im not sure if i understand what you wrote correctly, but it seems it isnt sending the right click for some reason, but i don't know of any way to fix that. Ive tested the script extensively on three different computers, so its probably specific to your system.

One thing could try is to open SMHelper.ahk, search for a line that says 'Lbutton::', and then increase variable in 'Sleep, 5' line (a few lines down from 'Lbutton::').
Kaelis
Moderator
Posts: 1590
Joined: Fri Dec 14, 2007 4:46 am

Post by Kaelis »

(sorry for double post but i wanted to keep this clean)

I have modified the script so that it is easy to change/add/remove the hotkeys (new download in op).

Modifying hotkeys:
Open SMHelper.ahk with text editor of your choice. Navigate to the HOTKEYS part of the script. It should look like this:

Code: Select all

;#########################################################
;### 									HOTKEYS                ###
;#########################################################

`::Suspend

!r::
	Suspend, Permit
	Reload
return

NumpadDot::
Gosub, HColorHotkeys
return

Space::
Gosub, HModeExit
return

...
These are the hotkey bindings.



Syntax for bindings:
[hotkey]::
Gosub, [function]
return

Where, surprisingly, hotkey is a key, button or a combination of these, and function is a function that the selected hotkey will invoke. For example:

#LButton::
Gosub, HMButtonChangeColor
return

# means Win key. HMButtonChangeColor is a function that will change the color of a piece under mouse pointer, so pressing Win + Left mouse button will execute this function.

Keys:
To combine key/button with a modifier key (alt, ctrl, shift or win) use these tokens:
# - Win
! - Alt
^ - Control
+ - Shift
Like so: #UP - Win key + up arrow movement key.

To combine two normal (non-modifier) keys/buttons, use & (ampersand), like so: '[ & UP'. Thats left square bracket key plus up movement key.
The names of the letter and number keys are the same as that single letter or digit. For example: b is the "b" key and 5 is the "5" key.

Some other keys/buttons:


LButton
RButton
MButton
Space - the spacebar
Tab
Enter (or Return)
Escape (or Esc)
Backspace (or BS)

Delete (or Del)
Insert (or Ins)
Home
End
PgUp
PgDn
Up
Down
Left
Right

ScrollLock
CapsLock
NumLock

Numlock ON
Numpad0
Numpad1
Numpad2
Numpad3
Numpad4
Numpad5
Numpad6
Numpad7
Numpad8
Numpad9
NumpadDot (.)
NumpadDiv (/)
NumpadMult (*)
NumpadAdd (+)
NumpadSub (-)
NumpadEnter

Numlock OFF
NumpadIns
NumpadEnd
NumpadDown
NumpadPgDn
NumpadLeft
NumpadClear
NumpadRight
NumpadHome
NumpadPgUp
NumpadDel
NumpadUp
NumpadDiv (/)
NumpadMult (*)
NumpadAdd (+)
NumpadSub (-)
NumpadEnter


Additional info in autohotkey help file.

Note that some keys are taken and cannot be changed, namely the numpad color keys, the ~ (tilde key) and the alt+r hotkey.


Functions:
HColorHotkeys - toggle color (numpad) hotkeys for switching active colors
HColorAUp, HColorADown - cycle through active colors
HModeExit - exit color/move mode
HColorMode - toggle color mode
HUpMode, HDownMode, HLeftMode, HRightMode - enter move modes
HUpMove, HDownMove, HLeftMove, HRightMove - nudge section by specified offset
HMButtonChangeColor - change color of a piece under mouse cursor
HotkeyChangeColor - change color of selected piece
Last edited by Kaelis on Sat Jul 26, 2008 6:10 am, edited 1 time in total.
Kaelis
Moderator
Posts: 1590
Joined: Fri Dec 14, 2007 4:46 am

Post by Kaelis »

No comments, no ideas? Come on guys, give me some feedback. It would help to keep the thread up top, so that newcomers will see it, too.
Wolfbrother
Lieutenant Commander
Lieutenant Commander
Posts: 69
Joined: Sat Apr 19, 2008 7:23 am

Post by Wolfbrother »

Not very easy to get used to but excellent help. Could do with a read-me included or something
TheBlueEcho
Vice Admiral
Vice Admiral
Posts: 1435
Joined: Tue Dec 04, 2007 7:31 am

Post by TheBlueEcho »

I mostly like it for the move function, that is helpful in itself.

But I couldn't get the coloring to work. I turned on SM, then Helper, moved some pieces left/right, but the colors, it seems like all it wants to do is open up the Custom color picker, instead of auto coloring the piece I click on.
antisocialmunky
Vice Admiral
Vice Admiral
Posts: 1032
Joined: Wed Jan 30, 2008 8:22 am

Post by antisocialmunky »

Someone should sticky this.
Don’t worry it has airbags.
Kaelis
Moderator
Posts: 1590
Joined: Fri Dec 14, 2007 4:46 am

Post by Kaelis »

NEW VERSION - 1.03
Fixed (hopefully) issues with color changing, although color mode might still be broken depending on os/configuration.
Added two new hotkeys and relevant functions : you can use - (minus/underscore) and = (equals/plus) keys to cycle through active colors. The functions are HColorAUp and HColorADown.


Wolfbrother wrote:Not very easy to get used to but excellent help.
Do you have any suggestions how to make it 'easier' ?
Wolfbrother wrote:Could do with a read-me included or something
Included instructions in the download.
TheBlueEcho wrote:But I couldn't get the coloring to work. I turned on SM, then Helper, moved some pieces left/right, but the colors, it seems like all it wants to do is open up the Custom color picker, instead of auto coloring the piece I click on.
I think ive fixed it, at least changing colors with ' and win+lmbutton. Still not sure, don't have enough testers, but anyone who had problems with color changing should try the new version.
BoVinE
Commodore
Commodore
Posts: 603
Joined: Fri Jan 18, 2008 2:37 am

Post by BoVinE »

You know all the problems I've found, and it works great for my purposes now.

One thing I wanted to tell people is, if you open the SMHelper.ahk, you can edit the options that appear as

Code: Select all

c1r := 114
c1g := 114
c1b := 192

c2r := 87
c2g := 87
c2b := 181

c3r := 77
c3g := 77
c3b := 176

c4r := 65
c4g := 65
c4b := 146

c5r := 56
c5g := 56
c5b := 127

c6r := 0
c6g := 10
c6b := 91

c7r := 0
c7g := 16
c7b := 164

c8r := 255
c8g := 255
c8b := 255

c9r := 4
c9g := 4
c9b := 4

c10r := 123
c10g := 123
c10b := 123
[/size]

These are the color codes for the startup colors, and by changing the values (RGB, clealy) you can save the colors you want.

Note that this does not change the color of the icon, but still works with the color change. I believe the display color is controlled by these lines:

Code: Select all

Gui, Add, Text, vTXT1 HwndTX1ID x11 y350 w40 h26 +Center,
Control_Colors("TXT1", "Set", 0x000000, 0xFFFFFF) 
Gui, Add, Text, vTXT2 HwndTX2ID x61 y350 w40 h26 +Center,
Control_Colors("TXT2", "Set", 0xFFFFFF, 0x000000) 
Gui, Add, Text, vTXT3 HwndTX3ID x111 y350 w40 h26 +Center,
Control_Colors("TXT3", "Set", 0x0000FF, 0xFFFF00) 
Gui, Add, Text, vTXT4 HwndTX4ID x11 y280 w40 h26 +Center,
Control_Colors("TXT4", "Set", 0x00FFFF, 0xFF0000) 
Gui, Add, Text, vTXT5 HwndTX5ID x61 y280 w40 h26 +Center,
Control_Colors("TXT5", "Set", 0x00FF00, 0xFF00FF) 
Gui, Add, Text, vTXT6 HwndTX6ID x111 y280 w40 h26 +Center,
Control_Colors("TXT6", "Set", 0xFFFF00, 0x0000FF) 
Gui, Add, Text, vTXT7 HwndTX7ID x11 y210 w40 h26 +Center,
Control_Colors("TXT7", "Set", 0xFF0000, 0x00FFFF) 
Gui, Add, Text, vTXT8 HwndTX8ID x61 y210 w40 h26 +Center,
Control_Colors("TXT8", "Set", 0xFF00FF, 0x00FF00) 
Gui, Add, Text, vTXT9 HwndTX9ID x111 y210 w40 h26 +Center,
Control_Colors("TXT9", "Set", 0x000000, 0xFFFFFF) 
Gui, Add, Text, vTXT10 HwndTX10ID x11 y420 w40 h26 +Center,
Control_Colors("TXT10", "Set", 0x000000, 0xFFFFFF)
[/size]
These are the codes for the buttons that are the colors you choose. They go in order of 1-10, and the hexadecimal value define the color it displays, while the second defines the color of the stars when that color is highlighted (usually the inverse color).

The codes for theses are 0xRRGGBB, using the characters 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. A-F represent 10-15. The number you choose is the multiple of the two characters in that section.
0xFFFFFF is 15x15, making 255 255 255 the RGB code, or white.

To convert your RGB codes, use this website http://www.javascripter.net/faq/rgbtohex.htm
copy this into the right area, keeping the 0x------ in the area (i.e. take 0xFFFFFF and past the code given to you over the FFFFFF).
This next step is important.
Take the last two characters of the 6 characters, and switch them with the first. This is because SMH reads hex not as RGB, but instead as BGR.
now save the file, and reload the script.

Adding buttons will be covered later, along with screenshots.
Last edited by BoVinE on Sat Jul 26, 2008 8:59 am, edited 1 time in total.
Forgetting internet deadlines since 2003
Wolfbrother
Lieutenant Commander
Lieutenant Commander
Posts: 69
Joined: Sat Apr 19, 2008 7:23 am

Post by Wolfbrother »

I have no real suggestions in how to make it easier just due to the problems being inherent with a macro although those instructions go a long way to making it easier to understand. Only having problems changing the colours along the pallette i.e. default is 1 I want to swap to 2 but using the instructions it doesn't work, althoug knowing me I just haven't read them right as others don't seem to have a problem.
Post Reply