Is it possible to make this AHK script? - autohotkey

I attempted to made ahk key that,
(WHILE PRESSING FN
wait for next key to enter
then add that key to the beginning and
end of the already selected line)
FN::
SendInput {LButton down}{Shift down}
Sleep, 50
SendInput {Shift up}{LButton up}
StringRight, line, clipboard, 1
Send, {Blind}{FN}
key := "{A_ThisHotkey}"
SendInput {Home}{Shift down}{End}{Shift up}
SendInput {BS}
SendInput {BS}
SendInput {BS}
SendInput {BS}
SendInput {BS}
SendInput {BS}
SendInput {BS}
SendInput %key%{line}%key%
return

Related

Strange behaviour from AutoHotKey opening CTRL+ALT+DEL menu

I'm trying to create an AutoHotKey script to run some Premiere Pro shortcuts when I press Ctrl+Alt+d but for some reason it opens the Ctrl+Alt+Del windows menu instead. Hoping someone can debug because I can't figure it out.
Here's the script:
^!d::
Send, {Shift down}NumpadDiv{Shift up}
Send, {Shift down}1{Shift up}
Send, {NumpadDiv}
Send, {Shift down}3{Shift up}
Send, {Ctrl down}a{Ctrl up}
Send, {Delete}
Send, {Shift down}1{Shift up}
Send, {Up}
Send, {Enter}
Send, {Down}
Send, {Backspace 3}
Send, SEL
Send, {Enter}
Send, {Down}
Send, {Backspace 11}
Send, STR
Send, {Tab}
Send, {Shift down}o{Shift up}
Send, {Shift down}2{Shift up}
Send, {Shift down}n{Shift up}
return
Thanks in advance!
Fixed this problem by adding
KeyWait Control
KeyWait Alt
To the beginning of my script

Fixing Keyboard shortcut send in Auto Hot Key

Hi this is a super easy question but I was hoping someone could help me solve two AutoHotKey questions.
I am trying to get the keys Cntrl, J and I to be a keyboard shortcut that sends alt,h,v, and f.
Thus far I have tried these two ways of typing it
^&j&i::Send, !&h&v&f
^ji::Send, !hvf
as well as each of those without the comma after send.
I am also looking to send these keys on a very small delay, such as 5ms between each key
I was thinking of using something like this
^&j&i::
{
Send, {! down}
sleep 5
Send, {h down}
sleep 5
Send, {v down}
sleep 5
Send< {f down}
}
but of course, that is not working either. Any help is appreciated
Refer to https://www.autohotkey.com/docs/Hotkeys.htm#combo
Combinations of three or more keys are not supported. With this in mind we need to check the key state of the control key before defining the hotkey.
A few other things to note: SendInput is the ideal send method, and you likely want those keys back into an up state which I've included in my example.
#if GetKeyState("LControl", "P")
{
j & i::
{
SendInput {Alt down}
sleep 5
SendInput {h down}
sleep 5
SendInput {v down}
sleep 5
SendInput {f down}
sleep 5
SendInput {Alt Up}
sleep 5
SendInput {h Up}
sleep 5
SendInput {v Up}
sleep 5
SendInput {f Up}
return
}
}

Autohotkey Mapping Modifiers

I can't use arrow keys from my keyboard so I mapped 1234 to be the arrow keys like that:
*!^1::
Send, {Left down}{Left up}
Return
*!^2::
Send, {Down down}{Down up}
Return
*!^3::
Send, {Up down}{Up up}
Return
*!^4::
Send, {Right down}{Right up}
Return
Now my problem is that in some programs the arrow keys pressed with the shift modifier is associated to a function and with the current settings, when I press Ctrl+Alt+Shift+1 it still outputs me the associated arrow key without considering the 'Shift' modifier.
Do you know how could I solve the problem?
Thanks.
You can just add a list of commands that already includes the shift key, like this:
*+!^1::
Send, {Shift down}{Left down}{Left up}{Shift up}
Return
*+!^2::
Send, {Shift down}{Down down}{Down up}{Shift up}
Return
*+!^3::
Send, {Shift down}{Up down}{Up up}{Shift up}
Return
*+!^4::
Send, {Shift down}{Right down}{Right up}{Shift up}
Return

AutoHotkey - press Ctrl+Alt only, without any characters

I can see that Ctrl+Alt+Delete is not possible with AutoHotkey, but what about just Ctrl+Alt?
Things I've tried:
; 1
#+y::
Send, {Ctrl}{Alt}
return
;2
#+y::
Send, {Ctrl down}
Send, {Alt down}
Send, {Alt up}
Send, {Ctrl up}
return
;3
#+y::
Send, {LCtrl down}
Send, {LAlt down}
Send, {LAlt up}
Send, {LCtrl up}
return
;4
#+y::
Send, !^
return
;5
#+y::
Send, {ctrl down}{alt down}{2}{alt up}{ctrl up}
return
Any ideas?
The below will do what you want. It's also recommended you use SendInput going forward.
#+y::
SendInput, {Ctrl Down}{Alt Down}{Ctrl Up}{Alt Up}
Try to specify the left or right ALT or CTRL keys
#+y::
Send, {LCtrl}{LAlt}
return

AHK - How to hold a macro while Physical Key depressed

What I want to do is this:
Numpad3::
if(not GetKeyState("Shift" , "P") and not GetKeyState("RButton" , "P"))
{
SendInput {Shift down}
Sleep, 33
Click down right
}
Return
Numpad3 Up::
Sleep, 100
Click up right
Sleep, 33
SendInput {Shift up}
Return
But for some reason it isn't canceling when I let the button up. :(
I would suggest to use Send {RButton Down} (or Up) to send the right mouse click, instead of Click up right.
Also, you don't want to be sending random Sleep's if they are not really necessary, as it creates lag and makes the script inelegant and potentially unreadable.
Here is code which sends Control instead of RButton but it's only so I can test it within Notepad++.
Just replace Control with RButton and have a go:
*NumpadPgDn::
*Numpad3::
Send {Shift Down}{Control Down}
return
*NumpadPgDn Up::
*Numpad3 Up::
Send {Shift Up}{Control Up}
return