SavePictureAs - (Save Image/Picture)
Somehow it does the rightclicking and save as for me, but it always saves in Chrome's Default saveto folder
I changed the code some.
Added CoordMode, mouse , Screen
Now after the Lbutton is pressed the script waits for the Lbutton to be released using Keywait before it gets the x-y coordinates on release of the Lbutton.
I removed the GoSub to help troubleshoot.
I increased the sleep to 1000ms.
I moved the "Mouse moved up" code to the top.
I added to the "Timed out waiting for the Save As window to open" message to help you figure out why the message appeared.
I think increasing the sleep time will fix the issue with it saving to the default download folder incorrectly.
There are other issues like when you click and drag and you are not over an image. For instance while you are copy and pasting using the mouse. Also, when using the scroll bar by clicking on the scrollbar and moving the scrollbar up.
Try searching the forum for "detecting scrollbar under cursor".
Add that code under KeyWait,lbutton,UP then add RETURN.
Try this code
SetTitleMatchMode,1 LeftFolder = %a_desktop%\temp RightFolder = %A_MyDocuments%\temp CoordMode, mouse , Screen return ~lbutton:: ;left button down MouseGetPos,xd,yd ;get x and y coordinates KeyWait,lbutton,UP sleep 100 MouseGetPos,xu,yu ;get x and y coordinates if (yd-yu) > 20 ;if ydown is greater then yup then mouse was moved up { sleep 1000 Send {rbutton} Sleep, 1000 send {v} WinWaitActive, Save,,5 if errorlevel = 1 { MsgBox Timed Out waiting for Save As window`n`nIf you are getting this error message then your mouse has moved more then 20 pixels up and the script was unable to right click and/or send v to open the Save As window. Maybe you released the mouse button when the cursor was not above the image. return } return } if (xd-xu) > 20 ;if xdown is greater then xup, then mouse was moved left { sleep 1000 Send {rbutton} Sleep, 1000 send {v} WinWaitActive, Save,,5 if errorlevel = 1 { MsgBox Timed Out waiting for Save As window`n`nIf you are getting this error message then your mouse has moved more then 20 pixels to the left and the script was unable to right click and/or send v to open the Save As window. Maybe you released the mouse button when the cursor was not above the image. return } ControlgetText, Filename, Edit1, Save ControlSetText, Edit1,,Save ControlSetText,Edit1,%LeftFolder%\%FileName%,Save ControlClick , &Save, Save,,,,NA return } if (xu-xd) > 20 ;if xup is greater then xdown then mouse was moved right { sleep 1000 Send {rbutton} Sleep, 1000 send {v} WinWaitActive, Save,,5 if errorlevel = 1 { MsgBox Timed Out waiting for Save As window`n`nIf you are getting this error message then your mouse has moved more then 20 pixels to the right and the script was unable to right click and/or send v to open the Save As window. Maybe you released the mouse button when the cursor was not above the image. return } ControlgetText, Filename, Edit1, Save ControlSetText, Edit1,,Save ControlSetText,Edit1,%RightFolder%\%FileName%,Save ControlClick , &Save, Save,,,,NA return } return
Try using message boxes like below to troubleshoot.
ControlgetText, Filename, Edit1, Save MsgBox retrieved %filename% from the Edit1 control ControlSetText, Edit1,,Save MsgBox erased Edit1 control ControlSetText,Edit1,%LeftFolder%\%FileName%,Save MsgBox set the value of the Edit1 control to %LeftFolder%\%FileName% ControlClick , &Save, Save,,,,NA MsgBox check %LeftFolder% to see if image existsLet me know how it works for you.
Somehow Chrome Save As dialog just "ignores" anything filled by the ControlSetText function, it only "listens" to what the user types in. I can see that the box is filled with the right information, yet when Save button is hit, it is still the old information that is saved
so this doesn't work
~lbutton:: MouseGetPos,xd,yd return ~lbutton up:: FormatTime, CurrentDateTime1341,, yyyy-MM-dd_hhmmss ; It will look like 2011-10-27_123456 MouseGetPos,xu,yu if (xd-xu) > 40 { gosub,OpenSaveWindow TrayTip, Picture saved to %LeftFolder%, %CurrentDateTime1341% %FileName%, 1, 1 ControlSetText,Edit1,%LeftFolder%\%CurrentDateTime1341% %FileName%,Save ControlClick , &Save, Save,,,,NA .................(more of your script)
but this works:
~lbutton:: MouseGetPos,xd,yd return ~lbutton up:: FormatTime, CurrentDateTime1341,, yyyy-MM-dd_hhmmss ; It will look like 2011-10-27_123456 MouseGetPos,xu,yu if (xd-xu) > 40 { gosub,OpenSaveWindow TrayTip, Picture saved to %LeftFolder%, %CurrentDateTime1341% %FileName%, 1, 1 ControlSetText,Edit1,%LeftFolder%\%CurrentDateTime1341% %FileName%,Save send ^a sleep 30 send ^c sleep 30 send ^v sleep 30 ControlClick , &Save, Save,,,,NA .................(more of your script)
As you can see I have to add the "Select All", copy and then REPASTE lines to make Chrome realize that there is new information in the Filename field, otherwise even if ControlSetText has filled in the correct path and filenames, Chrome still save it like before (old name, old folder), as if the new path generated by ControlSetText that I see in the Filename field is an illusion!
I wonder why Chrome does not recognize the change of information input(ed) by the ControlSetText? this mystery really annoys me
I am using Chrome 15.0.874.121 and I do not have that behavior.
Try replacing controlsettext with
ControlFocus,edit1,Save SendInput {Raw}%LeftFolder%\%FileName% ;leave no spaces between {Raw} and %LeftFolder%\ %FileName%
I just remembered I had the same problem you are having a long time ago when I coded SavePictureAs.
I even documented it in my SavePictureAs.ahk code.
I am using SendInput {Raw} with SavePictureAs.ahk V6.3.
Here are the notes I put in SavePictureAs.ahk V6.3
;NOTES 1: Reason for using SendInput {Raw} instead of Send
;Send Car+Mustang+-+1999+Red+06 actually sends CarMustang_!999Red)6 (incorrect filename)
;SendInput {Raw} Car+Mustang+-+1999+Red+06 actually sends Car+Mustang+-+1999+Red+06 (exact filename match)
;NOTES 2: Reason for using SendInput {Raw} instead of ControSetText. When using some broswers on some OS's ControlSetText puts the text in the control but then when sending enter, alt s, or (ControlClick, &Save) to save the image it always tries to save the original filename without the new path. For example it continues to try to save - images.jpg instead of c:\NewPath\images.jpg This behavior is in windows vista and windows 7.
About your note, it is truly assuring to know that I'm not the only person with the hallucination :twisted:
At the check of what browser is being used, you look for 'Chrome_WidgetWin_0', but what is returned in my case is 'Chrome_WidgetWin_1'.
I can hard-code a simple fix for myself, but thought you might want to know.
So it is failing when I try to use this in Chrome.
At the check of what browser is being used, you look for 'Chrome_WidgetWin_0', but what is returned in my case is 'Chrome_WidgetWin_1'.
I can hard-code a simple fix for myself, but thought you might want to know.
thanks for the feedback.
I will change the code to check for both classes and update the download later.
What version of Chrome are you using?
I don't have chrome installed on this computer but I will check later to see if the class has changed.
thanks again
Datalife
Fixed Google Chrome window class issue found by Jaycephus.
thanks
DataLife
I am glad you find my program useful.Thank You! Just what i was looking for for chrome for many many months!!
Thanks for using it. I put alot of work into it.
DataLife
That's pretty cool, I had a couple problems with it but it ended up working with Chrome in the end, with FF the zip files worked only, with IE there was a Save As dialog box 2 times and it saved on the second. Anyways it's working great with Chrome now thanks!
Thanks for the report.
What OS are you using?
What version of Firefox?
I use SavePictureAs with Windows 7 and IE 9 and have no problems at all. It was originally written on Window XP but has not been tested on Windows XP in awhile.
thanks
DataLife