Mapping Middle Mouse Button to the End key using Autohotkey - autohotkey

My goal is to map the "Delete" key to the middle mouse, aka my clickable wheel on my mouse. I'm on a Windows 10 machine. Currently, no matter what I do, clicking on the wheel within the Browser and other apps, produces the cross-hair.
I tried:
MButton::
Send, {End}
also tried
WheelDown::
Send, {End}
Both did not work. Thoughts?

Related

autohotkey: How to make right mouse key mimic itself and the functions of left mousekey at same time?

aka RButton should activate both LButton and Rbutton's native functions based on whether it is held down or clicked.
~Rbutton::
send {lbutton down}{rbutton down}
return
This only works if I hold Rbutton down. When I release....Lbutton continues to press itself cause its still pressed down....I have to tap it to stop. It also doesn't address at all the single click function of mousekeys. Mouse is not like keyboard presses. I'm confused when the community acts like they are. Mouse has helddown state and it has single press state. I want both of these states translated over.
When rbutton is held it should also hold Lbutton. when rbutton is released it should also release lbutton. The above code activates when rbutton is pressed....so I'm guessing any usage of
If GetKeyState("RButton", "P")
send {lbutton down}
return
has to take place outside it. But this doesn't work outside of it. So do i use if not getkeystate()....well that is going to destroy the native function of LButton which is also a no-no. There should be no key destruction only key addition, I want to add Lbutton's workings to Rbutton. period.
~RButton::LButton
Seems to work. I'm confused as to why, and what this syntax is. I thought the solution would involve the Send, and its scripting of {click right mouse}{click right down}?

How do you remap alt+tab in autohotkey?

How do you make your alt+tab functionality work like OSX where it uses meta+tab and not alt+tab, while also respecting the shift key?
I have the solution for this. Note the date of this post because I've gone through many apparently obsolete solutions before figuring this out. I've worked on this problem for a total of about 4 hours and have encountered a plethora of solutions that don't work. I'm a professional developer of 10 years but this problem nearly killed me.
There is a special keyword to replicate Alt + Tab functionality.
I also realized that AutoHotkey will block keyboard signals until you've completed the shortcut by releasing all keys, so any additional tabs that are sent while I held down the control key are ignored.
Yes, it does that. Hotkeys create something they call "threads" and by default there can be only one. So if you want to trigger the same hotkey again before the previous "thread" has finished, you can use #MaxThreadsPerHotkey directive.
The code below swaps Alt + Tab and Ctrl + Tab functionality — that is Ctrl + Tab will switch between apps and Alt + Tab between tabs in a browser. The thread limit is 255 which means that you can hold Ctrl and (in theory) press Tab 255 times before it stops working.
#UseHook
SendMode Input
#MaxThreads 255
#MaxThreadsPerHotkey 255
<!Tab::
Send {LCtrl down}{Tab}
Keywait LAlt
Send {LCtrl up}
return
#MaxThreadsPerHotkey
<^Tab::AltTab
I think I've spent more time trying to make AHK hotkeys do what I want than they could possibly save me even if I lived to a hundred.
<#Tab::AltTab
This will remap "win + tab" to "alt tab". It also works with multiple presses of the tab key.
Note: I've mapped RControl onto my LWin key via Windows registry, so autohotkey sits on top of that.
I found many solutions that said simply
>^Tab::
Send {LAlt down}{Tab}
KeyWait RControl
Send {LAlt up}
return
The issue here is that it doesn't handle alt+tab+tab+tab to go 3 programs back.
I also realized that AutoHotKeys will block keyboard signals until you've completed the shortcut by releasing all keys, so any additional tabs that are sent while I held down the control key are ignored.
What I realized is I needed a 2nd AutoHotKeys process to force that through. It seems like a rather redundant thing to write but here's my 2nd script:
#IfWinActive "ahk_class TaskSwitcherWnd"
Tab::Send {Tab}
#IfWinActive
If you're not familiar, the #IfWinActive stuff is just to make it so that this isn't firing every time the Tab key is sent - it's only while Windows' task switcher is in focus. Ultimately, this script simply says Tab::Send {Tab}.
Then you need to tell it to also react to the shift key. Oddly, the task switcher listens for that just fine but not Tab, so we don't need to forward the Shift key in that script too.
Ultimately, my two scripts look like this:
Script 1
#IfWinNotActive ahk_class TaskSwitcherWnd
; Remap Ctrl-Tab to Alt-Tab
$>^Tab::
Send {Alt down}{Tab}
Keywait Control
Send {Alt up}
return
; Remap Ctrl-Shift-Tab to Alt-Shift-Tab
$>^+Tab::
Send {Alt down}{Shift down}{Tab}
Keywait Control
Send {Alt up}{Shift up}
return
#IfWinActive
Script 2
#IfWinActive ahk_class TaskSwitcherWnd
Tab::Send {Tab}
#IfWinActive
Run these simultaneously.

