• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

unmerged(497946)

Second Lieutenant
1 Badges
May 29, 2012
122
0
  • A Game of Dwarves
The basics:
Autohotkey is a script-driven piece of software that intercepts input like key presses or mouse clicks and sends the recipient... something else.

To use such a script:
Install Autohotkey (duh), copy the spoilered text into a text file and rename it to [somename].ahk
Then you can run it with a double click.

I wrote the script so that it is limited to windows that have "A Game of Dwarves" in the title so yes, it affects this forum, too. =)


Level - changing is now mapped to mouse buttons 4 + 5 as well as CTRL-Mousewheel.
Still haven't decided which way I like best so I tried both.

CTRL - Left mouse Button = autofire. For selling all that lumber.

#IfWinActive, A Game of Dwarves,

;--------------------------------------
;Mouse buttons 4 + 5 change levels
XButton2::
Send, r
return

XButton1::
Send, f
return


;--------------------------------------
;Shift-Mousewheel changes levels
^WheelDown::
Send, r
;Send,{SHIFTUP}r{SHIFTDOWN}
return

^WheelUp::
Send, f
;Send,{SHIFTUP}f{SHIFTDOWN}
return


;--------------------------------------
; CTRL - LButton... autofire.
^LButton::
GetKeyState, StateMLeft, LButton, P
if StateMLeft = U
return

; MLeft IS pressed
Send, {SHIFTDOWN}
MouseClick, left
Loop
{
Sleep 5
GetKeyState, StateMLeft, LButton, P
if StateMLeft = U
{
Send, {SHIFTUP}
break
}
MouseClick, left
}
Send, {SHIFTUP}
return



Alternative script: Mousewheel changes levels, CTRL-Mousewheel zooms in and out.
I find myself using the level change a lot... zooming only when the engine makes things artificially tricky to target.

#IfWinActive, A Game of Dwarves,

;--------------------------------------
;Mouse buttons 4 + 5 change levels
XButton2::
Send, r
return

XButton1::
Send, f
return


;--------------------------------------
;CTRL-Mousewheel zooms, regular Mousewheel changes levels
WheelDown::
Send, r
return

WheelUp::
Send, f
return

^WheelDown::
Click WheelDown
return

^WheelUp::
Click WheelUp
return


;--------------------------------------
; CTRL - LButton... autofire.
^LButton::
GetKeyState, StateMLeft, LButton, P
if StateMLeft = U
return

; MLeft IS pressed
Send, {SHIFTDOWN}
MouseClick, left
Loop
{
Sleep 5
GetKeyState, StateMLeft, LButton, P
if StateMLeft = U
{
Send, {SHIFTUP}
break
}
MouseClick, left
}
Send, {SHIFTUP}
return



And if the movement direction seems backwards... too bad. I'm a mouse-Y-inverter. =P

PS: This is no cheat of any kind. It only presses keys that you could press... if you didn't rather press mouse buttons instead.
 
Last edited:
This is awesome. Thanks for posting this and I will be giving it a try.
:)

Edit: After just a quick test - both the level change and the "auto fire" work real nice.
I will reserve judgment on system overhead, ease in actual game play, etc, etc for a latter time.
 
Last edited:
Hmm, that program looks quite useful for something else I'm trying to do. Do you know if it can send hotkey commands to windows that are not active (Minimised)? I have two monitors, and I like to play games on one and watch videos on the second. However the annoying thing is if I ever need to pause the video on monitor 2 I need to alt tab my game, pause the video, and alt tab back into my game. Some games this works really badly and can crash the game because of bad alt tab coding. Some games I run fullscreen windowed which makes things easier but yeah, I want to just hit a button on my keyboard without leaving the game.
 
AHK can "set focus" to a particular window.
I don't know if this brings the window to the foreground, which you obviously want to avoid. =)

Search / ask in the AHK forum. I can do some scripting with it but I don't use it often enough to really dig in.


@ Xerkis
System overhead is trivial. AHK only reacts to input events so most of the time it's dormant.
While it can do some timing and persistent loops (which can eat noticeable resources), it's awkward and inaccurate at that because that's not what it was written for.
It really sucks for trying to do something like writing an active bot for a game but it's excellent for doing reactive... stuff. =)
You could, for instance, hotkey certain building elements that you use often.
Say, CTRL-B to open the build menu and select the wooden block for building. There is a macro recorder which can record your exact mouse movements. For the most part, the real limit is your own imagination...


I still can't decide whether I like the level change better on the mouse wheel or buttons 4+5. I use the buttons when I need to go down exactly 1 or 2 levels but for scrolling waaaaay up and down, the wheel is very fast. =)
 
Last edited:
So far, I'm really liking the scroll level changing. Works very nice. The autofire is a bit too fast though and you can sell too much. Is there a way to slow it down a bit? Not much though.

And what you are saying about recording a build mouse movement. . . . I'm thinking ladders for sure. I will have to give that a try next.
This is a very nice tool. this kind of thing should be implimented in to aGoD.

Thanks again for posting this.
 
I have autohotkey around somewhere. The scroll to change levels sounds like a great idea.
 
While I prefer the zoom effect the mousewheel currently has (especially as mine isn't normally "locked" and can spin freely) I can certainly see how a CTRL or similar modifier to make the mousewheel change floors would be useful - built in of course.
 
I hardly ever use the zoom function.
Only when I can't "hit" some tile because the engine bugs and the thing I'm targeting is hidden by an invisible wall or something. Then it's time to rotate and zoom around...

As a result, I switched the mousewheel functions to change level by default.
Much better. =)