Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Mouse Movement to Keypress


  • Please log in to reply
49 replies to this topic
Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012
Babba... I feel a little dumb now! hahaha
I didn't have the joystick in the scene at first so I kept thinking of the mouse doing the job... If the joystick in Michi's wheelchair is like any other then this is surely a better aproach for him. I don't know if that's the same case for Oby, though...

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


strobo
  • Members
  • 359 posts
  • Last active: Mar 10 2015 08:13 PM
  • Joined: 19 Jun 2012

Absolutely no reason for feeling this or that wayicon_razz.gif

As you noted already, this approach depends on hardware. Maybe, we'll see whether it applies at all.


Regards,
Babba

Michigraf
  • Members
  • 9 posts
  • Last active: Nov 28 2014 05:30 PM
  • Joined: 11 Dec 2012
@pulover big thanks for the script. i test it. edit: it works very good thanks again!
 
the joystick is a special one. i dont have the char until january. but i know that i get a bluetooth to mouse module: here a link: http://www.pgdt.com/...bluetooth.html 
so you need to take the bluetooth signal and convert it to key presses (or better as gaming joystick). but i talk first to my vendor.


Oby
  • Members
  • 11 posts
  • Last active: Jan 31 2013 04:52 PM
  • Joined: 10 Dec 2012

Babba... I feel a little dumb now! hahaha
I didn't have the joystick in the scene at first so I kept thinking of the mouse doing the job... If the joystick in Michi's wheelchair is like any other then this is surely a better aproach for him. I don't know if that's the same case for Oby, though...

 

I am in the same case as michigraf and I have a little the same system. 

With the stickmode it is better.
For me the option of the mouse deactivates during the sending of touch would be useful. 
It is not as well fluid as the joystick truth especially for angles but it is a habit to take.

@babba I had seen this script, but the computer considers its as a mouse and not as a joystick



Pulover
  • Members
  • 1596 posts
  • Last active: Apr 06 2016 04:00 AM
  • Joined: 20 Apr 2012

>> @babba I had seen this script, but the computer considers its as a mouse and not as a joystick


Then we can forget the joystick script...

I'm experimenting something with a mouse hook but I need to know if BlockInput will work for this device. Can you test it please?

; F1 should block mouse movements.
F1::
BlockInput, % (Block := !Block) ? "MouseMove" : "MouseMoveOff"
return

Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer) | Class_LV_Rows - Copy, Cut, Paste and Drag ListViews | Class_Toolbar - Create and modify | Class_Rebar - Adjustable GUI controls

Join the New AutoHotkey Forum!


Oby
  • Members
  • 11 posts
  • Last active: Jan 31 2013 04:52 PM
  • Joined: 10 Dec 2012

Yes that blocks well the mouse. I threw the other script at the same time that also block the sending of touche



strobo
  • Members
  • 359 posts
  • Last active: Mar 10 2015 08:13 PM
  • Joined: 19 Jun 2012

The following script should send wasd (easy to modify) and block the cursor:

Spoiler

TheGoods AHKHID.ahk must be saved to the same directory as the script. The next spoiler contains it:

Spoiler

Regards,
Babba

Oby
  • Members
  • 11 posts
  • Last active: Jan 31 2013 04:52 PM
  • Joined: 10 Dec 2012

It is the similar that blocks everything



cml091872
  • Members
  • 2 posts
  • Last active: Dec 24 2012 10:08 PM
  • Joined: 19 Dec 2012

I too am interested in using the WASD keys on my keyboard to move forward, backward, turn left, turn right and using r-click on the mouse to view camera only with mouse.

I believe one of the scripts above in this forum allow that to happen. Am I correct?

If so, could you please just offer a small step-by-step of what I need to do to get this working for my gameplay in Skyrim as well.

Sorry, if I need little hand-holding here but never used scripts to alter gameplay. Only mods.

So, do I copy something to notepad and put it in a folder in Skyrim, etc.?

What do I copy and what folder do I place it in, etc?

Please help! And thank you very much, if you do, for taking the time to help me here.



strobo
  • Members
  • 359 posts
  • Last active: Mar 10 2015 08:13 PM
  • Joined: 19 Jun 2012

@Oby: Really? Does it block spam and popups?:) I'm not familiar with TheGoods AHKHID.ahk, but someone who is, probably can disentangle the devices (getting the right ids etc...).

