I have several programs I open/use every day. Some days I shut the machine off, mostly I use Hibernate. When I open these programs, I now use keyboard shortcuts to (1) Maximize the screen, (2) go to a specific part of the program, and (3) open a prompt, etc.
I cannot figure out how to get AHK to recognize that a program (Microsoft Word for instance) just opened and when that program finishes loading, it runs a script. Can someone let me know if this is possible. I've searched the Community, and searched on Google without any luck.
Run Script on Program Load
Started by
aahkuser
, May 01 2009 04:27 PM
10 replies to this topic
#1
-
Posted 01 May 2009 - 04:27 PM
Why not show us what you have already?
Also, we need to know what program (I know you said Word, but you also said for example), and what you want it to do.
Also, we need to know what program (I know you said Word, but you also said for example), and what you want it to do.
#2
-
Posted 01 May 2009 - 05:13 PM
This is the example for a program I use at work. I need to (1) cancel a prompt window, (2) align the window to the top left, (3) re-size the program window, (4) press a button to view the main window.
This all works fine, but you requested the code, etc. The problem I have is that whenever I load the program (usually once a day, but some times several times) and it's annoying pressing the key combination each time. I want it to do this when the program is done loading, is it possible to have on_formload or something like that similar to Microsoft Access?
(2) I have the same sort of thing randomly in Windows Media Player where it loads the "Now Playing" window and when the program loads, I want it to automatically do browser back.
This all works fine, but you requested the code, etc. The problem I have is that whenever I load the program (usually once a day, but some times several times) and it's annoying pressing the key combination each time. I want it to do this when the program is done loading, is it possible to have on_formload or something like that similar to Microsoft Access?
#IfWinActive Winworks AutoShop ahk_class #32770 ^!+d:: { Send, n Sleep, 275 WinGetPos, InitialWindowPosX, InitialWindowPosY, InitialWindowSizeX, InitialWindowSizeY If InitialWindowPosX <> 0 { If InitialWindowPosY <> 0 { WinMove, 0,0 } } MouseClickDrag, Left, 100,749,100,769 Sleep, 100 MouseClick, left, 202, 78 } return
(2) I have the same sort of thing randomly in Windows Media Player where it loads the "Now Playing" window and when the program loads, I want it to automatically do browser back.
#3
-
Posted 04 May 2009 - 10:26 PM
EDIT:
I have created a kind of template.
Hope it fits your needs.
Example 2 - Alerts when loaded only
Example 3 - Alerts when closed only
Example 4 - Alerts when loaded only using a single "return"
=============================================================
Also, instead of
I have created a kind of template.
Hope it fits your needs.
EDIT: removed old code for "OnLoad/OnClose Script Template" by MasterFocus Please see github.com/MasterFocusExample 1 - Alerts when loaded and also closed
Example 2 - Alerts when loaded only
Example 3 - Alerts when closed only
Example 4 - Alerts when loaded only using a single "return"
=============================================================
Also, instead of
WinGetPos, InitialWindowPosX, InitialWindowPosY, InitialWindowSizeX, InitialWindowSizeY If InitialWindowPosX <> 0 { If InitialWindowPosY <> 0 { WinMove, 0,0 } }you may try this:
WinGetPos, InitialWindowPosX, InitialWindowPosY If InitialWindowPosX AND InitialWindowPosY WinMove, 0,0(don't know if you're using InitialWindowPos, but seems unnecessary)
#4
-
Posted 05 May 2009 - 04:03 PM
Nice work, MasterFocus. I've made a few tweaks:
- Shorter.
- Less dynamic variable references. This should prove a little more efficient.
- OnOpen instead of OnLoad. I figure "Open" more naturally opposes "Close".
- OnOpen can be defined without OnClose, and vice versa.
; Original script by MasterFocus. See original post for instructions. EDIT: code removed - please see github.com/MasterFocus for up-to-date codeNotable differences:
- Shorter.
- Less dynamic variable references. This should prove a little more efficient.
- OnOpen instead of OnLoad. I figure "Open" more naturally opposes "Close".
- OnOpen can be defined without OnClose, and vice versa.
#5
-
Posted 06 May 2009 - 10:22 AM
Thanks a lot. This is take some time to go through, lol. But it looks like its exactly what I need.
Also, I have been looking for an Intellisense editor for AHK (more or less a copy of the VBA editor in M-Office). Does anyone have a recommendation?
Also, I have been looking for an Intellisense editor for AHK (more or less a copy of the VBA editor in M-Office). Does anyone have a recommendation?
#6
-
Posted 06 May 2009 - 05:08 PM
Also, I have been looking for an Intellisense editor for AHK (more or less a copy of the VBA editor in M-Office). Does anyone have a recommendation?
Something like that?
<!-- m -->http://www.autohotke...opic.php?t=1371<!-- m -->
________
WASHINGTON MEDICAL MARIJUANA DISPENSARY
#7
-
Posted 06 May 2009 - 08:28 PM
I'll have to look at the thread more, but I don't think it's enough, because I also need to be exactly like VBA in that it makes "; comments" green (or some color), reminds me to close a bracket, in addition to the auto-complete.
I looked at the AHK Editor and one another one, but didn't find them similar at all and have just been using Notepad from then on.
I looked at the AHK Editor and one another one, but didn't find them similar at all and have just been using Notepad from then on.
#8
-
Posted 07 May 2009 - 06:45 AM
Also, I have been looking for an Intellisense editor for AHK (more or less a copy of the VBA editor in M-Office). Does anyone have a recommendation?
Is this what you are looking for?
http://www.autohotke...topic41503.html
#9
-
Posted 07 May 2009 - 07:16 AM
Lexikos, you pointed out some interesting things I did not know.
Thanks for the modifications.
Thanks for the modifications.
#10
-
Posted 11 May 2009 - 07:30 PM
I use Bill2's Process Manager to control priorities and affinities. It has the option to launch side programs when the desired process starts or ends ans since I'm running it anyway, I use it to launch similar add-on scripts that you described. The program would be overkill for script launching alone, but I'd recommend it to anyone who is also looking for priotity and affinity management for a multi-core machine.
Warning: To be useful, Bill2 needs to be run in learning mode at first, which consists of lots of pop ups each time a new process is detected asking if you want to set a rule for it. The pop ups are annoying, but once you have Bill2 set up, it can be of great value.
Warning: To be useful, Bill2 needs to be run in learning mode at first, which consists of lots of pop ups each time a new process is detected asking if you want to set a rule for it. The pop ups are annoying, but once you have Bill2 set up, it can be of great value.
#11
-
Posted 11 May 2009 - 10:52 PM
Hardware: fast laptop with SSD
Software: Win 7 Home Premium 64-bit, android for phone and tablet