How can I SetFocus to one of my Dialog boxes?
Moderators: JRL, Dorian (MJT support)
How can I SetFocus to one of my Dialog boxes?
I use Dialogs as Main Menu's in some of my scripts, and at times it would be helpful if I could Setfocus to a Dialog that is up, and pass commands to it as I would any other window. I tried the obvious "Setfocus>Dialogabc*" where the Dialogabc is the name of the Dialog, however it doesn't work. It is odd as even when the window is "focused" I can't pass commands to it via my script, but manually if I hit them the cursor responds properly.
Thanks!
Thanks!
Um, clearly it is impossible to focus a modal dialog from the script that displayed it because the script is waiting for the dialog to close before it can do anything else. I would have though this was obvious. If not read my recent explanation of what modal means in this forum. Modal forms halt execution until they are closed. So while a modal form is displayed the process that displayed it does nothing.
However:
- You should be able to focus a non-modal dialog from within the same script since the script is executing while the dialog is showing.
- It is possible that another application/macro scheduler instance could focus the dialog by focusing the application that owns it (macro scheduler).
However:
- You should be able to focus a non-modal dialog from within the same script since the script is executing while the dialog is showing.
- It is possible that another application/macro scheduler instance could focus the dialog by focusing the application that owns it (macro scheduler).
MJT Net Support
[email protected]
[email protected]
similar question...
Hello, this sounds kind of similar to my question, support helped/gave me a Setfocus to IE Explorer then using a number of Press Tab to get to a specified ID box to enter a number. This works fine unless the target computer has more or less search windows in the browser.
It’s not a big deal for me to compile a few of these with more or less Press Tabs in it but if the target computer ever adds or subtracts a search window like Google I’ll have to go back and change the Macro.
My question is, can I get to that box by using its name?
Shel
And as always many thanks to the great support staff!
It’s not a big deal for me to compile a few of these with more or less Press Tabs in it but if the target computer ever adds or subtracts a search window like Google I’ll have to go back and change the Macro.
My question is, can I get to that box by using its name?
Shel
And as always many thanks to the great support staff!
If I compile two executables, one that creates a dialog (Modal) called "Menu", and launch another Macro executable called "locate" to setfocus on the Modal Window "Menu" according to your reply above this should work, however I still can not setfocus on the "Menu" window, and I have tried using "Macro Scheduler*" and "Menu*" etc. Please advise - thank you. If you have info on this I will read it, or an example that would be great. Thank you.
Works for me. Here's what I did.
1. I started the Dialog Example sample script.
2. I started another instance of Macro Scheduler.
3. I made a script that looked like this:
SetFocus>This is My Dialog
Press ALT
Press F4
Release ALT
4. Run that script and it closed the dialog in the first script.
This would be the same as running two compiled macros.
1. I started the Dialog Example sample script.
2. I started another instance of Macro Scheduler.
3. I made a script that looked like this:
SetFocus>This is My Dialog
Press ALT
Press F4
Release ALT
4. Run that script and it closed the dialog in the first script.
This would be the same as running two compiled macros.
MJT Net Support
[email protected]
[email protected]
Thank you for the prompt reply. I can do what you are doing, however my problem is that (using your example) I would want to be able to run the inital macro "dialog Example" and have it launch/"run" a separate executable from the initial macro (call it "control") that starts just BEFORE the message modal comes up, so when the "This is My Dialog" modal window is up the "control" executable can "setfocus" and tab to the field that I want in preparation for data entry to the "This is My Dialog" modal window again by the user.
The objective is to reset the cursor to the initial field in my dialog always. If you don't then the cursor is where you last left it in the dialog the next time the "show" command is executed which is sloppy.
What happens is the "setfocus" works but control never passes back to the user and the program hangs up and I have to "exit" out of macro Scheduler altogether.
Thank you for your help.
The objective is to reset the cursor to the initial field in my dialog always. If you don't then the cursor is where you last left it in the dialog the next time the "show" command is executed which is sloppy.
What happens is the "setfocus" works but control never passes back to the user and the program hangs up and I have to "exit" out of macro Scheduler altogether.
Thank you for your help.
That won't work because if the second macro is launched by the first then it is owned by the first and is therefore part of the same process. Therefore the modal dialog belongs to it - they are all part of the same process - and the dialog is modal to the process - the process thread is suspended until the dialog is closed.
Maybe one workaround - launch the second macro via a desktop shortcut hotkey or by sending a double click on the shortcut. That way the process is independent as it is started by Windows.
Maybe one workaround - launch the second macro via a desktop shortcut hotkey or by sending a double click on the shortcut. That way the process is independent as it is started by Windows.
MJT Net Support
[email protected]
[email protected]