@cml091872: These scripts do not what you are after. The basics of using AHK can be found in

http://www.autohotkey.com/docs/


Regards,
Babba

Oby
  • Members
  • 11 posts
  • Last active: Jan 31 2013 04:52 PM
  • Joined: 10 Dec 2012

@babba I put well both scripts in the same file. But I know not so it is necessary to give to them a specific name.

 

Otherwise I would like to keep the script of pulover which walks well. 
I would just want that the cursor does not move while it sends up, down, left and right. 
And I do not think of managing to modify him myself.

Sorry if my explanations are not very clear



strobo
  • Members
  • 359 posts
  • Last active: Mar 10 2015 08:13 PM
  • Joined: 19 Jun 2012

Now, only one script is left over and the arrow keys are chosen. Control+t toggles the behavior. If the keys are reliably (enough for your applications) sent, we can fit the script for your needs.

Spoiler

Regards,
Babba

Oby
  • Members
  • 11 posts
  • Last active: Jan 31 2013 04:52 PM
  • Joined: 10 Dec 2012


 

;==========================================================================
;
; 				MouseSendZones
;
; Author:		Pulover [Rodolfo U. Batista]
;				rodolfoub@gmail.com
;
; HoverMode:	The script sends user-defined keys when the mouse is
;				over an area of the screen by creating a rectangle at
;				the center to be the Dead Zone and 8 other rectangles
;				around it, each one will send and hold the configured
;				keys when the mouse hovers over it.
;
; StickMode:	When the mouse is moved in one direction the script
;				sends the corresponding keys and releases them when
;				it stops moving. This is more specific for using a
;				joystick to control mouse movements.
;
;==========================================================================

; ########## Configurations: ##########

; Select Hotkey to active HoverMode:
Hover = F1

; Select Hotkey to active StickMode:
Stick = F2

; Select Hotkey show Zones Guidelcines:
ShowZones = CapsLock

; Select optional Hotkey reset mouse to Center:
Center = MButton

; Set Horizontal & Vertical Dead Zone Ranges in pixels:
DeadZoneRangeX := 200
DeadZoneRangeY := 150

KeySet =
( ; Set the keys that will be sent for each of the eight zones of the screen:
Up = Up
Down = Down
Left = Left
Right = Right
UpLeft = Up & Left
UpRight = Up & Right
DownLeft = Down & Left
DownRight = Down & Right
)

; ########## End of configurations! ##########

