Saving a file to a specific subdirectory
Moderators: Dorian (MJT support), JRL
Saving a file to a specific subdirectory
I use pdffactory pro (pdff) to produce pdfs.
I would like to use Macro Sch to open up the save button in pdff and to save the file to the d:\ drive.
I would like some help in that part of the coding because:
1. The save buttons does not have any uderline text.
2. The save window can be at any part of the screen depending on where left last time.
3. There is no drop down menu, only a save button, giving the option to save.
4. The save window shows an explorer type tree of the files. It defaults to showing the folder which was used last. I therefore have to find a way of moving to the correct directory.
5. The save directories are accessed by a drop down bar.
Robin
I would like to use Macro Sch to open up the save button in pdff and to save the file to the d:\ drive.
I would like some help in that part of the coding because:
1. The save buttons does not have any uderline text.
2. The save window can be at any part of the screen depending on where left last time.
3. There is no drop down menu, only a save button, giving the option to save.
4. The save window shows an explorer type tree of the files. It defaults to showing the folder which was used last. I therefore have to find a way of moving to the correct directory.
5. The save directories are accessed by a drop down bar.
Robin
For the button and the frame, many operations can be done "relative" to the position of the current window / frame.
You can often focus on specific windows, and use MouseMoveRel (or other operations, like pressing tab to move to specific fields.)
As for the tree list, you may be able to do something like use the minus key to 'colapse' all branches, then use GetControlText to see the contents of the list (I'm uncertain right now, I haven't tested it). You can then see which root branch you want, navigate to it, use + to expand it, then get the list again. (All theory, I don't know if it would work).
In some cases, a save-as window will provide the ability to enter the path name manually in to an editbox, and the tree will auto-adjust to that location... sometimes you need to use a wildcard (c:\windows\*.*) for it to realise you want to change to that directory, rather than attempting to use it as the path/filename.
You can often focus on specific windows, and use MouseMoveRel (or other operations, like pressing tab to move to specific fields.)
As for the tree list, you may be able to do something like use the minus key to 'colapse' all branches, then use GetControlText to see the contents of the list (I'm uncertain right now, I haven't tested it). You can then see which root branch you want, navigate to it, use + to expand it, then get the list again. (All theory, I don't know if it would work).
In some cases, a save-as window will provide the ability to enter the path name manually in to an editbox, and the tree will auto-adjust to that location... sometimes you need to use a wildcard (c:\windows\*.*) for it to realise you want to change to that directory, rather than attempting to use it as the path/filename.
Debugger
Thank you for your helpfull reply. I am well on the way to completing the macro.
I am trying to debug part of the macro. In order for the debugger to run effectively I think I have to keep the focus of the macro on the program I wish to run. How do I do it when in order to debug I have to be focused in Macro Sch. I have tried pressing F8 when in the other program and it does not step the Macro Scheduler.
I am trying to debug part of the macro. In order for the debugger to run effectively I think I have to keep the focus of the macro on the program I wish to run. How do I do it when in order to debug I have to be focused in Macro Sch. I have tried pressing F8 when in the other program and it does not step the Macro Scheduler.
Robin
In the debugger, select "Debug -> Refocus Windows" (from the drop down list).
If your script contains a "setfocus" at the start, it will focus to the window, pause and go to the debug window. When you press F8 again, it will automtically re-focus the save-as window (or whatever window was in focus at the time before it went back to the debugger).
If your script contains a "setfocus" at the start, it will focus to the window, pause and go to the debug window. When you press F8 again, it will automtically re-focus the save-as window (or whatever window was in focus at the time before it went back to the debugger).
Sorry but I can not get the focus right. The following causes ALT S in macro sch instead of pdff. What am I doing wrong?
SetFocus>pdffactory pro*
WaitWindowOpen>pdffactory pro*
Press ALT
//save button
Send Character/Text>S
Also someone advised me earlier of a macro that reports back the window name. Does anyone know where it is to be found because it is no longer in my list of macros.
SetFocus>pdffactory pro*
WaitWindowOpen>pdffactory pro*
Press ALT
//save button
Send Character/Text>S
Also someone advised me earlier of a macro that reports back the window name. Does anyone know where it is to be found because it is no longer in my list of macros.
Robin
Unfortunately I am obviously doing something wrong when using debug, because even with the addition of the Let>WF_TYPE=0 I am still not getting the focus right. It is defaulting to opening the search menu in MSch.
This problem is important to me because I need to step through the program.
I would therefore appreciate some more help.
This problem is important to me because I need to step through the program.
I would therefore appreciate some more help.
Robin
You also should enable Refocus Windows under the debug menu.
Also having WaitWIndowOpen after a SetFocus for the same window doesn't make much sense and could cause it to fail. Should be the other way round. You should also Release the ALT key or you could get weird results later when you send other keys.
WaitWindowOpen>pdffactory pro*
SetFocus>pdffactory pro*
Press ALT
//save button
Send Character/Text>S
Release ALT
Try this simple example:
1. Create a new macro and paste in this code:
//Start
Let>WF_TYPE=0
WaitWindowOpen>Notepad*
SetFocus>Notepad*
Send>Hello
//End
2. Run Notepad
3. In the script editor ensure Refocus Windows is selected under the Debug menu.
4. Place the cursor on the FIRST line and hit F8. Press F8 to step from line to line. When you get to the SetFocus line, Notepad should get focused. Wait a brief moment and the editor will refocus. Press F8 again and Notepad will refocus and Hello will be sent to the Notepad window.
You should get the same results as me. Now follow the same steps with your window instead.
Without the WF_TYPE the debugger may find the script editor. With WF_TYPE=0 child windows are not searched and so it cannot find itself. So for debugging this is useful.
Also having WaitWIndowOpen after a SetFocus for the same window doesn't make much sense and could cause it to fail. Should be the other way round. You should also Release the ALT key or you could get weird results later when you send other keys.
WaitWindowOpen>pdffactory pro*
SetFocus>pdffactory pro*
Press ALT
//save button
Send Character/Text>S
Release ALT
Try this simple example:
1. Create a new macro and paste in this code:
//Start
Let>WF_TYPE=0
WaitWindowOpen>Notepad*
SetFocus>Notepad*
Send>Hello
//End
2. Run Notepad
3. In the script editor ensure Refocus Windows is selected under the Debug menu.
4. Place the cursor on the FIRST line and hit F8. Press F8 to step from line to line. When you get to the SetFocus line, Notepad should get focused. Wait a brief moment and the editor will refocus. Press F8 again and Notepad will refocus and Hello will be sent to the Notepad window.
You should get the same results as me. Now follow the same steps with your window instead.
Without the WF_TYPE the debugger may find the script editor. With WF_TYPE=0 child windows are not searched and so it cannot find itself. So for debugging this is useful.
MJT Net Support
[email protected]
[email protected]
1. I am getting an error message when I try to close the script editor:
List index out of bounds (-1).
What should I do to correct it?
2. I am also finding my code is opening up the window task manager. This is not supposed to happen.
3. Pdff is strange in that the window is called pdffactory pro when it is focused and page 1 when it is not focused. How do I retain the focus in such a situation.
4. Someone told me about a program that reports back the window name. I need to download it again.
List index out of bounds (-1).
What should I do to correct it?
2. I am also finding my code is opening up the window task manager. This is not supposed to happen.
3. Pdff is strange in that the window is called pdffactory pro when it is focused and page 1 when it is not focused. How do I retain the focus in such a situation.
4. Someone told me about a program that reports back the window name. I need to download it again.
Robin
1. This sounds like there's an error with one of your macro settings. Open up each macro in turn, check it's settings and close it again. If still a problem email a copy of your macros.dat file to support.
2. You've probably sent keystrokes to somewhere other than you intend to.
3. Get the handle of it instead. When you know it is focused (when it is first run, for example) or when you can be sure of it's title, set WIN_USEHANDLE to 1 and then use GetActiveWindow. This will retrieve the window's handle which will not change during the session. Remember to set WIN_USEHANDLE back to 0 before any other window functions if you want to use titles again:
Let>WIN_USEHANDLE=1
GetActiveWindow>pdf_handle,x,y
Let>WIN_USEHANDLE=0
Assuming PDFFactory was active when you run the above code you will now have it's handle in pdf_handle and can use that later in the script (when setting WIN_USEHANDLE to 1) to focus it.
4. I think they were referring to GetActiveWindow. Assign the following to a hot key and it will tell you the active window name:
GetActiveWindow>title,x,y
MessageModal>title
It has to be run from a hot key so that the act of running it from Macro Scheduler doesn't move focus to Macro Scheduler.
Alternatively use View/System Windows from the Tools menu in Macro Scheduler.
2. You've probably sent keystrokes to somewhere other than you intend to.
3. Get the handle of it instead. When you know it is focused (when it is first run, for example) or when you can be sure of it's title, set WIN_USEHANDLE to 1 and then use GetActiveWindow. This will retrieve the window's handle which will not change during the session. Remember to set WIN_USEHANDLE back to 0 before any other window functions if you want to use titles again:
Let>WIN_USEHANDLE=1
GetActiveWindow>pdf_handle,x,y
Let>WIN_USEHANDLE=0
Assuming PDFFactory was active when you run the above code you will now have it's handle in pdf_handle and can use that later in the script (when setting WIN_USEHANDLE to 1) to focus it.
4. I think they were referring to GetActiveWindow. Assign the following to a hot key and it will tell you the active window name:
GetActiveWindow>title,x,y
MessageModal>title
It has to be run from a hot key so that the act of running it from Macro Scheduler doesn't move focus to Macro Scheduler.
Alternatively use View/System Windows from the Tools menu in Macro Scheduler.
MJT Net Support
[email protected]
[email protected]
1. I followed your advice and set up a macro with
GetActiveWindow>title,x,y
MessageModal>title
It produced the following message:
pdfFactory Pro : D:\DOCUME~1\Robin.8BG\LOCAL... (7 pages, 30 KB)
How would I put the above in a setfocus command?
2. I also tried the view/system windows from the tools menu. Is there a way of setting the focus to say a button through using the number of the button as shown in the system window?
Could you please point me to some guidance as to how to use the information in the system window?
GetActiveWindow>title,x,y
MessageModal>title
It produced the following message:
pdfFactory Pro : D:\DOCUME~1\Robin.8BG\LOCAL... (7 pages, 30 KB)
How would I put the above in a setfocus command?
2. I also tried the view/system windows from the tools menu. Is there a way of setting the focus to say a button through using the number of the button as shown in the system window?
Could you please point me to some guidance as to how to use the information in the system window?
Robin
Hi,
I have looked at the problem with pdFFactory Pro. It is an awkward one and one that doesn't work well with the debugger because of the new window that pops up and changes focus, and because it changes it's title. However, the following script when run normally (not in the debugger) is able to get the window handle of the pdf factory pro window.
To use this script, first open Notepad and enter some text into it. Leave Notepad running and then run this script. It ends by focusing Macro Scheduler, then displaying the window handle of pdffactory pro and then focusing back to pdffactory to prove it works:
SetFocus>Notepad*
Press ALT
Send>fp
Release ALT
WaitWindowOpen>Print
Send>pdf
Press Enter
WaitWindowClosed>Print
Wait>2
//We should now have the PDFFactory Pro Window, get it's handle
Let>WIN_USEHANDLE=1
GetActiveWindow>handle,x,y
Let>WIN_USEHANDLE=0
SetFocus>Macro Scheduler 7.3
MessageModal>handle
Let>WIN_USEHANDLE=1
SetFocus>handle
See how this gets the handle of PDFFactory Pro by making the assumption that after the print window has gone the next window to appear will always be the PDFFactory Pro window.
Hope this helps.
I have looked at the problem with pdFFactory Pro. It is an awkward one and one that doesn't work well with the debugger because of the new window that pops up and changes focus, and because it changes it's title. However, the following script when run normally (not in the debugger) is able to get the window handle of the pdf factory pro window.
To use this script, first open Notepad and enter some text into it. Leave Notepad running and then run this script. It ends by focusing Macro Scheduler, then displaying the window handle of pdffactory pro and then focusing back to pdffactory to prove it works:
SetFocus>Notepad*
Press ALT
Send>fp
Release ALT
WaitWindowOpen>Print
Send>pdf
Press Enter
WaitWindowClosed>Print
Wait>2
//We should now have the PDFFactory Pro Window, get it's handle
Let>WIN_USEHANDLE=1
GetActiveWindow>handle,x,y
Let>WIN_USEHANDLE=0
SetFocus>Macro Scheduler 7.3
MessageModal>handle
Let>WIN_USEHANDLE=1
SetFocus>handle
See how this gets the handle of PDFFactory Pro by making the assumption that after the print window has gone the next window to appear will always be the PDFFactory Pro window.
Hope this helps.
MJT Net Support
[email protected]
[email protected]