I am trying to make a script that when press x to cut, c to copy and v to paste if the ScrollLock is on.
Here is my script that is not working, it will perform cut, copy and paste no matter ScrollLock is on or off.
~ScrollLock::
KeyWait, ScrollLock
GetKeyState, ScrollLockState, ScrollLock, T
If ScrollLockState = D
{
x:: Send, ^x
c:: Send, ^c
v:: Send, ^v
}
And for the script below, I cannot type x, c and v when ScrollLock is off, but can cut, copy and paste when ScrollLock is on.
~ScrollLock::
KeyWait, ScrollLock
GetKeyState, ScrollLockState, ScrollLock, T
x::
If ScrollLockState = D
{
Send, ^x
return
}
c::
If ScrollLockState = D
{
Send, ^c
return
}
v::
If ScrollLockState = D
{
Send, ^v
return
}
You can do it in the following way:
#If GetKeyState("ScrollLock", "T")
x::Send, ^x
c::Send, ^c
v::Send, ^v
#If
Related
The AHK script below should use 7-zip to extract a folder when ctrl+ALT+Left is pressed. When you manually right-click on a folder and then type "7eee" and then press enter, the folder extracts. I'd like to mimic this without the right-click and instead use the keyboard shortcut. I tried to do this two ways:
;alt + ctrl
!^LButton::
blockinput on
send {LButton}{RButton}7eee{enter}
blockinput Off
return
I also tried:
;alt + ctrl
!^LButton::
temp = %clipboard%
KeyWait, LButton, D
send {LButton}
sleep,100
Send, {Ctrl Down}c{Ctrl Up}
file = %clipboard% ;get file address
clipboard = %temp% ;restore clipboard
outdir := getdir(file)
if (A_Is64bitOS = 1)
{
runwait, "C:\Program Files\7-Zip\7z.exe" x "%file%" -o"%outdir%" -y,,hide
}
else
{
runwait, "C:\Program Files (x86)\7-Zip\7z.exe" x "%file%" -o"%outdir%" -y,,hide
}
msgbox, 7zip has finished extracting "%file%".
return
getdir(input)
{
SplitPath, input,,parentdir,,filenoext
final = %parentdir%\%filenoext%
return final
}
EDIT:
I have found something that works:
#IfWinActive, AHK_EXE Explorer.exe
^e::
temp = %clipboard%
Send, {Ctrl Down}c{Ctrl Up}
file = %clipboard% ;get file address
clipboard = %temp% ;restore clipboard
outdir := getdir(file)
if (A_Is64bitOS = 1)
{
runwait, "C:\Program Files\7-Zip\7z.exe" x "%file%" -o"%outdir%" -y,,hide
}
else
{
runwait, "C:\Program Files (x86)\7-Zip\7z.exe" x "%file%" -o"%outdir%" -y,,hide
}
msgbox, 7zip has finished extracting "%file%".
return
getdir(input)
{
SplitPath, input,,parentdir,,filenoext
final = %parentdir%\%filenoext%
return final
}
#If
But I do not like the message box and I wish there were a progress bar or indication that it is in the process of extracting.
This is an old question and you're probably fine with the workaround you've found, but if you're still looking for a simple script that mimics the mouse/keyboard procedure, here it is:
^#!z:: ;// Ctrl + Alt + Win + Z
blockinput on
Sleep, 300
SendInput, {AppsKey}
Sleep, 100
SendInput, 7
Sleep, 100
SendInput, e
Sleep, 100
SendInput, e
Sleep, 100
SendInput, e
Sleep, 100
SendInput, {Enter}
blockinput on
Return
I did not try your code but in general, using the context menu key (AppKey) is more reliable than mouse button clicks, and also adding some sleep time between key strokes helps. If the script doesn't work, you may need to increase the sleep time intervals, 100 ms at a time, till it works.
I'd like to remap my windows key to something else, but also I'd like to keep all windows key based shortcut.
In pseudo code it would be something like this:
when LWin Down
until LWin Up
if not LWin down
abort
else
execute command
Release the left windows key within 0,3 seconds after pressing it, to do something else (e.g. to send a):
~LWin::
KeyWait, LWin
return
~LWin Up::
Send {LWin Up}
If (A_PriorHotKey = "~LWin" AND A_TimeSincePriorHotkey < 300)
Send, a
; else ; another action after long press (not recommendet)
; Send, b
return
EDIT:
Try also this:
LWin up::
If (A_PriorKey = "LWin")
Send a
return
; In this case its necessary to define a custom combination by using "&" or "<#"
; to avoid that LWin loses its original function as a modifier key:
<#d:: Send #d ; <# means LWin
So in this game im moving my charachter with the WASD keys, but if i hold down the A and D key at the same time,
the game register that as a forward movement (W key |) so the charachter starts to move forward instead of the strafe actions (Left) \ (right) /.
So i need a code which is prevents the A and D key simultaneous pressing.
CHECK THIS GIF, SO U CAN SEE WHAT I MEAN!
I want A and D override each other (Im not using the W key), because if i hit both A and D at the same time my character moves forward, not like this \ /
and i want to avoid the forward movements.
I want insantly changed fast Left \ and Right / strafing only.
Here is the code what i got so far:
~a::
If (GetKeyState("d", "p"))
{
Send {d up}
d = 0
}
Return
~d::
If (GetKeyState("a", "p"))
{
Send {a up}
a = 0
}
Return
a up::
If (d)
{
Send {d down}
d = 0
}
Return
d up::
If (a)
{
Send {a down}
a = 0
}
Return
Basicly this code almost working.
The problem is if i don't change the numbers i can't change directions continuously i need to let go the keys. It stops after 1 direction change. If i change the numbers its working, but after a few direction change its getting toggled either left or right. Even if i let it go its moving left or right....
Any ideas? thx
This should work. Try it and let me know.
$*a::
$*d::
SendInput, {a Up}{d Up}
StringReplace, hk, A_ThisHotkey, % "$*"
SendInput, {%hk% Down}
KeyWait, % hk
Send, {a Up}{d Up}
return
EDIT: You can play around with the code below. Maybe it will help you out
#SingleInstance, force
#Persistent
#NoEnv
#MaxThreadsPerHotkey, 1
~a & d::
~d & a::
Send, {a up}
key := "d"
SetTimer, pressdown, 10
return
~d::key := "d"
~a::key := "a"
~a up::key := "d"
~d up::key := "a"
pressdown:
if GetKeyState(key, "p")
{
SendInput, {%key% down}
SetTimer, pressdown, 30
}
else {
SetTimer, pressdown, Off
SendInput, {%key% up}
}
return
This script cannot allow A, or D to be simultaneously pressed.
This may be a very simple code but I am not able to find how to do it.
I have this
Send, Hi
Send, How Are you
Send, I am Fine
I want to do it like this
Hi How Are you
....
Right now with the below code
KeyWait, Capslock
Send, Hi
KeyWait, Capslock
Send, How Are you
KeyWait, Capslock
Send, I am Fine
I get
HiHow Are YOuI Am Fine as soon as I press Capslock.
I want it to wait to execute the next command. THanks for your help.
KeyWait, Capslock
Send {Capslock} ; Tap it again to reset it and force it to be released
; or Send {Capslock Up} to force it to be released
; or SetCapslockState Off to disable it completley
Send, Hi KeyWait, Capslock{Enter}
Send, How Are you KeyWait, Capslock{Enter}
Send, I am Fine{Enter}
If you want it in a hotkey, you could do something like this.
~$CapsLock::
Send {CapsLock Up}
Send, Hi {Enter}
KeyWait, Capslock, D
Send {CapsLock Up}
Send, How Are you{Enter}
KeyWait, Capslock
Send {CapsLock Up}
Send, I am Fine{Enter}
return
(It's glitching on my computer, but it may be because I'm on a virtual machine.)
SetCapslockState
Sorry if it is too late,but i did it anyways for everyone searching the solution for it,i assume you want to change it every time u press capslock to be different text:
CapsLock::
CapsLock0:
{
SendRaw Hi
Sleep 500
KeyWait, CapsLock, D
{
Goto CapsLock1
}
}
Return
CapsLock1:
{
SendRaw How Are you
Sleep 500
KeyWait, CapsLock, D
{
Goto CapsLock2
}
}
Return
CapsLock2:
{
SendRaw I am Fine
Sleep 500
KeyWait, CapsLock, D
{
Goto CapsLock0
}
}
Return
Explaination for Sleep,it is used because if you would press CapsLock without it then 2 of the command blocks would be executed,it is especially needed.
How about this...
Capslock::
Send, Hi{Enter}
Sleep, 400 ; sleep briefly to allow the CapsLock key to be released
KeyWait, Capslock, D
Send, How Are you?{Enter}
Sleep, 400
KeyWait, Capslock, D
Send, I am fine Thank you.{Enter}
Return
How about this...
Capslock::
Send, Hi{Enter}
KeyWait, Capslock, U
KeyWait, Capslock, D
Send, How Are you?{Enter}
KeyWait, Capslock, U
KeyWait, Capslock, D
Send, I am fine Thank you.{Enter}
Return
I'm trying to re-map the arrow keys to a combination of Alt-key to get them more centered on the keyboard. The problem is that I cant get the combination with shift to work (for selecting text while moving the cursor).
This is a starting point:
lalt & ö:: Send, {left}
lalt & å:: Send, {up}
lalt & -:: Send, {down}
lalt & ä:: Send, {right}
Any tips would be appreciated.
This only fixes it for Shift.
lalt & ö::
If GetKeyState("Shift", "D") = true
Send, +{Left}
Else
Send, {Left}
Return
lalt & å::
If GetKeyState("Shift", "D") = true
Send, +{Up}
Else
Send, {Up}
Return
lalt & -::
If GetKeyState("Shift", "D") = true
Send, +{Down}
Else
Send, {Down}
Return
lalt & ä::
If GetKeyState("Shift", "D") = true
Send, +{Right}
Else
Send, {Right}
Return
You can declare alt modifier with ! and shift with +
Combine them to give alt + shift
!ö:: Send, {left}
!å:: Send, {up}
!-:: Send, {down}
!ä:: Send, {right}
+!ö:: Send, +{left}
+!å:: Send, +{up}
+!-:: Send, +{down}
+!ä:: Send, +{right}