AutoHotkey as control + right (zoom) mouse button for Zbrush

I'm trying to setup some hotkeys so I can use my tablet and stylus for Zbrush in a left handed setup more easily.
Basically, I want to start emulating my mouse and modifier navigation with the arrow keys.
so far what I have works. right mouse for orbit, middle for pan.
I am trying to figure out how to add a modifier key (ctrl) to the right mouse click and hold so while I hover the stylus and move it the zoom function works.
I need:
left arrow key = ctrl+right mouse hold
Thanks!
Here's my code so far:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive, ahk_class ZBrush
#MaxHotkeysPerInterval 200
Numpad0::f ;frame
Up::Space
; Use the Down Arrow as middle mouse button
Down:: ;Down Arrow Button
click Down middle ;click middle mousebutton and hold
keywait, Down ; wait until key is released.
click Up middle ; release middle mousebutton
; Use the Right Arrow Button as right mouse button
Right:: ;right Arrow Button
click Down right ;click right mousebutton and hold
keywait, Right ; wait unitl key is released
click Up right ; release right mousebutton
return
I don't have an application that ctrl + right-click does anything, so I couldn't fully test it. See if this works:
left::
Send , {ctrl down}
Click , down , right
Return
left up::
Send , {ctrl up}
Click , up , right
Return
I gave that a try and for some reason it seemed like ctrl was still sticking and causing problems although it seems to work in other applications. Since this question was ZBrush specific I'll add what became my solution for zooming in and out with hovering stylus movement while holding down the left arrow:
Left::
Send, {Alt Down}
click Down right
Send, {Alt Up}
Keywait, Left
click Up right
return
Not sure if I need the Keywait or not but it seems to work

AutoHotKey alt stays pressed

I have this script
+#^a::
SetTitleMatchMode 2
IfWinExist InterCounter
{
WinActivate
Send x
Send !{ESC}
}
return
after using it, alt stays pressed and I have to press alt on my keyboard to get to normal state (no key pressed). If I forget to do it and type something, a key shortcut is initiated. If I type SPACE for example, ALT+SPACE is pressed.
I tried various things. {Alt up} and other. They did not work. Where is the problem? Is there a fix for my script?
(would do that in a comment if I could)
try to Send , {ALT down}{ALT up} which should do the trick. If not something else is interfering, like a 3d party program. Try close everything on your system except notepad and the AHK-script and see if that helps.

Having Problems running Auto Hot Key in "ahk_class SWT_Window0" windows

I'm not sure if this is common or not but I cannot get my code to run in this type of window. It works in all of my other windows except for the one, ahk_class SWT_Window0, I want it to work in... go figure.
My code is:
RButton::
SendInput {Click 166,350}
return
Pretty simple just move the cursor and click. It works in google chrome wundow spy scite and various other windows but not with the correct window. Any help would be awesome thanks!
Jack,
Have you tried to use the scan codes directly in your application?
Here is an example. It clicks the mouse at the current location and then sends a {Tab}. You need to change this for your needs. You can move your mouse to the right location first with MouseMove,%XPos3%,%YPos3%
F8:: ; Press F8 to start macro
Send, {vk01} ; Click left mouse button
;Send, {scYYY} ;
Send, {vk09sc00F} ; Send the Vk and SC codes for the {Tab} key.
Return
Let me know if this works