I cant seem to remove a window from alt-tab list - autohotkey

I confirmed this bit of code a few months and set it aside for when I will need it. I need to exclude a program from alt-tab list, for examples sake, I am using notepad:
WinSet, ExStyle, ^0x80, notepad
Notedpad is still present in alt-tab. I could have sworn this used to work.
Did windows 11 new alt-tab break compatibility? or am I doing it wrong?
Any help would be wonderfull.

You need a timer or a loop to perform an action, each time a window appears:
#Persistent
SetTimer, exclude_program_from_alt_tab_list, 200
Return
exclude_program_from_alt_tab_list:
WinSet, ExStyle, 0x80, ahk_class Notepad ; Windows 11
Return

Related

How to hide the title bar of a program (for example Notepad) using autohotkey

I would like to completely hide the title bar of Notepad. That means that (1) if I switch to existing instances of Notepad, the titles gets hided, (2) if I open new instances of Notepad, the titles gets hided.
I have used the following but it does not work. Any help to correct the code or another solution is welcomed.
#IfWinActive, ahk_class Notepad
WinSet, Style, -0xC00000, A
return
#IfWinActive
#SingleInstance force
#warn
SetTimer, HN, 2500
return
r::Reload
x::ExitApp
HN:
If WinActive("ahk_class Notepad")
WinSet, Style, -0xC00000, A
return
the above code works for me, just tested on win10
It will work Only If Someone Assigns a Hotkey to execute the job... Meaning Something Should Trigger It Somewhere like in the below example.
Note: In the Script below, Both y and z, would perform the same job.
#SingleInstance force
#warn
r::Reload
x::ExitApp
#IfWinActive, ahk_class Notepad
y::WinSet, Style, -0xC00000, A
#IfWinActive
/*or*/
#IfWinActive, ahk_class Notepad
z::
WinSet, Style, -0xC00000, A
return
#IfWinActive
Below ones too can help you further in that direction
If WinActive...
IfWinActive...

Send function key stroke from AutoHotkey to OBS Studio

I am trying to send a keystroke to OBS Studio using AutoHotkey.
The code I am using is
DetectHiddenWindows, On
hWnd := WinExist("ahk_exe obs64.exe")
ControlSend,, {F5}, ahk_id %hWnd%
The function I want to trigger is "start recording"
Nothing is delivered. There is a rumour that the latest OBS does not allow for ControlSend. Is that true? How do I circumvent that?
Use SetKeyDelay (or separate up & down events with delay in between) to make the key be held down for a bit longer.
;hold down for 50ms
SetKeyDelay, -1, 50
ControlSend, , {F5}, ahk_exe obs64.exe
Also, assuming you don't need the hwnd for something else, there's no need to get it.
And it should work just fine as well without detecting hidden windows.

How to find OneNote windows 10 in AutoHotKey's if winexist?

I'm trying to build a script that allows me to open and use OneNote (The store app not OneNote 2016) with a hotkey, but I would like to use the same hotkey to switch the the app from another window. I have accomplished this with many other programs, but never with windows store app. Here is the code I'm trying to use.
#If WinExist("OneNote ahk_class ApplicationFrameWindow", "OneNote")
{
WinActivate,
}
Else
Run, C:\Users\ChrisCochrun\Documents\OneNote
#If
Unfortunately it's not detecting that the window exists and it'll only just launch a new instance of onenote. I've looked for answers, but I'm having trouble making it so that AHK actually sees the window already running and jumping to it.
Thanks very much for any help at all!
If the window's title doesn't start with "OneNote", you need to use
SetTitleMatchMode 2.
The #If-directive is only used for creating context-sensitive hotkeys and hotstrings.
F1:: ; or a hotkey of your choise
SetTitleMatchMode 2
If WinExist("OneNote ahk_class ApplicationFrameWindow", "OneNote")
WinActivate
Else
Run, C:\Users\ChrisCochrun\Documents\OneNote
return
rshfit::
SetTitleMatchMode 2
If WinExist("OneNote for Windows 10")
WinActivate return
;If I use rshift to activate Onenote for Windows 10

Auto Maximize skype live conversation window with Autohotkey

