Factorio
AutoHotkey script for scrollin the screen with mouse
NOTE: This is mostly for sandbox mode, where you don't have a unit/guy.

If interested, a bit of background info and discussion in a thread I started few days ago:
Can you play this with mouse only?



In short, this is used for scrolling the screen without using WASD.
Scrolling happens when you move your mouse cursor to the edges of the screen

https://youtu.be/0OOoYM5677M
(Video makes the scrolling look a bit choppy. It's smooth ingame)

At the moment it doesn't have diagonal scrolling, but it shouldn't be too hard to add it if needed.
I don't find it necessary yet, but with bigger builds it might become exactly that.

All of this is done with AutoHotkey script. AHK is a really powerful tool that can be used in many ways, but with gamers it's used a lot for different macros, toggles, rapid fire, etc.
In this case it tracks your mouse and when the cursor is near the edge (distance in pixels can be customised) it will simulate pressing a corresponding key; top of the screen "W", left "A"...

I can't take the credit for the script though. As I was looking in to it, two fine gentlemen (thank you Xtra and Exaskryz) on AHK forums pretty much did all the work. See thread here[autohotkey.com]


There are two ways to use the script:

1. You can install https://autohotkey.com/ and run the script[puu.sh].
(If you don't want to download the script, you can create a blank one an copy/paste the code below)

2. You can run the scrip as a standalone exe[puu.sh].
(AHK allowes you to create exe from a script)

There are few things you can adjust in the script. See the info text within the script for details.

#NoEnv #Persistent CoordMode, Mouse, Screen ; If you are running the game on 2nd monitor use Window instead of Screen SetKeyDelay, 20, 50 E:= 15 ; Size of the triggering edge in pixels W:= A_ScreenWidth H:= A_ScreenHeight T:= "w" ; Keys triggered by the screen edges B:= "s" L:= "a" R:= "d" SetTimer, EdgeCheck, 10 ; Cursor position check interval in ms. In case of performance hit, up it to 50. EdgeCheck: MouseGetPos, X, Y If ((flag="top") && (Y<=E)) || ((flag="bottom") && (Y>=H-E)) || ((flag="left") && (X<=E)) || ((flag="right") && (X>=W-E)) return If (flag="top") && (Y>E) Send {%T% up} If (flag="bottom") && (Y<H-E) Send {%B% up} If (flag="left") && (X>E) Send {%L% up} If (flag="right") && (X<W-E) Send {%R% up} If (E<X && X<W-E) && (E<Y && Y<H-E) { flag:="" return } else if (Y<=E) { flag:="top" Send {%T% down} } else if (Y>=H-E) { flag:="bottom" Send {%B% down} } else if (X<=E) { flag:="left" Send {%L% down} } else { flag:="right" Send {%R% down} } return f12:: ; Hotkey to pause the script Pause Suspend return
Автор останньої редакції: VonAntero; 27 берез. 2016 о 15:58
< >
Показані коментарі 13 із 3
I didn't know you could move the camera independently of the player character?
Цитата допису Game Over, Man:
I didn't know you could move the camera independently of the player character?
No, this is mainly for sandbox mode where you don't have the character.
What the scrip does is it presses w, a, s or d when your mouse cursor is at the corresponding edge of the screen.
If you would use this in the normal mode, the character would move.
Improved version by me with corners and only working inside the game:
Spanish comments.


#NoEnv #Persistent #IfWinActive, ahk_class ALEX ; Factorio NOMBRE ~LButton:: ~RButton:: ~MButton:: ~Space:: ~Up:: ~Down:: ~Left:: ~Right:: ~Enter:: ~Tab:: ~q:: ~w:: ~e:: ~r:: ~t:: ~y:: ~u:: ~i:: ~o:: ~p:: ~a:: ~s:: ~d:: ~f:: ~g:: ~h:: ~j:: ~k:: ~l:: ~ñ:: ~z:: ~x:: ~c:: ~v:: ~b:: ~n:: CoordMode, Mouse, Screen ; If you are running the game on 2nd monitor use Window instead of Screen SetKeyDelay, 20, 50 E:= 5 ; Size of the triggering edge in pixels (No tiene que estar justo sobre el margen) W:= A_ScreenWidth H:= A_ScreenHeight Top := "w" ; Keys triggered by the screen edges Bottom := "s" Left := "a" Right := "d" SetTimer, EdgeCheck, 50 ; Cursor position check interval in ms. In case of performance hit, up it to 50. return EdgeCheck: IfWinNotActive, ahk_class ALEX { SetTimer, EdgeCheck, Off return } MouseGetPos, X, Y ;~ ToolTip, %Flag% ; ########################################### ; ####### SE ESTA BIEN, NO HACER NADA ####### ; ########################################### ; (Y<=E) = Y por arriba del Margen superior ; (Y>=H-E) = Y por abajo del Margen inferior ; (X<=E) = X por izquierda del Margen izquierdo ; (X>=W-E) = X por derecha del Margen derecho ; ||||||||||||||||||||||||||||||||| ; (X>=E) = X por derecha del Margen izquierdo ; (Y>=E) = Y por arriba del Margen superior ; (Y>=H-E) = Y por arriba del Margen inferior ; ||||||||||||||||||||||||||||||||| If ((flag="top") && (Y<=E) && (X>=E) && (X<=H-E)) || ((flag="bottom") && (Y>=H-E) && (X>=E) && (X<=W-E)) || ((flag="left") && (X<=E) && (Y>=E) && (Y<=H-E)) || ((flag="right") && (X>=W-E) && (Y>=E) && (Y<=H-E)) || ((flag="topleft") && (Y<=E) && (X<=E)) || ((flag="bottomleft") && (Y>=H-E) && (X<=E)) || ((flag="topright") && (Y<=E) && (X>=W-E)) || ((flag="bottomright") && (Y>=H-E) && (X>=W-E)) return ; ##################### ; ####### PAROS ####### ; ##################### If (flag="top") && (Y>E) ; O sea que la Posición Y está más abajo que la E | La Posición X mayor que la E { Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} } If (flag="bottom") && (Y<H-E) ; La posición de Y es menor que la (total altura - su margen) { Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} } If (flag="left") && (X>E) ; O sea que la Posición X está más a la derecha que la E { Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} } If (flag="right") && (X<W-E) ; La posición de X es menor que la (total anchura - su margen) { Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} } If (flag="topleft") && (Y>E) && (X>E) ; Estar por fuera de los margenes { Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} } If (flag="bottomleft") && (Y<H-E) && (X>E) ; Estar por fuera de los margenes { Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} } If (flag="topright") && (Y>E) && (X<W-E) ; Estar por fuera de los margenes { Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} } If (flag="bottomright") && (Y<H-E) && (X<W-E) ; Estar por fuera de los margenes { Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} } ; ||||||||||||||||||||||||||||||||| ; E>X = Que está fuera del Margen ; X<W-E = Que está fuera del Margen ; ||||||||||||||||||||||||||||||||| ; E>Y = Que está fuera del Margen ; Y<H-E = Que está fuera del Margen ; ||||||||||||||||||||||||||||||||| If (E<X && X<W-E) && (E<Y && Y<H-E) ; Esto siempre Igual { flag:="" return } ; ##################### ; ####### SENDS ####### ; ##################### else if ((Y<=E) and (X<=E)) ; La Posición Y es menor que el Margen | Posición X Menor que el Margen || O sea que está en la esquina TOP LEFT { flag:="topleft" Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} Send {%Top% down} Send {%Left% down} } else if ((Y<=E) and (X>=W-E)) ; En el Margen Sup Derecho { flag:="topright" Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} Send {%Top% down} Send {%Right% down} } else if ((Y>=H-E) and (X<=E)) ; La Posición Y está por debajo del margen inferior | Posición X Menor que el Margen || O sea que está en la esquina BOTTOM LEFT { flag:="bottomleft" Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} Send {%Bottom% down} Send {%Left% down} } else if ((Y>=H-E) and (X>=W-E)) ; En el Margen Inf Derecho { flag:="bottomright" Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} Send {%Bottom% down} Send {%Right% down} } else if ((Y<=E) and (X>=E) and (X<=W-E)) ; La Posición Y es menor que el Margen | Posición X Mayor que el Margen Izquierdo y Menor que el Derecho || O sea que no está en la esquina .TOP LEFT ni TOP RIGHT. { flag:="top" Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} Send {%Top% down} } else if ((Y>=H-E) and (X>=E) and (X<=W-E)) ; La Posición Y es mayor que la (total altura - su margen) | Posición X Mayor que el Margen Izquierdo y Menor que el Derecho || O sea que no está en la esquina .TOP LEFT ni TOP RIGHT. { flag:="bottom" Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} Send {%Bottom% down} } else if ((X<=E) and (Y>=E) and (Y<=H-E)) ; La Posición X es menor que el Margen | Posición Y por abajo del Margen superior y por arriba del margen inferior || O sea que no está en la esquina .TOP LEFT ni BOTTOM LEFT. { flag:="left" Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} Send {%Left% down} } else if (X>=W-E) and (Y>=E) and (Y<=H-E) ; La Posición X es mayor que la (total anchura - su margen) | Posición Y por abajo del Margen superior y por arriba del margen inferior | O sea que no está en la esquina .TOP RIGHT ni BOTTOM RIGHT. { flag:="right" Send {%Top% up} Send {%Bottom% up} Send {%Left% up} Send {%Right% up} Send {%Right% down} } return #If F2::ExitApp
Автор останньої редакції: Pinkfloydd8; 28 січ. 2017 о 12:20
< >
Показані коментарі 13 із 3
На сторінку: 1530 50

Опубліковано: 27 берез. 2016 о 15:18
Дописів: 3