I have a Script that toggle a source in SLOBS (OBS), how can I make it that the keypress get only send to OBS, mostly my games also react to the Hotkeys, maybe it's possible to get the keypress only send to OBS so that the game is not affected by it, is this possible my actual script:
#Persistent
SetTimer, PressTheKey, 1800000
Return
PressTheKey:
Send, {F24 down}
Sleep, 50
Send, {F24 up}
Sleep, 10000
Send, {F24 down}
Sleep, 50
Send, {F24 up}
return
You need to use ControlSendRaw.
Related
I have created a hotkey that I want to use only in MS Teams (workaround for the lack of 'Reply to message' function).
I assigned it to Ctrl+R, however it seems that it prevents other applications that use the same combination from noticing the hotkey.
The code is below:
^r::
if WinActive("ahk_exe Teams.exe")
{
SoundBeep 200,500
Send, ^c
Send, {Tab}
Send, >
Sleep, 500
Send, ^v
Send, {Enter}
Send, {Enter}
}
return
Is there a way to tell AHK to let the key combination bubble up when the active app is NOT teams?
I tried adding an 'else' clause in which I would Send, ^r but that didn't work.
Actually, I got it. Posting the working solution.
It seems I needed to wrap the hotkey declaration within the #ifwinactive directive.
#IfWinActive("ahk_exe Teams.exe")
^r::
SoundBeep 200,500
Send, ^c
Send, {Tab}
Send, >
Sleep, 500
Send, ^v
Send, {Enter}
Send, {Enter}
return
#IfWinActive
An even better, comprehensive solution and more powerful approach by #ThierryDalon - https://github.com/tdalon/ahk/blob/master/Lib/Teams.ahk
https://tdalon.blogspot.com/2020/11/teams-shortcuts-smart-reply.html
I'm impressed with what AutoHotkey can do. How can I optimize that code? What do I need to know?
SetTitleMatchMode RegEx ;
::/act1::
Send {LControl down}
Send {LShift down}
Send {m}
Send {LControl up}
Send {LShift up}
Send {Left 3}
Send {LShift down}
Send {Home}
Send {LShift up}
Send {LControl down}
Send {c}
Send {LControl up}
WinActivate WidnowA
Send {LControl down}
Send {Home}
Send {LControl up}
Send {Down 1}
Send {Right 12}
Send {LControl down}+{v}
Send {LControl up}
Send {,}
Send {Space}
Send {LControl down}
Send {s}
Send {LControl up}
CoordMode, Mouse, Screen
x := 150
y := 1420
Click %x% %Y%
Send {Right 3}
return
I think that no need to describe the sections, but.. can I write it another (easiest) way?
Thanks
Along with the possible typo David found, you can condense a lot of your send commands into one line. Also, does it need to be left control and shift or will either do? I've written it below without specifying.
SetTitleMatchMode , RegEx
CoordMode, Mouse, Screen
::/act1::
Send , ^+m{left 3}+{home}^c
WinActivate , WindowA
Send , ^{home}{down}{right 12}^v{,}{space}^s
Click , 150 , 1420
Send , {right 3}
Return
As far as writing it an easier way, it will help to know what you're trying to accomplish. It's likely that what you're trying to do can be done more reliablely by manipulating controls directly instead of sending keystrokes.
I don't see a lot of room to optimize here as there isn't much repetition going on. If you had the same series of keystrokes being used, you could reduce repetition with a function. However, it does appear that you have a typo at "WinActivate WidnowA"
One possible improvement is changing your use of "Send" to "SendInput" which is "generally faster and more reliable".
aI use AutoHotKey to remap a few keys, and that has been extremely useful. Example:
!t::
Send, ^t
return
That would intercept Alt-t key and send Ctrl-t instead.
I was wondering if there's a way to intercept an Alt-LeftMouseClick and send Ctrl-LeftMouseClick instead?
This maps ALT+LeftMouseClick to Ctrl+LeftMouseClick
!lbutton::send ^{click}
Turns out, I could do it with:
!LButton::
Send, {Control down}
MouseClick
Send, {Control up}
return
I have a long list folders that i need to automatically spreadsheet the following two pieces of information into our existing excel document:
Folder Name
File count within that folder
I've written the script up to the point where i now need AHK to get the file count of the active explorer window, copy to clipboard and ALT+TAB/Paste it into the spreadsheet. I plan to loop this script using 'goto' and just monitoring it until it reaches the last folder and use ESC to end the script by eye.
Whats the easiest way to get the numerical value file count of the active window and have it copied to clipboard?
My code so far which is basically using F2 to 'rename' thus copy folder name, alt+tab to spreadsheet, paste it in, move to the file count cell on the spreadsheet, alt+tab back to active explorer window, step into said folder -- and now i'm stuck (where i need to get file count onto clipboard). It's worth noting that i would want the file count to ignore system files like .DS_Store if they're present.
`::
{
Send, {F2}
Sleep, 200
Send, {Ctrl Down}
Sleep, 50
Send, c
sleep, 50
Send, {Ctrl Up}
Sleep, 100
Send, {Alt Down}
Sleep, 50
Send, {Tab}
Sleep, 50
Send, {Alt Up}
Sleep, 100
Send, {Ctrl Down}
Sleep, 50
Send, v
sleep, 50
Send, {Ctrl Up}
Sleep, 100
Send, {Right}
Sleep, 50
Send, {Right}
Sleep, 50
Send, {Right}
Sleep, 100
Send, {Alt Down}
Sleep, 50
Send, {Tab}
Sleep, 50
Send, {Alt Up}
Sleep, 100
Send, {Enter}
^^^^^^^^^^^^^ Need my file count / copy to clipboard here
Esc::ExitApp
}
Maybe have a look at something like this (and follow along in the comments):
; Calculate the number of files in a folder and its subfolders:
SetBatchLines, -1 ; Make the operation run at maximum speed.
FileNum = 0
; FileSelectFolder, WhichFolder ; Ask the user to pick a folder.
WhichFolder := Clipboard ; assumes full path to folder is in clipboard
Loop, Files, %WhichFolder%\*.*, R
{
if A_LoopFileAttrib contains H,R,S ; Skip Hidden, Read-only, or System files
continue ; Skip this file and move on to the next one
FileNum += 1
}
Clipboard := FileNum
ClipWait ; Wait for the clipboard to contain text.
MsgBox %WhichFolder% has %FileNum% files in it (incl. subfolders).
Then, have a look at the following which explains how to read and loop through directories and files:
https://autohotkey.com/docs/commands/LoopFile.htm.
Hth, let us know how you make out . . .
I have successfully made it so that when I hold down the right mouse button I can control the system volume with The scroll wheel. But my problem now is that every time that I release the right button it still right clicks even if I have changed the volume.
I want to retain the normal right click, but not when I have used the right mouse button in a macro (then it should ignore the release of the right mouse button). How do I best add a script to ignore mouse clicks in this situation?
This is what I use at the moment:
~RButton & WheelUp::Send {Volume_Up}
And I like it for its brevity (also, other ways have shown to be buggy), so I hope that there is a simple solution that I have missed.
I think it should be possible to have a timer based solution that works (like for double right click as shortkeys), but I have been unable to use that solution.
Here are solutions I have found that Don't quite solve it:
RButton & WheelUp::Send {Volume_Up} ; inactivates right click
RButton:: click right ; gets right click back, but unable to have right click pressed
;(dragging things with right click, etc would be impossible)
RButton & WheelUp:: Send {Volume_Up}
RButton & WheelDown::Send {Volume_Down}
OK, here is a better solution, I think.
~RButton & WheelUp::
Send {Volume_Up}
SetTimer, CloseContextMenu, 50
return
~RButton & WheelDown::
Send {Volume_Down}
SetTimer, CloseContextMenu, 50
return
CloseContextMenu:
KeyWait, RButton, R
WinGetTitle, active_title, A
WinGetClass, active_class, A
WinActivate, ahk_class Progman ;desktop
WinWaitActive, ahk_class Progman
Send, {ALT Down}{ALT Up} ; try also: Send, {Esc} (remove the Alt command)
SetTimer, CloseContextMenu, off
WinActivate, %active_title% ahk_class %active_class%
return
~RButton & WheelUp::
Send {Volume_Up}
SetTimer, CloseContextMenu, 50
return
~RButton & WheelDown::
Send {Volume_Down}
SetTimer, CloseContextMenu, 50
return
CloseContextMenu:
KeyWait, RButton, R
Send, {Esc}
SetTimer, CloseContextMenu, off
return
Try also this:
#NoEnv
SendMode Input
#SingleInstance Force
Process, Priority, ,High
#InstallKeybdHook
#InstallMouseHook
#UseHook
#MenuMaskKey vk07 ; is used to mask Win or Alt keyup events
; http://ahkscript.org/docs/commands/_MenuMaskKey.htm
return
~RButton & WheelUp::
Send {Volume_Up}
SetTimer, CloseContextMenu, 50
return
~RButton & WheelDown::
Send {Volume_Down}
SetTimer, CloseContextMenu, 50
return
CloseContextMenu:
KeyWait, RButton, R
Send, {ALT Down}{ALT Up}
SetTimer, CloseContextMenu, off
return