Thought I'd share my ahk scripts for morrowind

Not about OpenMW? Just about Morrowind in general? Have some random babble? Kindly direct it here.
Post Reply
redtmpusr
Posts: 1
Joined: 01 Jul 2019, 04:25

Thought I'd share my ahk scripts for morrowind

Post by redtmpusr »

This assigns hotkeys for common mouse intensive actions that I can't live without anymore. Dialogue clicking, dragndrop, etc.
Please make suggestions or corrections and I will update the thread if people end up finding this useful.

Features:
1) home key pauses the script
2) Shift click on any item will instantly send it to the container, or instantly send it from container to inventory. This is big one for me, like moving lots of books from inventory to storage, not having to go back and forth with mouse.
3) Z key changes map from local to world and world to local. This is big because when exploring, finding entrances on local map is easy, while world map gives location barrings.
4) C key is take all from container, I use this only in early game when I am opening and taking all alchemy ingredients. In a new town, there are 100+ crates and bags to open one by one.
5) X key presses ok dialogue, useful when buying or selling a stack, and automatically taking all.

They, of course, might feel silly for the first 30 min or so, then become very handy.

Code: Select all

; simple helper scripts to assign hotkeys to save mouse movements

takeall_x := 1654
takeall_y := 946

okay_x := 874 
okay_y := 628

map_mode_x := 1802 
map_mode_y := 881

drag_n_drop_destination_x := 1295
drag_n_drop_destination_y := 831


; presses takeall diaglogue when you click on stack of items. set the ui takeall button position, it is in the container box.
c::
 {
   mouseclick, left, %takeall_x%, %takeall_y%, 1, 0
 }
return


; press okay diaglogue. set ui ok button position
X::
 {
   mousegetpos, start_x, start_y
   mouseclick, left, %okay_x%, %okay_y%, 1, 0
   mousemove, %start_x%, %start_y%, 0
 }
return


; toggle map local / world. set toggle ui button position
z::
 {
   mousegetpos, start_x, start_y
   mouseclick, left, %map_mode_x%, %map_mode_y%, 1, 0
   mousemove, %start_x%, %start_y%, 0
 }
return


; drap and drop from current mouse position ( your item stack ) to the container box. Set container box destination position
<+LButton::
  {
    mousegetpos, start_x, start_y
	SetDefaultMouseSpeed, 0 ; Move the mouse instantly.
	Send +{Click start_x, start_y}
	Sleep 15
	Send {Click, %drag_n_drop_destination_x%, %drag_n_drop_destination_y%}
    mousemove, %start_x%, %start_y%, 0
  }
return

; pause script with home key
home::Suspend, Toggle

Here is demented's display mouse position script from the ahk forum. This will be needed for making the destination x and y positions work for you. The tooltip of x and y that shows up in the top left of the screen will not show up in game. So position your mouse in game, and alt+tab out, then record that position.

Code: Select all

; !!!
; demented made this
; https://autohotkey.com/board/topic/80205-display-mouse-coordinates-and-copy-them-if-needed/


#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.

#Warn ; Recommended for catching common errors.

SendMode Input ; Recommended for new scripts due to its superior speed and reliability.

SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.



; While CapsLock is toggled On

; Script will display Mouse Position (coordinates) as a tooltip at Top-Left corner of screen.

; Also allows to copy them (to clipboard) with a PrintScreen button.



#SingleInstance force ; only one instance of script can run



#Persistent ; to make it run indefinitely

settimer start1, 0 ; "0" to make it update position instantly

return



start1:

if !GetKeyState("capslock","T") ; whether capslock is on or off

 {

 tooltip ; if off, don't show tooltip at all.

 }

 else

 { ; if on

 CoordMode, ToolTip, Screen ; makes tooltip to appear at position, relative to screen.

 CoordMode, Mouse, Screen ; makes mouse coordinates to be relative to screen.

 MouseGetPos xx, yy ; get mouse x and y position, store as %xx% and %yy%

 tooltip %xx% %yy%, 0, 0 ; display tooltip of %xx% %yy% at coordinates x0 y0.

 PrintScreen:: ; assign new function to PrintScreen. If pressed...

 clipboard == %xx% %yy% ; ...store %xx% %yy% to clipboard.

 return

 }

return

**EDIT:
Was inspired to update dragndrop to detect cursor position, and either dragndrop from container to inventory, or inventory to container. It assumes move full stack in all versions for now

V2

Code: Select all

; openmw user "redtmpusr"
; simple helper scripts to assign hotkeys to save mouse movements

SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#SingleInstance force ; only one instance of script can run
#Persistent ; to make it run indefinitely

takeall_x := 1654
takeall_y := 946

okay_x := 874 
okay_y := 628

map_mode_x := 1802 
map_mode_y := 881

drag_n_drop_container_destination_x := 1295
drag_n_drop_container_destination_y := 831

drag_n_drop_inventory_destination_x := 1100
drag_n_drop_inventory_destination_y := 912

dividing_line_between_inventory_and_container := 1174 ;731


; presses takeall diaglogue when you click on stack of items. set the ui takeall button position, it is in the container box.
c::
 {
   mouseclick, left, %takeall_x%, %takeall_y%, 1, 0
 }
return


; press okay diaglogue. set ui ok button position
X::
 {
   mousegetpos, start_x, start_y
   mouseclick, left, %okay_x%, %okay_y%, 1, 0
   mousemove, %start_x%, %start_y%, 0
 }
return


; toggle map local / world. set toggle ui button position
z::
 {
   mousegetpos, start_x, start_y
   mouseclick, left, %map_mode_x%, %map_mode_y%, 1, 0
   mousemove, %start_x%, %start_y%, 0
 }
return


; drap and drop from current mouse position ( your item stack ) to the container box. Set container box destination position
<+LButton::
  {
	SetDefaultMouseSpeed, 0 ; Move the mouse instantly.
	; if it is in first 3 quarts of screen, move item from inventory to container. If cursor is in last quarter of screen, move item from container to inventory
    mousegetpos, start_x, start_y
	if start_x < %dividing_line_between_inventory_and_container%
	{
		Send +{Click start_x, start_y}
		Sleep 15
		Send {Click,%drag_n_drop_container_destination_x%, %drag_n_drop_container_destination_y%}
		mousemove, %start_x%, %start_y%, 0
	}
	else if start_x > %dividing_line_between_inventory_and_container%
	{
		Send +{Click start_x, start_y}
		Sleep 15
		Send {Click,%drag_n_drop_inventory_destination_x%, %drag_n_drop_inventory_destination_y%}
		mousemove, %start_x%, %start_y%, 0
	}
  }
return

; pause script with home key
home::Suspend, Toggle
Post Reply