I have written a script and it has a couple of problems - it works in a Perfect World. It has to do the (the/a) send function. Since I am not a real programer I don't know what to call it. I have a window open with a dialog box on top. When the mouse is moved the user clicks on the enter key and the location is recorded - this works fine in some applications: However, in some applications like outlook, when the user clicks on enter - the cursor automatically sets focus to that screen and an error is generated. The error is bizzar - a format disk screen appears that you cannot get rid of, without rebooting. I quess the question is if you can send an ALT A or something to activate the Button/Command on the (active/window) script. Attached is the code. When I get this resolved I have a question on why I get an error when doing a loop back to a dialog box.
Dialog>TestWindow
Caption=Test Window Compatibility
Top=235
Width=356
Left=309
Height=199
Label=Enter the Name of the Window you want to scrape,64,16
Label=This Window should come to the Front and be Active,64,80
Button=Okay,56,104,75,25,1
Edit=windowname,64,40,241,
Button=Exit,144,104,75,25,2
Button=Help,232,104,75,25,3
EndDialog>TestWindow
Label>MainLoopTestWindow
Show>TestWindow,result
If>result=1,Showwindow
If>result=2,End
If>result=3,Helpbox1
Goto>MainLoopTestWindow
Label>Showwindow
Let>w=%TestWindow.windowname%
SetFocus>%w%*
Dialog>Box2
Caption=Capture Left Side of Field
Top=306
Width=269
Left=389
Height=149
Label=Place the cursor over the left side of the field,16,8
Label=that you want to capture,72,24
Label=DO NOT click on the Window,64,48
Label=Press Enter to Continue,72,66
Button=Button1,0,0,0,0,1
EndDialog>Box2
Label>MainLoop
Show>Box2,result
If>result=2,End
If>result=1,saveLpos
Goto>MainLoop
Label>saveLpos
GetWindowPos>%W%*,X,Y
GetCursorPos>X1,Y1
Let>Lwidth=%X1%-%X%
Let>LHeight=%Y1%-%y%
Dialog>Box3
Caption=Capture Right Side Of Screen
Top=306
Width=269
Left=389
Height=149
Label=Place the cursor over the Right side of the field,16,8
Label=that you want to capture,72,24
Label=DO NOT click on the Window,64,48
Label=Press Enter to Continue,72,66
Button=Button1,0,0,0,0,1
EndDialog>Box3
Label>MainLoop3
Show>Box3,result
If>result=2,End
If>result=1,saveRpos
Goto>MainLoop3
Label>saveRpos
GetWindowPos>%W%*,X,Y
GetCursorPos>X1,Y1
Let>Rwidth=%X1%-%X%
Let>RHeight=%Y1%-%y%
Let>Move=%RHeight%
SetFocus>%w%*
GetWindowPos>%w%*,npX,npY
Add>npX,%Lwidth%
Add>npY,%RHeight%
MouseMove>npX,npY
Wait 0.5
LDown
Add>npy,%Rwidth%
MouseMove>npX,npY
Wait 0.5
LUp
Wait. 0.3
Press CTRL
Wait 0.5
Send c
Wait 0.5
Release CTRL
GetClipBoard>Scraped
Dialog>Dialog7
Caption=Dialog7
Top=351
Width=302
Left=384
Height=160
Label=Left X,40,16
Label=Right X,39,33
Label=Move,39,49
Label=%Lwidth%,85,17
Label=%Rwidth%,86,33
Label=%Move%,87,50
Label=Value Captured,39,70
Label=%Scraped%,39,86
Button=Okay,167,22,75,25,1
EndDialog>Dialog7
Label>Displayloop
Show>Dialog7,Result
If>result=1,End
If>result=2,End
Goto>Displayloop
SRT>Helpbox1
End>Helpbox1
Label>End
Label>EOF
Sending a Command to issue an action instead of enter
Moderators: JRL, Dorian (MJT support)
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Some quick observations, no testing done yet:
1. Label>Showwindow
Let>w=%TestWindow.windowname%
I did not see Test.Window.windowname defined yet, so %.....% looks strange, not sure a variable will work with "%" as part of variable name.
2. Label>saveLpos
GetWindowPos>%W%*,X,Y
Not sure that %W% exists. Variables can be case sensitive. Earlier you defined %w%, but not %W%.
3. Label>saveRpos
GetWindowPos>%W%*,X,Y
Same comment as above re %W% / %w%
==================================
I didn't see any loops back to Dialog, but you will get error. Dialog has already been named and defined and you cannot do that again in a script.
You can loop to Show> as you have done, but not to Dialog>
==========================
I am a little confused about your comments on windows taking focus. It sounds to me like you may be running this script in one window, maybe in the background?, and using mouse/keyboard in other windows. If you click on ENTER in a window that will move focus to the current window that you just clicked in. You may then see strange errors if macro was running. Because the macro commands will now be executed in the active window. Results will be unpredictable. You will have to wait for this type of macro to complete running before using mouse/kybd or any other windows.
Again, just some comments without testing, maybe can do later......
1. Label>Showwindow
Let>w=%TestWindow.windowname%
I did not see Test.Window.windowname defined yet, so %.....% looks strange, not sure a variable will work with "%" as part of variable name.
2. Label>saveLpos
GetWindowPos>%W%*,X,Y
Not sure that %W% exists. Variables can be case sensitive. Earlier you defined %w%, but not %W%.
3. Label>saveRpos
GetWindowPos>%W%*,X,Y
Same comment as above re %W% / %w%
==================================
I didn't see any loops back to Dialog, but you will get error. Dialog has already been named and defined and you cannot do that again in a script.
You can loop to Show> as you have done, but not to Dialog>
==========================
I am a little confused about your comments on windows taking focus. It sounds to me like you may be running this script in one window, maybe in the background?, and using mouse/keyboard in other windows. If you click on ENTER in a window that will move focus to the current window that you just clicked in. You may then see strange errors if macro was running. Because the macro commands will now be executed in the active window. Results will be unpredictable. You will have to wait for this type of macro to complete running before using mouse/kybd or any other windows.
Again, just some comments without testing, maybe can do later......
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Still working on it
Bob,
I have corrected the case sensitive part to clean it up - However, that wasn't causing the dfficulty.
What I am trying to do in a nutshell is record the X,Y location on an open window. The above program will work on some applications but not all.
With Macro Scheduler, on some applications when a Dialog Box is open and when the cursor is over a data input field you can Press Enter and the focus will not change to that window, (it triggers Macro Scheduler) which is what I want to do. In other applications it will change focus to that application. Microsoft Access and Outlook are examples of the difference.
For instance
With a Dialog box open and active (it is on running on top of Microsoft Access) I can move the curser and position it over a data entry field, press the Enter Key and the XY location will be read by Macro Scheduler and the script will continue. - this is what I want and it is perfect
However,
Outlook on the other hand works differently when the Enter key is pressed Outlook becomes active - and that is when the above program crashes. What happens is the cursor jumps into the data entry field.
I was thinking is there a way for something different than Pressing Enter to trigger an event. In other words if Alt + C were pressed, could that be read to continue a script instead of Enter? If that was the case I think the above script would work. Any Ideas?
I have corrected the case sensitive part to clean it up - However, that wasn't causing the dfficulty.
What I am trying to do in a nutshell is record the X,Y location on an open window. The above program will work on some applications but not all.
With Macro Scheduler, on some applications when a Dialog Box is open and when the cursor is over a data input field you can Press Enter and the focus will not change to that window, (it triggers Macro Scheduler) which is what I want to do. In other applications it will change focus to that application. Microsoft Access and Outlook are examples of the difference.
For instance
With a Dialog box open and active (it is on running on top of Microsoft Access) I can move the curser and position it over a data entry field, press the Enter Key and the XY location will be read by Macro Scheduler and the script will continue. - this is what I want and it is perfect
However,
Outlook on the other hand works differently when the Enter key is pressed Outlook becomes active - and that is when the above program crashes. What happens is the cursor jumps into the data entry field.
I was thinking is there a way for something different than Pressing Enter to trigger an event. In other words if Alt + C were pressed, could that be read to continue a script instead of Enter? If that was the case I think the above script would work. Any Ideas?
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Can you explain a little more on the "data entry" field?
Where in the script are you pausing to press ENTER?
If you loop back to Show> that forces a Dialog window that takes the focus from wherever you were. Pressing ENTER will execute in whichever window has the focus, the Dialog or the "other" program.
You may need to add a SetFocus>WindowName* in your script before it continues.
==========Aaargh!...never mind my earlier question about where you are pressing ENTER. I just read the content of the Dialog script. This dialog is coming up and you are instructing user to move the cursor, but not click in the window, then press ENTER to bring up more instructions.
Clever routine, I like it! May get to try it out later to actually see problem in real time. Now I understand what you are doing., pretty sure I can duplicate your actions.....
Is this an entry field in the Dialog, or in the other windows, like in Access, in Outlook?when the cursor is over a data input field
Where in the script are you pausing to press ENTER?
If you loop back to Show> that forces a Dialog window that takes the focus from wherever you were. Pressing ENTER will execute in whichever window has the focus, the Dialog or the "other" program.
You may need to add a SetFocus>WindowName* in your script before it continues.
==========Aaargh!...never mind my earlier question about where you are pressing ENTER. I just read the content of the Dialog script. This dialog is coming up and you are instructing user to move the cursor, but not click in the window, then press ENTER to bring up more instructions.
Clever routine, I like it! May get to try it out later to actually see problem in real time. Now I understand what you are doing., pretty sure I can duplicate your actions.....
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!