I had a request for this and I am not sure how to do it. In an application actually an old applicaion, (I think origionally VB for Dos) that is now running in windows, The user presses F12 to save the file and presses Y to confirm it. The goal is to stop this from happening and run a confirmation script in between the prosess that is triggered from F12.
My though was to turn off F12 have the user press a different Key combo, run the script, enable the F12 key. Send F12 and then the Y key. However this is unacceptable to them. They don't want to have to remember a key combination they want F12 period.
Any ideas on how to do this? It would mean taking away control of F12 from the application and assigning it to only Macro Scheduler, even though the other applicaiton is waiting for a key stroke from it.
Disabling key and taking control
Moderators: JRL, Dorian (MJT support)
Assuming there is a way to disable and enable F12 within the application:
Start with F12 disabled > Compile the following and run it in the background.
//VK123 = F12
OnEvent>KEY_DOWN,VK123,0,KeyPress
//VK123 as Event Para with 5 as Extra Para = Ctrl+Alt+F12
OnEvent>KEY_DOWN,VK123,5,KillThis
Let>QuitThis=0
Label>start
If>QuitThis=1,end
Wait>0.01
Goto>start
SRT>KeyPress
Macro>[Drive]:\[Path]\ScriptToBeRun.scp
Set>Application Window Name*
//what ever code is required to enable F12
Press F12
WaitWindowOpen>Save*
Wait>0.1
Send>y
//what ever code is required to disable F12
END>KeyPress
SRT>KillThis
Let>QuitThis=1
END>KillThis
Start with F12 disabled > Compile the following and run it in the background.
//VK123 = F12
OnEvent>KEY_DOWN,VK123,0,KeyPress
//VK123 as Event Para with 5 as Extra Para = Ctrl+Alt+F12
OnEvent>KEY_DOWN,VK123,5,KillThis
Let>QuitThis=0
Label>start
If>QuitThis=1,end
Wait>0.01
Goto>start
SRT>KeyPress
Macro>[Drive]:\[Path]\ScriptToBeRun.scp
Set>Application Window Name*
//what ever code is required to enable F12
Press F12
WaitWindowOpen>Save*
Wait>0.1
Send>y
//what ever code is required to disable F12
END>KeyPress
SRT>KillThis
Let>QuitThis=1
END>KillThis
Disabling the key
That is the problem, I would need to disable the applications rights to accept input from the F12 key. The way it would work is that the user clicks on my compiled macro. This macro accepts a parameter that is passed to it on start up. This paremeter is placed in a field on the screen.
At this point the user does their work and when they are finished they press F12. This is what I need to intercept. so I could leave the first macro running and just waiting for the key. However, since I don't know how the program works that normally accepts the F12 key my though was to somehow turn it off and assign it to Macro Scheduler.
If that cannot be done I was wondering and have never tested it, but can two applicaitons be waiting for the same key to be pressed. In other words, when the user presses F12 it triggers what they normally want to do, but at the same time it triggers a Macro. This way both run and I set focus to my screen and don't allow them to leave it.
Any ideas?
At this point the user does their work and when they are finished they press F12. This is what I need to intercept. so I could leave the first macro running and just waiting for the key. However, since I don't know how the program works that normally accepts the F12 key my though was to somehow turn it off and assign it to Macro Scheduler.
If that cannot be done I was wondering and have never tested it, but can two applicaitons be waiting for the same key to be pressed. In other words, when the user presses F12 it triggers what they normally want to do, but at the same time it triggers a Macro. This way both run and I set focus to my screen and don't allow them to leave it.
Any ideas?
Hmmmm...
If you have Onevent running in the back ground waiting for F12 to be pressed and if the pressing of F12 in the application always brings up the window that is waiting for additional user input, It seems what you are asking should be feasible.
The back ground script will detect that F12 was pressed and so will the application. Have the back ground script do what it needs to do then return to the app and press "y" to finish the save. I have no way to test your specific application but I think this could work.
If you have Onevent running in the back ground waiting for F12 to be pressed and if the pressing of F12 in the application always brings up the window that is waiting for additional user input, It seems what you are asking should be feasible.
The back ground script will detect that F12 was pressed and so will the application. Have the back ground script do what it needs to do then return to the app and press "y" to finish the save. I have no way to test your specific application but I think this could work.