I need to port an autohotkey script to autokey - porting

I have been playing Stardew Valley and want to try animation canceling and found this script:
#IfWinActive Stardew Valley
x::
While GetKeyState("x","P")
{
sendEvent {LButton Down}
sleep 10
sendEvent {LButton Up}
sleep 125
sendEvent {r Down}{Delete Down}{RShift Down}
sleep 10
sendEvent {r Up}{Delete Up}{RShift Up}
}
sleep 30
return
The problem is that this is for AutoHotKey which is only for windows. I could try wine but I think I would then need a windows version of Stardew Valley which would require a windows version of Steam and wine probably doesn't have the files to allow for that. So instead I downloaded AutoKey which uses a very different language from AutoHotKey. The next issue is that I have not been able to find:
1.How to set click duration
2.How to set Keyboard press duration
3.How to specify what shift to use(It MUST use right shift to work)
4.How to make it repeat until I release the hotkey
If you can port it to AutoKey or recommend a different alternative then it would be appreciated.

Related

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

Consume Windows key release in autohotkey script

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

Solution to AHK sending too many events when holding down a mouse button?

When using three different methods of holding down the left mouse button:
Mouseclick, left, 0, 0, 1, , D, R
or
Send {LButton down}
or
Click down
the game I'm making a macro for logs me out complaining that I'm sending too many actions. I tested this by itself as a script, like:
F3::
Click down
return
So there's no chance other code is causing it.
I was wondering if there are any settings I can use (by settings I mean like CoordMode, Mouse, Screen) or any other solution to perhaps prevent whatever rapid event sending AHK is using to simulate a mouse button being held down. Is there any possible fix I can try? I'm open to testing any ideas.
Well, you could introduce a Sleep like so:
LButton::
while (GetKeyState("LButton", "P"))
{
MouseClick, left
Sleep, 100
}
return
Though I personally dislike binding the mouse click to behaviours via the same mouse click, as it can lead to results that are difficult to get out of.
Here's an example with a toggleable hotkey.
Insert::
SendInput, {LButton Down}
loop
{
Sleep, 100
if getkeystate("Insert", "p") ; Hold for a second as the Sleep will delay recognition.
{
SendInput, {LButton Up}
break
}
}
return
Edited per the comments:
Insert::
SendInput, {LButton Down}
KeyWait, Insert, D
SendInput, {LButton Up}
return

Holding control, shift and v, using only one key

I am using lightroom for this hotkey. I dont know why is this doesn't work for me.
::{control}{sleep 5}{shift}{sleep 5}v
And Alt+F+↓(5x) then Enter.
And Alt+F+↓(5x) then Enter.
I don't know what you mean by that, because I can't see anything like that in your script. So I will just ignore it and do what the thread title and your script says/implies.
The following script will simulate pressing Ctrl+Shift+V when you press the A key
SetKeyDelay, 5 ;wait 5 milliseconds between every keystroke
a::^+v
About your comment, I guess I know what you are on to, try this:
SetKeyDelay, 5 ;wait 5 milliseconds between every keystroke
2::
SendInput, !f
Sleep, 50
SendInput, {Down}{Down}{Down}{Down}{Down}{Enter}
Return