; Parse KeySet and assign variables to the keys:
Loop, Parse, KeySet, `n
{
	Loop, Parse, A_LoopField, =, %A_Space%
		If Mod(A_Index, 2)
			Key := A_LoopField
		Else
		{
			%Key% := A_LoopField
			StringSplit, %Key%, A_LoopField, &, %A_Space%
		}
}

#SingleInstance, Force
SendMode, Input
SetKeyDelay, -1
SetMouseDelay, -1
SetBatchLines, -1
CoordMode, Mouse, Screen

; Get coordinates for the center of the screen to create a Dead Zone:
DeadZoneX := A_ScreenWidth / 2
DeadZoneY := A_ScreenHeight / 2

; Activate Hotkeys:
Hotkey, %Hover%, Hover, On
Hotkey, %Stick%, Stick, On
Hotkey, %ShowZones%, ShowZones, On
Try Hotkey, %Center%, CenterMouse, On

; Create a rectangle to show Dead Zone:
A := DeadZoneRangeX*2, B := DeadZoneRangeY*2, C := A-2, D := B-2

Gui, -Caption +ToolWindow +LastFound +AlwaysOnTop
Gui, Color, Red
Gui, +LastFound
WinSet, Region, 0-0 %A%-0 %A%-%B% 0-%B% 0-0  2-2 %C%-2 %C%-%D% 2-%D% 2-2
GoSub, ShowZones
Display := !Display
SetTimer, RemoveTip, -1500
return

Hover:
StickMode := False
SetTimer, WatchMouse, % (HoverMode := !HoverMode) ? 0 : "Off"
Loop, % %hKeys%0
	Send, %  (hKeys = "DeadZone") ? "" : "{" %hKeys%%A_Index% " up}"
TrayTip,, % (HoverMode) ? "HoverMode On" : "HoverMode Off"
return

Stick:
HoverMode := False
SetTimer, WatchMouse, % (StickMode := !StickMode) ? 0 : "Off"
Loop, % %hKeys%0
	Send, %  (hKeys = "DeadZone") ? "" : "{" %hKeys%%A_Index% " up}"
TrayTip,, % (StickMode) ? "StickMode On" : "StickMode Off"
return

ShowZones:
If (Display := !Display)
{
	Gui, Show, % "NA x" DeadZoneX - DeadZoneRangeX "y" DeadZoneY - DeadZoneRangeY "w" DeadZoneRangeX * 2 "h" DeadZoneRangeY * 2
	Tooltip, Dead Zone, % DeadZoneX-25, % DeadZoneY-25, 1
	Tooltip, % Up, % DeadZoneX-25, % 0, 2
	Tooltip, % Down, % DeadZoneX-25, % A_ScreenHeight, 3
	Tooltip, % Left, % 0, % DeadZoneY-25, 4
	Tooltip, % Right, % A_ScreenWidth, % DeadZoneY-25, 5
	Tooltip, % UpLeft, % 0, % 0, 6
	Tooltip, % UpRight, % A_ScreenWidth, % 0, 7
	Tooltip, % DownLeft, % 0, % A_ScreenHeight, 8
	Tooltip, % DownRight, % A_ScreenWidth, % A_ScreenHeight, 9
}
Else
	GoSub, RemoveTip
return

RemoveTip:
Gui, Cancel
Tooltip,,,,1
Tooltip,,,,2
Tooltip,,,,3
Tooltip,,,,4
Tooltip,,,,5
Tooltip,,,,6
Tooltip,,,,7
Tooltip,,,,8
Tooltip,,,,9
return

CenterMouse:
Click, %DeadZoneX%, %DeadZoneY%, 0
return

WatchMouse:
MouseGetPos, pX, pY
If StickMode
{
	If ((pX = 0) || (pX = A_ScreenWidth-1))
		|| ((pY = 0) || (pY = A_ScreenHeight-1))
		GoSub, CenterMouse
	Sleep, 150
	MouseGetPos, cX, cY
	zKeys := MoveZone(pX, pY, cX, cY)
}
Else
	zKeys := GetZone(pX, pY, DeadZoneX, DeadZoneY, DeadZoneRangeX, DeadZoneRangeY)
If (hKeys <> zKeys)
{
	Loop, % %hKeys%0
		Send, %  (hKeys = "DeadZone") ? "" : "{" %hKeys%%A_Index% " up}"
	Loop, % %zKeys%0
		Send, % (zKeys = "DeadZone") ? "" : "{" %zKeys%%A_Index% "  down}"
	hKeys := zKeys
}
return

GetZone(X, Y, DX, DY, RX, RY)
{
	If (Y < (DY - RY))
		Zone .= "Up"
	If (Y > (DY + RY))
		Zone .= "Down"
	If (X < (DX - RX))
		Zone .= "Left"
	If (X > (DX + RX))
		Zone .= "Right"
	return Zone = "" ? "DeadZone" : Zone
}

MoveZone(pX, pY, cX, cY)
{
	If (cY < pY)
		Zone .= "Up"
	If (cY > pY)
		Zone .= "Down"
	If (cX < pX)
		Zone .= "Left"
	If (cX > pX)
		Zone .= "Right"
	return Zone = "" ? "DeadZone" : Zone
}

 

@babba A priori your script works.

But I do not know if we can adapt him so that the mouse sends arrows but so that the cursor does not move or to adapt him to the script above


strobo
  • Members
  • 359 posts
  • Last active: Mar 10 2015 08:13 PM
  • Joined: 19 Jun 2012

On my machine the script (from my last spoiler) works (but not perfectly reliable), that is:

Pressing Ctrl+t remaps the mouse move directions to the ARROW KEYS and makes the cursor hold position.

Pressing Ctrl+t again, deactivates this remapping and so on.

Did You try that script?


Regards,
Babba

noxxle
  • Members
  • 3 posts
  • Last active:
  • Joined: 09 Jan 2013

I'm new to autohotkey.  How do I configure your script to automatically reset the mouse after I activate a zone?