Consume Windows key release in autohotkey script - autohotkey

I'd like to map the Windows 10 virtual desktop switching feature to Windows key + mouse wheel with autohotkey.
My script looks like this:
LWin & WheelUp::Send ^#{Left}
LWin & WheelDown::Send ^#{Right}
The desktop switching works flawlessly, I can even hold down the Windows key and scroll up and down and it will change back and forth between desktops.
Unfortunately, if I keep holding down the Windows key for a little while after the last wheel action, the key release is sent to the OS which opens the start menu. Also, when I close the start menu afterwards (by pressing the windows key again) it switches back to the first virtual desktop I changed to (as if it had only received one "switch desktop" command).
So, my question is: how can I consume this key release in my script (and only for these two commands)?
Thanks in advance.

Try this .
LWin & WheelUp::
Send, {Ctrl Down}{LWin Down}{Left}
SetTimer ReleaseKeys, 50
return
LWin & WheelDown::
Send, {Ctrl Down}{LWin Down}{Right}
SetTimer ReleaseKeys, 50
return
ReleaseKeys:
If not GetKeyState("LWin","P")
{
SetTimer ReleaseKeys, off
Send {Blind}{Ctrl Up}
Send {Blind}{LWin Up}
WinClose Start ahk_class Windows.UI.Core.CoreWindow
}
return

Related

AHK Remapping Middle Mouse button to something else

After a month of trial and error, I've finally found a solution!
How to remap Middle mouse button something else?
If you don't have a three-button mouse, this is a must-have for blender (esp. Laptop)
I'm aware of "emulate 3 button mouse" in Preference>>Input.
But if you check that option then you won't be able to 'Select loop'
which uses ALT leftClick.
What if you could remap Mbutton to any other key you rarely use?
Yes you can!
Nice to see that you tried it yourself.
But here's how a context sensitive remap is actually done:
#IfWinActive ahk_class GHOST_WindowClass
LWin::MButton
#IfWinActive
This script will allow you to remap Mbutton with other key, such as LeftWin.
;~--------------------------------------------------------------------------------------
#IfWinActive ahk_class GHOST_WindowClass ; Blender's class
$LWin:: ; "$" this allows to send the trigger key in a working script***
loop
{
if getkeystate("LWin", "p") ; if a button is Physically held down by the user.
{
send, {MButton DOWN}
}
else
{
send, {MButton UP}
;~ MsgBox, Blender is active ; You dont need this.
return
}
}
#IfWinNotActive ahk_class GHOST_WindowClass ; Other than blender (I'm aware of other methods, but this works for me!)
Send, {LWin} ; *** like here I'm able to use Left Win again without triggering the script.
;~ MsgBox,Blender isnt active ;; You dont need this.
return
;~ --------------------------------------------------------------------------------------

ControlSend [Strg]+[Win]+[Numpad3] to OBS Studio

I try to send [Strg]+[Win]+[Numpad3] to OBS Studio to pause recording via an Autohotkey script.
My current approach is the following one because I want to avoid that other applications react on this shortcut. For example Notepad++ changes with this the open tabs.
ControlSend, , ^#{Numpad3}, ahk_class Qt5QWindowIcon
Actually, nothing happens in OBS Studio. Even when using {Ctrl down} and {LWin down} it does not work. Do you have an idea?
Use SetKeyDelay (or use separate up & down events with delay inbetween) to make the key be hold down for a bit longer.
Worked for me.
;hold down for 50ms
SetKeyDelay, -1, 50
ControlSend, , ^#{Numpad3}, ahk_class Qt5QWindowIcon

LButton Hotkey seems to prevent Send, {LButton}

