I still need time to understand your help - and I also tried to follow to no avail - it must be sth else in my entire codes below - if you could also kindly have a look - thank you very much again Rohwedder!!
Code: Select all
; ;.... = available
/*
akirofe wrote: ↑
Today, 10:23
Thank you very much Gregster!! Long time no see, how are you? :)
Now I see it was such a basic question :(
Could you also please help me with where to read about the above so I won't keep asking such basic questions...?
Thank you, fine, still hanging around here a lot. :)
I would recommend reading the docs ;)
Controlsend's Keys parameter is pretty similar to the one of the normal Send commands -> keynames need braces; and letters without braces are taken literally. The Send docs have a list of special keynames, and a few more details: https://www.autohotkey.com/docs/commands/Send.htm#keynames
The ControlSend docs even lead you to the Send docs: "Keys: The sequence of keys to send (see the Send command for details).[...] "
And could you please also help me with where I can read to know how to solve the below codes , which I believe didn't work because of the same keys being used for F5 and F14 further down... :(
Tbh, I don't know what "solve" means in this case.
What happens, what should happen instead?
I think the comboF5 & F14 should work while pressing F5 and F14 separately should still work as well.
I don't have F14, but these all work here:
Code: Select all - Download - Toggle Line numbers
#IfWinNotActive, ahk_exe something.exe
F5 & F10:: msgbox combo
#If
F5::msgbox F5
F10::msgbox F10
Well, F5 fires now only on key release, which is a side-effect of it being a prefix key in a custom combination.
Related: https://www.autohotkey.com/docs/Hotkeys.htm#combo
*/
; https://www.makeuseof.com/tag/10-cool-autohotkey-scripts-make/
; Key symbols https://www.autohotkey.com/docs/Hotkeys.htm
/*
Why didn't work?
F5 & F16::
Sleep 500
send {c}
Sleep 200
send {i}
return
AND
Shift & F15/Tab::^g
To try:
16
In order to prevent duplicate instances, I normally do not re-launch a script but use the build-in function Reload. I launch this with Ctrl+Win+Alt+R and use Ctrl+Win+Alt+E to edit the main AHK script.
^#!r::Reload
Actually, my script looks like this:
^#!r::
Send, ^s ; To save a changed script
Sleep, 300 ; give it time to save the script
Reload
Return
^!#e::Edit
As a matter of fact, all the way at the top of my script I have this to give me a visual and audio indication that the script was restarted:
#SingleInstance Force
#installKeybdHook
#Persistent
Menu, Tray, Icon , Shell32.dll, 25, 1
TrayTip, AutoHotKey, Started, 1
SoundBeep, 300, 150
Return
*/
/*
gregster:
To send the left arrow key, you need to put braces around it: {Left}
Same for Right -> {Right}
*/
/*
Hi Rohwedder,
Thank you very much for constantly helping me!!
Could you please also help me with how to make the following codes work please Rohwedder?
F15::Tab
F15 & F9::9
^F15::send {Thank you.}
; To send "Regards." when press Ctrl-F15-F9:
^9::send {Regards.}
Thank you very much Rohwedder!!
Kind Regards.
Tim
*/
#SingleInstance Force
#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.
/*
CoordMode, ToolTip, Screen
Loop, 5000
{
Hotkey, % "~*" GetKeyName(Format("vk{:x}", a_index - 1)), GetText
Hotkey, % "~*" GetKeyName(Format("sc{:x}", a_index - 1)), GetText
}
; "~" keeps the button original function
; "*" fires the hotkey even if extra modifiers are being held down
Return
GetText:
Sleep, 50
Key := RegExReplace(A_ThisHotkey, "^..") ; "^.." removes the first 2 characters ("~*") from the returned string
If StrLen(Key) > 1
Key := "{" Key "}"
Text .= Key
ToolTip, % "" . Key "`n`n" . Text, 0, 0 ; X\Y coordinates
Return
;=============================
*/
;============================== Start Auto-Execution Section ==============================
; Keeps script permanently running
#Persistent
; Avoids checking empty variables to see if they are environment variables
; Recommended for performance and compatibility with future AutoHotkey releases
#NoEnv
; Ensures that there is only a single instance of this script running
#SingleInstance, Force
;Determines whether invisible windows are "seen" by the script
DetectHiddenWindows, On
; Makes a script unconditionally use its own folder as its working directory
; Ensures a consistent starting directory
SetWorkingDir %A_ScriptDir%
; sets title matching to search for "containing" isntead of "exact"
SetTitleMatchMode, 2
;sets controlID to 0 every time the script is reloaded
controlID := 0
return
;============================== Main Script ==============================
#IfWinNotActive, ahk_exe chrome.exe
F3 & Ctrl::
; Gets the control ID of google chrome
ControlGet, controlID, Hwnd,,Chrome_RenderWidgetHostHWND1, Google Chrome
; Focuses on chrome without breaking focus on what you're doing
ControlFocus,,ahk_id %controlID%
; Checks to make sure YouTube isn't the first tab before starting the loop
; Saves time when youtube is the tab it's on
IfWinExist, YouTube
{
ControlSend, Chrome_RenderWidgetHostHWND1, k , Google Chrome
return
}
; Sends ctrl+1 to your browser to set it at tab 1
ControlSend, , ^1, Google Chrome
; Starts loop to find youtube tab
Loop
{
IfWinExist, YouTube
{
break
}
;Scrolls through the tabs.
ControlSend, ,{Control Down}{Tab}{Control Up}, Google Chrome
; if the script acts weird and is getting confused, raise this number
; Sleep, is measures in milliseconds. 1000 ms = 1 sec
Sleep, 150
}
Sleep, 50
; Sends the K button to chrome
; K is the default pause/unpause of YouTube (People think space is. Don't use space!
; It'll scroll you down the youtube page when the player doesn't have focus.
ControlSend, Chrome_RenderWidgetHostHWND1, k , Google Chrome
return
#IfWinNotActive
;============================== End Script ==============================
F5 & F8::
KeyWait, F8
IF (A_TimeSinceThisHotkey < 500)
{ ; type F5 & F8 < 500ms: release keys
Loop, 0xFF
IF GetKeyState(Key:=Format("VK{:X}",A_Index))
SendInput, {%Key% up}
}
Else ; hold F5 & F8 down > 500ms: (on/off) show (pressed/stuck down) keys
SetTimer, StuckKeys,% (StuckKeys:=!StuckKeys)?100:"Off"
Return
StuckKeys:
CoordMode, ToolTip, Screen
ToolTip,% StuckKeys?KeyCombination():, 0, 0
Return
KeyCombination(ExcludeKeys:="")
{ ;All pressed keys and buttons will be listed
ExcludeKeys .= "{Shift}{Control}{Alt}{WheelUp}{WheelDown}"
Loop, 0xFF
{
IF !GetKeyState(Key:=Format("VK{:02X}",0x100-A_Index))
Continue
If !InStr(ExcludeKeys,Key:="{" GetKeyName(Key) "}")
KeyCombination .= RegexReplace(Key,"Numpad(\D+)","$1")
}
Return, KeyCombination
}
;=============================
ScrollLock::ExitApp
/*#NoTrayIcon ; Hide the tray icon. (Use Win + Alt+ X to close.)
;#!x::
DetectHiddenWindows, On
WinGet, List, List, ahk_class AutoHotkey
Loop %List%
{
WinGet, PID, PID, % "ahk_id " List%A_Index%
If ( PID <> DllCall("GetCurrentProcessId") )
PostMessage,0x111,65405,0,, % "ahk_id " List%A_Index%
}
return
*/
RButton::RButton
RButton & LButton::MButton
RAlt::RButton
CapsLock::BackSpace
F1::send {WheelUp 7}
F2::MButton
;; F3::Shift
F4::send {WheelDown 10}
F5::Esc
F6::!Tab
F7::
Sleep 500
send {m}
Sleep 200
send {v}
return
F8::Backspace
F9::^z
F10::Enter
F11::Delete
F12::!Left
F13::^F4
F14::
Sleep 500
send {e}
Sleep 200
send {w}
return
F15::Tab
F16::RButton
F6 & LButton::^v
F6 & Ctrl::^c
;F6 & Shift
F6 & F5::^s
;F6 & F9::
F6 & F13::^x
F6 & F14::#v
F6 & F15::
Sleep 500
send {p}
Sleep 200
send {a}
return
F6 & F16::^a
;;;;;F8 & = can't, because hold for continued delting
F11 & LButton::ExitApp
F11 & Ctrl::Reload
;F11 & Ctl::
;F11 & F8::
;F11 & F10::
;F11 & F13::; other F1-F12... But can't F2: hold for middle mouse button pan.
^9::!Right
;^Space::^p
;^Shift::***do not use. Easy to mistype.
;^Tab::***do not use. Conflict with Window's Ctrl-Tab
^CapsLock::^F4
^LButton::
send {Ctrl down}{LButton down}{LButton up}{Ctrl up}
return
;------------
^F1::
Sleep 500
send {a}
Sleep 200
send {l}
return
^F2::
Sleep 500
send {t}
Sleep 200
send {r}
return
^Shift::
Sleep 500
send {d}
Sleep 200
send {i}
return
^F4::
Sleep 500
send {c}
Sleep 200
send {s}
return
^F5::
Sleep 500
send {m}
Sleep 200
send {a}
return
^F6::
Sleep 500
send {j}
Sleep 200
send {j}
return
^F7::
Sleep 500
send {c}
Sleep 200
send {o}
return
^F8::send {Up}
^F9::Space
^F10::send {Left}
^F11::send {Down}
^F12::send {Right}
^F13::send {t}
^F14::^WheelDown
^F15::^Tab
^F16::^WheelUp
F15 & Ctrl::0
F15 & F14::,
F15 & F16::.
;Not possible - F15 & LButton::
;Not possible - F15 & F13::
F15 & F1::1
F15 & F2::2
F15 & Shift::3
F15 & F4::4
F15 & F5::5
F15 & F6::6
F15 & F7::7
F15 & F8::8
F15 & F9::9
F15 & F10::=
F15 & F11::+
F15 & F12::-
F13 & Ctrl::send ndquach.com
F13 & F1::
Sleep 500
send {c}
Sleep 200
send {i}
return
F13 & F2::send Yes please call me 0420946997 or Whatsapp/Zalo +61420946997 cheers
F13 & Shift::
FormatTime, CurrentDateTime,, yyMMdd
SendInput %CurrentDateTime%
Return
F13 & F4::^x
F13 & F5::^s
F13 & F6::#v
F13 & F7::Reload
F13 & F8::^d
F13 & F9::send [email protected]
F13 & F10::
^s
Reload
return
F13 & F11::^f
F13 & F12::send 0420946997
;;;Shift & Ctrl::control Youtube in Chrome above:
;Shift & Capslock::
;Shift & Space::
;Shift & LAlt::
;;;;;Shift & F2::
;Shift & F6::
Shift & F13::
Sleep 500
send {c}
Sleep 200
send {i}
return
;Shift & Tab::^g
Shift & F14::Volume_Down
Shift & F16::Volume_Up
F5 & LButton::run VirtualKeyboard.ahk
;;;; F5 & Ctrl::
F5 & F13::
Sleep 500
send {s}
Sleep 200
send {c}
Return
;F5 & F14::
F5 & F15::
Sleep 500
send {s}
Sleep 200
send {o}
Return
;F5 & F16::
F5 & F2::
Sleep 500
send {s}
Sleep 200
send {p}
return
F5 & F6::
Sleep 500
send {s}
Sleep 200
send {m}
Return
F5 & F4::
Sleep 500
send {s}
Sleep 200
send {e}
Return
;;;;;F5 & F8:: (clear stuck key scripts above)
Space Up::Send, {Space}
Space & F5::CapsLock
Space & Tab::
Sleep 500
send {s}
Sleep 200
send {p}
return
Space & Capslock::0
Space & Shift::Volume_Up
Space & Ctrl::Volume_Down
;###Send {Volume_Down 100} ; Turns the volume DOWN 100 intervals, not muting
^q::send p
^w::send o
^e::send i
^r::send u
^t::send y
^a::send {;}
^s::send l
^d::send k
^f::send j
^g::send h
^z::send {/}
^x::send {.}
^c::send {,}
^v::send m
^b::send n
^!q::^q
^!w::^w
^!e::^e
^!r::^r
^!t::^t
^!a::^a
^!s::^s
^!d::^d
^!f::^f
^!g::^g
^!z::^z
^!x::^x
^!c::^c
^!v::^v
^!b::^b
f::f
;
f & Space::send {f }
f & q::Escape
f & w::`
f & e::Delete
f & r::send fr
f & t::send ft
f & a::send fa
f & s::Enter
f & d::Backspace
f & g::send fg
f & z::Tab
f & x::^F4
;
f & c::send @
f & v::send fv
f & b::send fb
f & y::send fy
f & u::send fu
f & i::send fi
f & o::send fo
f & p::send fp
f & h::send fh
f & j::send fj
f & k::send fk
f & l::send fl
f & n::send fn
f & m::send fm
s::s
s & Space::send {s }
s & q::send sq
s & w::send sw
s & e::send se
s & r::Up
s & t::send st
s & a::send sa
;s & s::
s & d::Left
s & f::Down
s & g::Right
s & z::.
s & x::send sx
s & c::,
s & v::?
s & b::!
s & y::send sy
s & u::send su
s & i::send si
s & o::send so
s & p::send sp
s & h::send sh
s & j::send sj
s & k::send sk
s & l::send sl
s & n::send sn
s & m::send sm
; could be EVEN more
d::d
d & Space::send {d }
d & q::send dq
d & w::send dw
d & e::send de
d & r::send dr
d & t::send dt
d & a::send da
;
d & s::send ds
;;;;;;d & d::send dd
d & f::Home
d & g::PgUp
d & z::send dz
;
d & x::send dx
d & c::send dc
d & v::End
d & b::PgDn
d & y::send dy
d & u::send du
d & i::send di
d & o::send do
d & p::send dp
d & h::send dh
d & j::send dj
d & k::send dk
d & l::send dl
d & n::send dn
d & m::send dm
z::z
z & Space::send {z }
z & q::send zq
z & w::[
z & e::]
z & r::\
;z & t::
z & a::send za
z & s::?
z & d::;
z & f::'
z & g::!
;z & z::
z & x::,
z & c::.
z & v::/
z & b::send {<3}
z & y::send zy
z & u::send zu
z & i::send zi
z & o::send zo
z & p::send zp
z & h::send zh
z & j::send zj
z & k::send zk
z & l::send zl
z & n::send zn
z & m::send zm
q::q
q & Space::send {q }
;q & q::send qq
q & w::&
q & e::*
q & r::(
q & t::)
q & a::send qa
q & s::$
q & d::
clipboard := "%"
send ^v
return
q & f::^
q & g::-
q & z::send qz
q & x::!
q & c::@
q & v::#
q & b::=
q & y::send qy
q & u::send qu
q & i::send qi
q & o::send qo
q & p::send qp
q & h::send qh
q & j::send qj
q & k::send qk
q & l::send ql
q & n::send qn
q & m::send qm
w::w
w & Space::send {w }
w & q::send Yes please call me 0420946997 or Whatsapp/Zalo +61420946997 cheers
;w & w::send ww
w & e::send we
w & r::send wr
w & t::send wt
w & a::send wa
w & s::send ws
w & d::
FormatTime, CurrentDateTime,, yyMMdd
SendInput %CurrentDateTime%
Return
w & f::send 0420946997
w & g::send [email protected]
w & z::send wz
w & x::send wx
w & c::send wc
w & v::send wv
w & b::send wb
w & y::send wy
w & u::send wu
w & i::send wi
w & o::send wo
w & p::send wp
w & h::send wh
w & j::send wj
w & k::send wk
w & l::send wl
w & n::send wn
w & m::send wm
XButton1 & F1::z
XButton1 & F2::a
XButton1 & Shift::q
XButton1 & F4::x
XButton1 & F5::s
XButton1 & F6::w
XButton1 & F7::c
XButton1 & F8::d
XButton1 & F9::e
XButton1 & F10::v
XButton1 & F11::f
XButton1 & F12::r
XButton1 & LButton::b
XButton1 & F15::g
XButton1 & Ctrl::t
XButton2 & F1::/
XButton2 & F2::;
XButton2 & Shift::p
XButton2 & F4::.
XButton2 & F5::l
XButton2 & F6::o
XButton2 & F7::,
XButton2 & F8::k
XButton2 & F9::i
XButton2 & F10::m
XButton2 & F11::j
XButton2 & F12::u
XButton2 & LButton::n
XButton2 & F15::h
XButton2 & Ctrl::y
Space & 1::WheelLeft
Space & 2::WheelRight
Space & 3::8
Space & 4::9
;Space & 5::
;Space & 6::
Space & [::5
Space & `;::WheelDown
Space & '::RButton
Space & ,::Delete
Space & .::!Tab
Space & /::send {!}
^y::send {+}
^u::send {6}
^i::send {7}
^o::send {8}
;^p::send {9}
^[::send {0}
^h::send {=}
^j::send {Home}
^k::send {Up}
^l::send {End}
^`;::send {PgUp}
;^'::send {}
^n::send {-}
^m::send {Left}
^,::send {Down}
^.::send {Right}
^/::send {PgDn}
/*
+F1::F1
+F2::F2
+F3::F3
+F4::F4
+F5::F5
+F6::F6
+F7::F7
LAlt & F8::
ToolTip, da, 100, 150
return
+F9::F9
+F10::F10
+F11::F11
+F12::F12
s::s
s & q::send sq
s & w::send sw
s & e::send se
s & r::send sr
s & t::send st
s & a::send sa
s & s::send ss
s & d::send sd
s & f::send sf
s & g::send sg
s & z::send sz
s & x::send sx
s & c::send sc
s & v::send sv
s & b::send sb
s & y::send sy
s & u::send su
s & i::send si
s & o::send so
s & p::send sp
s & h::send sh
s & j::send sj
s & k::send sk
s & l::send sl
s & n::send sn
s & m::send sm
*/
/*
$q::Delay("=") ;Delay: 300 ms
$w::Delay("7", 2000) ;Delay: 2 seconds
$e::Delay("8")
$r::Delay("9")
$t::Delay("y")
$a::Delay("-")
$s::Delay("4")
$d::Delay("5")
$f::Delay("6")
$g::Delay("{Ctrl Down}{WheelUp 1}{Ctrl Up}")
$z::Delay("+")
$x::Delay("1")
$c::Delay("2")
$v::Delay("3")
$b::Delay("{Ctrl Down}{WheelDown 1}{Ctrl Up}")
*Space::Global Down .= Down ? "" : A_TickCount
*Space Up::Down =
Delay(Key, Delay:=300)
{ ;Standard Delay = 300 ms
Send,% Down And (Down + Delay < A_TickCount)
? Key : SubStr(A_ThisHotkey, 2)
}
*/
/*
; Example: This is a hotkey that temporarily reduces the mouse cursor's speed, which facilitates precise positioning.
; Hold down Ctrl key to slow down the cursor. Release it to return to original speed.
~Ctrl::
IF OrigMouseSpeed
Return
SPI_GETMOUSESPEED = 0x70
SPI_SETMOUSESPEED = 0x71
; Retrieve the current speed so that it can be restored later:
DllCall("SystemParametersInfo", UInt, SPI_GETMOUSESPEED, UInt, 0, UIntP, OrigMouseSpeed, UInt, 0)
; Now set the mouse to the slower speed specified in the next-to-last parameter (the range is 1-20, 10 is default):
DllCall("SystemParametersInfo", UInt, SPI_SETMOUSESPEED, UInt, 0, Ptr, 3, UInt, 0)
Return
~Ctrl up::
DllCall("SystemParametersInfo", UInt, 0x71, UInt, 0, Ptr, OrigMouseSpeed, UInt, 0) ; Restore the original speed.
OrigMouseSpeed =
Return
*/