Here is what I'm trying to do and would greatly appreciate any help here.
I am trying to automate maximizing the live conversation window in skype with an Autohotkey script. I'm trying to make it so I can call into a remote machine using skype and have it auto answer (this is native in skype)...once I have a live conversation window I would like to maximize the live conversation window to fill the screen.
I've given this a shot but somehow don't think that I have the correct ahk_class for the live conversation window but there may be something else I am missing. I've placed a the code I've tried using below...any help would be great.
#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.
#Persistent
IfWinExist, TLiveConversationWindow ;
{
WinActivate
WinMaximize
send !{Enter};When using skype normally this Alt+Enter will maximize the window
return
}
I also tried to use this code to determine the proper class for the live conversation window...but has not helped as of yet.
Alt & Enter::
IfWinExist, TLiveConversationWindow
WinActivate
ControlFocus, ClassNN TLiveConversation1
ControlClick, ClassNN TLiveConversation1, , , , 2,
MouseClick, left, , , 2
send !{Enter}
; now we get the ID & CLASS
WinGet, Active_Window_ID, ID, A
WinGetClass, Active_Window_Class, A
MsgBox, The active window's class is "%Active_Window_class%" and ID is %Active_Window_ID%
Was able to get a simplified version of the code to work with a hotkey to initiate but have not been able to get the WinWait function to work as per #Schneyer.
Functioning Code activated by hotkey
#NoEnv
#Warn
#Persistent
SendMode Input
SetWorkingDir %A_ScriptDir%
; Skype Maximizer initiating functions
^!p::
;WinWait ahk_class TLiveConversation1
;WinWait ahk_class TConversationForm
;WinWait ahk_class TLiveConversationWindow
;WinMaximize ahk_class TLiveConversation1
;functioning code
;Activate tSkMainForm.
WinActivate ahk_class tSkMainForm
;Send Alt Enter Input to maximize.
SendInput !{Enter}
;TLiveConversationWindow Always On Top
WinSet, AlwaysOnTop,,ahk_class TLiveConversationWindow
;Minimize main form
WinMinimize ahk_class tSkMainForm
Return
When swapping the ^!p:: with any of the WinWait Functions nothing seems to happen. The WinWait seems like it should be the proper method, any thoughts on why it won't work?
Problems
#persistent lets the script run, but your code still gets executed only once when you start the script. After that it stays active but does nothing.
Use a WinWait to wait for the window to appear (wrap it in a Loop if you want it to run more than once).
Use ahk_class to to search for a window class instead of the window title
Working code
You can use the Window Spy tool which is included in AHK. Use the tray icon menu of a running AHK script to start it.
I use TConversationForm in the code, but it works with every window class.
#NoEnv
#Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
WinWait ahk_class TConversationForm
WinActivate
WinMaximize
Scanning through AHK forums I was able to find a post that led me to the answer for this little problem. Check the below link for further information.
https://autohotkey.com/board/topic/96491-detect-when-a-classnn-window-exists/
The problem with using ahk_class to identify when a skype call was active is that the "active call window" identified as classNN TLiveConversation1 in the inspector was actually a Control within the window of ahk_class tSkMainForm rather than a Window. This made the WinWait function ineffective at identifying it when the call initiated.
In order to identify the Control it is necessary to loop through the controls (using WinGet) in ahk_class tSkMainForm until the TLiveConversation exists and then kick off any subroutines needed. For me that was to maximize the live conversation window.
You'll see the code to do this starting with the WinGet function. All of this is wrapped in a while loop so that it will run persistently allowing it to be called over and over. In essence this code will do the following:
Create a list (SkypeControlList) of controls existing in ahk_class tSkMainForm.
Continually Loop Through SkypeControlList
When a new Live Conversation is initiated a control TLiveConversation1 will exist
Once TLiveConversation1 esists run necessary code
#NoEnv
#Warn
#Persistent
SendMode Event
SetWorkingDir %A_ScriptDir%
DetectHiddenWindows, on
stop = 0
Loop
{
While stop = 0
{
WinGet, SkypeControlList, ControlList, ahk_class tSkMainForm
Loop, Parse,SkypeControlList, `n
{
;Loop to search for control TLiveConversation1
if (A_LoopField = "TLiveConversation1")
{
;Deactivate active screensaver
PostMessage, 0x0112, 0x0F060, 0,, A
;RegWrite REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, ScreenSaveActive, 0
;SetKeyDelay, 500
Send {Esc}
;Activate tSkMainForm.
WinActivate ahk_class tSkMainForm
;Send Alt Enter Input to maximize.
Send !{Enter}
;TLiveConversationWindow Always On Top
WinSet, AlwaysOnTop,,ahk_class TLiveConversationWindow
stop = 1
sleep, 100
}
}
}
IfWinExist ahk_class TLiveConversationWindow
{
stop = 1
sleep, 1000
}
IfWinNotExist ahk_class TLiveConversationWindow
{
;Minimize all windows by win+D show desktop
send #d
sleep,1000
; is that call quality feedback window up? kill it.
SetTitleMatchMode, Regex
WinClose, ^Skype.*Call quality feedback$
stop = 0
}
sleep 1000
}
Return
The above code works great as long as there is no screen saver active on the machine being called. If there is an active screen saver the call will answer but the screen saver will not go away. You can see remnants of code trying to wake the computer from a screen saver (This does not currently work).
I've also added a few bits of code to clean up the experience such as removing the call quality popup window that skype throws up after a call as well as clearing the desktop after the call ends.
Thanks to #Blauhirn and #Schneyer for their input in trying to get this solved.

script opens document but not with hotkey

I'm creating a script to open and run with a program that has no help files but comes with a huge PDF manual. There is no way to open it from the program, so I have set up a command to open it. The command opens the PDF when run on its own, but when I assign a hotkey, it does not work. What very basic information am I missing?
thanks,
Ellen
SetTitleMatchMode, 2
runwait C:\Program Files\FontLab\TypeTool3\TTool3.exe, , max
IfWinExist TypeTool 3
Return
ExitApp
Return
#ifWinActive, TypeTool 3
$wheeldown::wheelup
$wheelup::wheeldown
F1::
Run, C:\Documents and Settings\Ellen\My Documents\TypeTool3WinMan.pdf
Return
#ifWinActive
Do you have a Return before your #IfWinActive statement? If not then during startup the script will run every line until it hits the first Return, which seems to be all the way to the end for you. So also place a return after your Run, C:..... command
And oh.. Are you sure about that weird long ahk_class? It could be correct but it looks strange and if this is just a littlebit off, your hotkey would never work, so try it first with the #IfWinActive line commented out.
SetTitleMatchMode, 2
;All the stuff you want to run at startup....
Return
#ifWinActive, (part of) the window name here e.g. Excel
$wheeldown::wheelup
$wheelup::wheeldown
F1::
Run, C:\Documents and Settings\Ellen\My Documents\TypeTool3WinMan.pdf
Return
#ifWinActive