I'm at a loss here. As soon as I add the LButton hotkey, the Send, {LButton} doesn't seem to work, but they show up in recently executed lines.
Env. Windows 7x64, Disabled Touchpad, AHK v1.1.31.01.
I try to emulate the Wink application (from DebugMode) to capture screenshots for training purposes. For that reason, I want to capture a screenshot just before a mouse click. This looks easy, and I even vaguely remember doing similar mouse hotkeys in the past. However I can't get this to work.
Step 1: I just reduced it to this simple script:
#InstallKeybdHook
#InstallMouseHook
#UseHook
#Persistent
Return
a::
Send, {LButton}
Return
q::
ExitApp
When using this script, I can simulate clicking the Left Mouse Button through the a key. Nothing special.
However as soon as I add either a line with "Hotkey, $LButton, MySendClick", or "$LButton::" the previously working a hotkey no longer works. In the recently executed lines, you can see the "Send, {LButton}" lines, but nothing is being send. Unexpectedly, the a hotkey actually causes the "$LButton::" hotkey to trigger (without it sending {LButton}). When I change the a hotkey to send "RButton" and the $LButton:: to $RButton::, then Send {Click} works perfectly (eventhough the a hotkey should never be able to trigger $RButton::).
Originally I just wanted to have the following HotKey:
$LButton::
SoundBeep, 300, 150 ; For testing only
; Send, ^{PrintScreen} ; To trigger Greenshot in the background
Sleep, 100
Send, {LButton}
Return
I upgraded from AHK v1.1.22.04 to v1.1.31.01. No improvement.
I tried "Click", "sendInput, {LButton}", "Send {Click}", "MouseClick, Left".
I tried "$LButton::", "vk01sc000::", "Hotkey, $LButton, MyClick".
Is this an issue with my specific Windows 7 configuration or an "undocumented AHK feature"?
#InstallKeybdHook
#InstallMouseHook
#UseHook
#Persistent
Return
a::
Send, {LButton}
Return
$LButton::
SoundBeep, 300, 150 ; Should be Send, ^{PrintScreen} ; To trigger Greenshot in the background
MouseClick, Left
Return
q::
ExitApp
In this last test example, When $LButton:: is disabled, the a hotkey works like a charm, but as soon as I enable $LButton::, the a hotkey triggers $LButton:: and no mouse click is being sent to the windows applications.
I would appreciate it when other Windows 7 users could quickly test this issue.
In my experience, using keys that you still want the input to pass through need the Tilde prefix.
https://www.autohotkey.com/docs/Hotkeys.htm#Tilde
~LButton::
SoundBeep, 300, 150 ; Should be Send, ^{PrintScreen} ; To trigger Greenshot in the background
KeyWait, LButton ; Wait for lbutton to be released.
Return

Sending and releasing multiple keys at once using AutoHotkey

I'm attempting to send three keys (Alt, Shift, Q) at same time using this script:
:*:pk:: ;
Send, {AltDown}{ShiftDown}{qDown}
return
When I run this is it does not release the keys, it seems like the Alt button remains pressed. After the above keys are pressed I then want to press the "q" character again (separately, not at same time).
How can I amend my script above to achieve this?
When using Down, you must also send an Up to the same key or else it will remain pressed. This can be achieved like this:
:*:pk::
Send, {Alt Down}{Shift Down}{q Down}{Alt Up}{Shift Up}{q Up}
Send, {q}

Eclipse Synchronize Hotkeys

There is a button "Upload All Outgoing Changes" in Synchronize panel of eclipse. Any way to "click" it without mouse? There is no such action in prefs->general->keys
I created an Auto Hot Key file just for this. http://www.autohotkey.com/
I hope you like it!
; Eclipse Synchronize Override Upload
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: Taylor York <taylor#tyec.co>
;
; Script Function:
; Upload Files to the Synchronize Window in Eclipse
;
;#NoTrayIcon
#SingleInstance force
DetectHiddenWindows, on
; the title starts with
SetTitleMatchMode 2
SyncAndUpload() ; Function
{
; Get to the Synchronize Tab
Send {ALT down} ; Hold Alt+Shift+Q down
Send {SHIFT down} ; Eclipse seemed to dislike pressing every key at once
Send {Q down}
Send {Q up}
Send {SHIFT up}
Send {ALT up}
Sleep, 250 ; wait 250 milliseconds
Send y
; Click Override and Upload
Send {Space} ; When you go to the Synchronize tab, you have to select something. Space selects to top item
Send {AppsKey} ; "Right Click" / Context menu the item that is selected
Send {o 2} ; Press o twice (Override and Upload is the second O)
}
; Make sure we are in Eclipse, so we dont hijack other apps!
#IfWinActive, ahk_class SWT_Window0
{
#IfWinActive, PHP ; Title starts with PHP (this is used so it only works in PHP mode.
{
^T::
{
KeyWait Control ; Wait to run until all keys are let go
KeyWait T
SyncAndUpload()
return
}
^S::
{
KeyWait Control ; Wait to run until all keys are let go
KeyWait S
Send ^S
Sleep 250
SyncAndUpload()
}
return
}
return
}
;endofscript
It does not exist and I think I know why: committing or updating should be a very conscious decision. So clicking the button promotes that kind of decision.
In general you can use Ctrl-Shift-L to see quick cheat sheet of shortcuts for currently opened views.