- I have an app called (sizer 4.0) which uses hotkeys to resize/move selected windows.
- In sizer 4.0, one hotkey I have set is (alt + m) which resizes a window and centers it on-screen.
A few of my applications won't start up at the center of my screen (when I launch their exe files). Can someone think up a script which will automatically run a (alt + m) keystroke when I start up those applications?
For example: I double-click firefox, autohotkey sees that firefox.exe has launched, the (alt + m) keystroke will automatically register w/out me typing it?
So, quite literally, an automatic hotkey (automatically run/register a keystroke when a specific exe launches)
[Automatic Hotkey] Auto-run an existing hotkey when an app starts?
-
- Posts: 2
- Joined: 01 May 2019, 21:48
Re: [Automatic Hotkey] Auto-run an existing hotkey when an app starts?
Try this:
Replace the executable names on the WinWaitActive line to the names of your executables (without the ".exe"). Add more by adding more pipe (|) characters. All of the array, process and ID business is just to prevent Ctrl+M from being sent to each window more than once (at launch).
Code: Select all
#SingleInstance Force
SetTitleMatchMode, RegEx
ProcessArray := []
Loop
{
WinWaitActive, ahk_exe i)\\notepad|winword|wordpad\.exe$ ; Wait for one of the applications to open
WinGet, ProcessID, PID ; Get the process ID (PID) of the application's window
If(!ProcessArray[ProcessID]) ; If the window isn't recognized in the array
{
Send, ^m
ProcessArray[ProcessID] := true ; Add the window's PID to the array
}
WinWaitNotActive ; Wait until the window is no longer active
For index, value in ProcessArray ; Loop through the array
If(!WinExist("ahk_pid " index)) ; If any recognized window no longer exists
ProcessArray.Delete(index) ; Delete the window's PID from the array
}
-
- Posts: 2
- Joined: 01 May 2019, 21:48
Re: [Automatic Hotkey] Auto-run an existing hotkey when an app starts?
Thanks for the response! They keystroke was (alt + m) so I switched '^m' to '!m'. That kind of works but some of the applications are .Ink files...
Re: [Automatic Hotkey] Auto-run an existing hotkey when an app starts?
Sorry about that. I misremembered you as wanting Ctrl+M.fakerwilliam wrote: ↑02 May 2019, 20:35Thanks for the response! They keystroke was (alt + m) so I switched '^m' to '!m'. That kind of works but some of the applications are .Ink files...
As for .lnk files, those are just shortcuts to other files. You need to right-click on them, choose Properties and then see what the names of the files are in the Target boxes.