Posts: 726
Threads: 99
Joined: Mar 2018
01-21-2019, 11:56 AM
(This post was last modified: 01-21-2019, 01:43 PM by win.)
Hello everyone, if I can get the direct download address of the file, I use the following QM code, but for some files on the network hard disk, I have two problems:
1. I can't get the direct download address. When I click the download button, I can get the download link, At different times, the download link address is different. and the download address is changed. Test the network disk download link: https://sendit.cloud/vjhlvevk3ky3
2. The downloaded file may be incomplete due to network problems. I need to make sure the downloaded file is complete.How check the downloaded file is complete?
I hope someone can provide some suggestions and methods, thanks in advance.
Macro Macro4
str localfile="$desktop$\quickmac.ex_"
IntGetFile "http://www.quickmacros.com/quickmac.exe" localfile 16 0 1
ren- localfile "$desktop$\quickmac.exe"
Posts: 1,338
Threads: 61
Joined: Jul 2006
i have tried before and never found a reliable way to download files from file hosting sites that don't offer direct downloads
Posts: 726
Threads: 99
Joined: Mar 2018
01-21-2019, 08:43 PM
(This post was last modified: 01-21-2019, 08:50 PM by win.)
I tried the code below but can't open the URL from IE
Macro Macro4
SHDocVw.IWebBrowser2 wb=web("https://sendit.cloud/vjhlvevk3ky3" 1)
MSHTML.IHTMLElement el=htm("INPUT" "id" "" "Internet Explorer" 0 0 0x221)
el.click
I found the following VBS code, I hope someone can help me improve it.
Dim btn,ie
Set ie = WScript.CreateObject("InternetExplorer.Application")
ie.Visible = true
ie.navigate "http://webpage.com"
Do
Wscript.Sleep 200
Loop Until ie.readyState = 4
Set btn =ie.Document.getElementById("J_SubmitQuick")
btn.click
Posts: 1,338
Threads: 61
Joined: Jul 2006
01-22-2019, 02:16 AM
(This post was last modified: 01-22-2019, 02:25 AM by Kevin.)
this is working for me in chrome
make sure
is checked in qm options window
run "$program files$\Google\Chrome\Application\chrome.exe" "https://sendit.cloud/vjhlvevk3ky3"
int w1=wait(30 WV win("" "Chrome_WidgetWin_1"))
Acc a.Find(w1 "PUSHBUTTON" "" "a:id=btn_download" 0x3005 30)
a.DoDefaultAction
Posts: 726
Threads: 99
Joined: Mar 2018
Can I use IE browser? Because some computers don't have Google Chrome installed.
My idea is: use IE browser, hide the IE window to run
Posts: 1,338
Threads: 61
Joined: Jul 2006
It's just not reliable .Internet explorer is an old outdated browser that really should not be used if at all possible.
Posts: 1,000
Threads: 253
Joined: Feb 2008
My usual order of operations is to use browser dialog to log in which will give QM access to the site if credentials are needed. Then IntGetFile to grab the page’s HTML. Then use findrx to parse out the link. Then IntGetFile to download the link.
These things can get tricky though, especially if JavaScript is being used for user interaction to interface with server side programming. It might take lots of reverse engineering to get a good link.
Sometimes I have to do what I call the GUI hack where I automate everything in the browser control. This is always my last resort because so many things can go wrong. Mostly timing while pages load. You also end up with Save As, File Exists, etc windows dialogs that need to be automated. Wait for window active is necessary to control timing.
Posts: 726
Threads: 99
Joined: Mar 2018
01-30-2019, 08:16 PM
(This post was last modified: 01-30-2019, 08:17 PM by win.)
@TheVig
Thank you for sharing your experience.
I am currently experiencing two problems. I hope someone can provide some suggestions. Thanks in advance:
1. Because I open IE directly, it is not always effective, so I created a dialog box and built-in IE browser control, but my code can't run.
2. If you use the account password to log in to the network disk, it will save the cookie, how to clear the cookie after getting the link.
Macro Macro3
qm_web ;;Function Custom Dialog Built-in IE Browser Control
;Click the download button in the dialog
int w=wait(3 WV win("Dialog" "#32770"))
Acc a.Find(w "LINK" "Download" "" 0x3001 3)
a.DoDefaultAction
;Clean up the cookie code
Function qm_web
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 400 222 "Dialog"
;3 ActiveX 0x54030000 0x0 0 0 400 222 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040701 "*" "" "" ""
str controls = "3"
str ax3SHD="http://quickmacros.com/"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Posts: 726
Threads: 99
Joined: Mar 2018
How to make the code of behind , operate the Front window in the sub-process
Macro Macro3
mac sub.ie
;Click the download button in the dialog
int w=wait(3 WV win("Dialog" "#32770"))
Acc a.Find(w "LINK" "Download" "" 0x3001 3)
a.DoDefaultAction
;Clean up the cookie code
#sub ie
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 400 222 "Dialog"
;3 ActiveX 0x54030000 0x0 0 0 400 222 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040701 "*" "" "" ""
str controls = "3"
str ax3SHD="http://quickmacros.com/"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Posts: 1,338
Threads: 61
Joined: Jul 2006
#1 your using mac incorrectly
to call a sub-function using mac
should be mac "sub.ie"
better probably would be something like this
Macro Macro300
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 400 222 "Dialog"
;3 ActiveX 0x54030000 0x0 0 0 400 222 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040800 "*" "" "" ""
str controls = "3"
str ax3SHD
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,mac "sub.WaitForLoaded" "" hDlg
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#sub WaitForLoaded
function hDlg
SHDocVw.WebBrowser we3
we3._getcontrol(id(3 hDlg))
we3.Navigate("http://www.quickmacros.com/download.html")
opt waitmsg 1
rep() 0.01; if(!we3.Busy) break
int w=wait(30 WV win("Dialog" "#32770"))
Acc a.Find(w "LINK" "Download" "value=http://www.quickmacros.com/quickmac.exe" 0x2005 3)
a.DoDefaultAction
Posts: 726
Threads: 99
Joined: Mar 2018
02-01-2019, 02:32 AM
(This post was last modified: 02-01-2019, 02:46 AM by win.)
Thanks for your help, I added some code and can't continue to run, I have tried the function acc and send the key
Macro Macro6
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 400 222 "Dialog"
;3 ActiveX 0x54030000 0x0 0 0 400 222 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040800 "*" "" "" ""
str controls = "3"
str ax3SHD
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,mac "sub.WaitForLoaded" "" hDlg
,mac "sub.con1"
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#sub WaitForLoaded
function hDlg
SHDocVw.WebBrowser we3
we3._getcontrol(id(3 hDlg))
we3.Navigate("http://www.quickmacros.com/download.html")
opt waitmsg 1
rep() 0.01; if(!we3.Busy) break
int w=wait(30 WV win("Dialog" "#32770"))
Acc a.Find(w "LINK" "Download" "value=http://www.quickmacros.com/quickmac.exe" 0x2005 3)
a.DoDefaultAction
#sub con1
int w3=wait(30 WA win(" - " "#32770"))
key As
key As
int w4=win("" "#32770")
clo w4
int w2=win("Dialog" "#32770")
clo w2
Posts: 1,338
Threads: 61
Joined: Jul 2006
not completely sure what your trying to do with your code
Posts: 726
Threads: 99
Joined: Mar 2018
02-01-2019, 03:17 AM
(This post was last modified: 02-01-2019, 03:19 AM by win.)
Use a custom dialog with IE controls to simulate a manual click of a button to download a file
Running is always unsuccessful, I don't know where I encountered the error
Posts: 1,338
Threads: 61
Joined: Jul 2006
02-01-2019, 03:37 AM
(This post was last modified: 02-01-2019, 04:05 AM by Kevin.)
try this
Macro Macro301
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 400 222 "Dialog"
;3 ActiveX 0x54030000 0x0 0 0 400 222 "SHDocVw.WebBrowser {8856F961-340A-11D0-A96B-00C04FD705A2}"
;END DIALOG
;DIALOG EDITOR: "" 0x2040800 "*" "" "" ""
str controls = "3"
str ax3SHD
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,mac "sub.WaitForLoaded" "" hDlg
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#sub WaitForLoaded
function hDlg
SHDocVw.WebBrowser we3
we3._getcontrol(id(3 hDlg))
we3.Navigate("http://www.quickmacros.com/download.html")
opt waitmsg 1
rep() 0.01; if(!we3.Busy) break
30 WV hDlg
;can use acc here
Acc a.Find(hDlg "LINK" "Download" "value=http://www.quickmacros.com/quickmac.exe" 0x2005 3)
a.DoDefaultAction
;or can use htm instead both work speed about the same
;Htm e=htm("B" "Download" "" hDlg "0" 1 0x1 30)
;e.Click
int w=wait(0 WA win("File Download - Security Warning" "#32770"))
act w
0.5
but id(4427 w)
int w1=wait(0 WA win("Save As" "#32770"))
but id(1 w1)
int w2=wait(0 WA win("Download complete" "#32770"))
but id(2 w2)
clo hDlg
Posts: 726
Threads: 99
Joined: Mar 2018
02-01-2019, 05:33 AM
(This post was last modified: 02-01-2019, 05:39 AM by win.)
Thanks, I can run successfully after I modify the title bar text.
Different language operating systems, waiting for the text on the title bar of the window is different, can I use wildcards? The following code is not successful
int w=wait(0 WA win(" - " "#32770"))
act w
0.5
but id(4427 w)
int w1=wait(0 WA win("?" "#32770"))
but id(1 w1)
int w2=wait(0 WA win("?" "#32770"))
but id(2 w2)
clo hDlg
I still have a problem, if the network disk needs to use the account password to log in, it will log the login system, there is a function to clear the login information?
|