Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] save as dialog is hard to automate
#1
I'm surprised by how long I've been trying to automate something so simple. I want to automate saving web pages. file > save as > enter name > save.

I've been at this for over an hour now. Everything runs but firefox's ui is unreliable so the macro will break for no reason that I can see.

Here are the problems:

1. this save dialog SOMETIMES will save when I press enter, sometimes it will make the window inactive.

2. I CAN'T grab activate this window after initializing it - EVEN when it's on top (active). so I can't use accessible objects. I've never had this happen before.

3. I can't use a bunch of tabs to go to the save button..whether I use space bar to press save, or enter to save...it'll work a few times..but it's the same as problem 1...sometimes, for no reason, it won't reach the save button.

I'm using "spe 300" so it should be slow enough.

is there anything I can do to avoid dealing with firefox's unreliable save dialog box?

Thanks
#2
In my Firefox it is standard "Save As" dialog. Objects work. Using Firefox 27 on Windows 7. Maybe some Firefox extension replaces the dialog?
#3
I got acc object to work. I added more code and then it stopped working. I can't figure this out. Can you please look at this?


Macro Macro2
Code:
Copy      Help
spe 200

int i
int w=win("" "Mozilla*WindowClass" "" 0x4)
act w


'Af             ;; Alt+F
'"a"            ;; "a"

int w1=win("Save As" "#32770")
act w1



spe 300

;pick filename area
Acc a.Find(w1 "TEXT" "File name:" "class=Edit[]state=0x100000 0x20000040" 0x1005 2)


;pick save button
Acc a1.Find(w1 "PUSHBUTTON" "Save" "class=Button[]id=1" 0x1005 2)


'Z              ;; Esc
'Z              ;; Esc


act w
'Af             ;; Alt+F
'"a"            ;; "a"


1
act w1


Keeps telling me on the last line "Error (RT) in Macro2: window not found. ? "
#4
Esc probably closed the window and the handle w1 is invalid.
#5
I tried replacing

'z with clo. No difference.

Why is w1 invalid?

I used window/control actions to generate and test the code for w1.

Even in my code, It works the first time I call w1, but not the second time it is called. I tested calling act w near the end and that works even when the save as dialog is active. But after calling act w, a call for w1 fails.

I'm sorry, but I just can't understand what's wrong.
#6
w1 is invalid because the window is closed. For other window need to call win again.

This macro is unreliable because does not wait for the save as window.
#7
I tried adding a delay to ensure the save as window has enough time to show up and it still gives the same error.

Macro Macro2
Code:
Copy      Help
spe 200

int i
int w=win("" "Mozilla*WindowClass" "" 0x4)
act w


'Af             ;; Alt+F
'a              ;; "a"
1

int w1=win("Save As" "#32770")
act w1

spe 300

;pick filename area
Acc a.Find(w1 "TEXT" "File name:" "class=Edit[]state=0x100000 0x20000040" 0x1005 2)


;pick save button
Acc a1.Find(w1 "PUSHBUTTON" "Save" "class=Button[]id=1" 0x1005 2)


clo                ;;tried using 'ZZ and I still get the same error, "window not found"

act w
'Af             ;; Alt+F
'a              ;; "a"

1
act w1          ;;I can verify that the save as window does appear and act w1 still gives the "window not found" error
#8
Good news: I found a fix
Bad news: I still don't understand why the fixes were needed. I commented the code in case this helps in the future.

Macro save pages at domain info - works - finally2
Code:
Copy      Help
spe 200

int i
int w=win("" "Mozilla*WindowClass" "" 0x4)
act w


'Af             ;; Alt+F
'a              ;; "a"
1

int w1=win("Save As" "#32770")
act w1

spe 300

0.5
;pick filename area
Acc a.Find(w1 "TEXT" "File name:" "class=Edit[]state=0x100000 0x20000040" 0x1005 2)

0.5
;pick save button
Acc a1.Find(w1 "PUSHBUTTON" "Save" "class=Button[]id=1" 0x1005 2)


clo

for i 2 70
,act w

,0.5
,
,'Cl ;;go to address bar
,spe
,'F"http://domain.info/page/{i}.aspx"
,'Y ;;enter
,
,7
,
,'Af             ;; Alt+F
,'a              ;; "a"
,1
,
,;I made this work by doing w1=win WITHOUT the int.
,w1=win("Save As" "#32770")
,act w1
,
,;click file name area
,a.DoDefaultAction

,
,;append page number
,spe    
,'ELLLLV            ;; End Left Left Left Left Space
,'F"page {i}"
,'E
,0.5
,
,;I made this work by doing w1=win WITHOUT the int.
,w1=win("Save As" "#32770")
,act w1

,;Must find object again. Even odder, I didn't have to use this for the a.DoDefaultAction for clicking the filename area.
,a1.Find(w1 "PUSHBUTTON" "Save" "class=Button[]id=1" 0x1005 2)
,
,;click save    
,a1.Mouse(1)


Forum Jump:


Users browsing this thread: 1 Guest(s)