 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Tlams
Joined: 29 Dec 2009 Posts: 84 Location: France
|
Posted: Sat Mar 06, 2010 8:41 pm Post subject: FileGetSize and ftp |
|
|
Hi!
I'have :
| Code: | FileGetSize, b100,ftp://tlams.free.fr/Metin2/maj/metin2.exe
FileGetSize, b100X,C:\Users\Thomas\Desktop\metin2.exe
if b100 = b100X
{
msgbox Maj inutile
}
else
UrlDownloadToFile, http://tlams.free.fr/Metin2/maj/metin2.exe, C:\Users\Thomas\Desktop\metin2.exe
|
But FileGetSize does not detect the size for a file in an ftp .
How can I do?
Thx |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
|
| Back to top |
|
 |
Tlams
Joined: 29 Dec 2009 Posts: 84 Location: France
|
Posted: Sat Mar 06, 2010 9:44 pm Post subject: |
|
|
It's very hard !
I do not understand xD
| Code: |
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; HttpQueryInfo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
QueryInfoFlag:
HTTP_QUERY_RAW_HEADERS = 21
Receives all the headers returned by the server.
Each header is terminated by "\0". An additional "\0" terminates the list of headers.
HTTP_QUERY_CONTENT_LENGTH = 5
Retrieves the size of the resource, in bytes.
HTTP_QUERY_CONTENT_TYPE = 1
Receives the content type of the resource (such as text/html).
Find more at: http://msdn.microsoft.com/library/en-us/wininet/wininet/query_info_flags.asp
Proxy Settings:
INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration
INTERNET_OPEN_TYPE_DIRECT 1 // direct to net
INTERNET_OPEN_TYPE_PROXY 3 // via named proxy
INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS
*/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
HttpQueryInfo(URL, QueryInfoFlag=21, Proxy="", ProxyBypass="") {
hModule := DllCall("LoadLibrary", "str", "wininet.dll")
If (Proxy != "")
AccessType=3
Else
AccessType=1
io_hInternet := DllCall("wininet\InternetOpenA"
, "str", "" ;lpszAgent
, "uint", AccessType
, "str", Proxy
, "str", ProxyBypass
, "uint", 0) ;dwFlags
If (ErrorLevel != 0 or io_hInternet = 0) {
DllCall("FreeLibrary", "uint", hModule)
return, -1
}
iou_hInternet := DllCall("wininet\InternetOpenUrlA"
, "uint", io_hInternet
, "ftp://tlams.free.fr/Metin2/maj/metin2.exe", url
, "str", "" ;lpszHeaders
, "uint", 0 ;dwHeadersLength
, "uint", 0x80000000 ;dwFlags: INTERNET_FLAG_RELOAD = 0x80000000 // retrieve the original item
, "uint", 0) ;dwContext
If (ErrorLevel != 0 or iou_hInternet = 0) {
DllCall("FreeLibrary", "uint", hModule)
return, -1
}
VarSetCapacity(buffer, 1024, 0)
VarSetCapacity(buffer_len, 4, 0)
Loop, 5
{
hqi := DllCall("wininet\HttpQueryInfoA"
, "uint", iou_hInternet
, "uint", QueryInfoFlag ;dwInfoLevel
, "uint", &buffer
, "uint", &buffer_len
, "uint", 0) ;lpdwIndex
If (hqi = 1) {
hqi=success
break
}
}
IfNotEqual, hqi, success, SetEnv, res, timeout
If (hqi = "success") {
p := &buffer
Loop
{
l := DllCall("lstrlen", "UInt", p)
VarSetCapacity(tmp_var, l+1, 0)
DllCall("lstrcpy", "Str", tmp_var, "UInt", p)
p += l + 1
res := res . "`n" . tmp_var
If (*p = 0)
Break
}
StringTrimLeft, res, res, 1
}
DllCall("wininet\InternetCloseHandle", "uint", iou_hInternet)
DllCall("wininet\InternetCloseHandle", "uint", io_hInternet)
DllCall("FreeLibrary", "uint", hModule)
return, res
} |
|
|
| Back to top |
|
 |
Tlams
Joined: 29 Dec 2009 Posts: 84 Location: France
|
Posted: Sun Mar 07, 2010 12:58 am Post subject: |
|
|
I'have find !
| Code: |
FileGetSize, b100,ftp://tlams.free.fr/Metin2/maj/mouse.cfg,
FileGetSize, b100X,C:\Users\Thomas\Desktop\mouse.cfg,
if b100:=b100X
{
msgbox Maj inutile
}
else
UrlDownloadToFile, http://tlams.free.fr/Metin2/maj/mouse.cfg, C:\Users\Thomas\Desktop\mouse.cfg
return |
But there is a problem!
If I edit the file "mouse.cfg" and I raise, it does not detect the change ...
Why ? |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Sun Mar 07, 2010 7:41 am Post subject: |
|
|
if b100:=b100X is not correct, with := you assign a value to a variable so you can can't compare it. Perhaps use the expression mode like so
_________________ AHK Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 2214 Location: switzerland
|
Posted: Sun Mar 07, 2010 8:25 am Post subject: |
|
|
not sure if works, must login for FTP
this example works:
| Code: | url = http://www.autohotkey.com
;url=ftp://tlams.free.fr/Metin2/maj/metin2.exe ; not works
SIZE7:=HttpQueryInfo(URL,5)
if (size7="timeout" or size7=0 or size7=-1)
msgbox,SIZE=%size7%`nERROR
else
msgbox,SIZE=%size7%
return
/*
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; HttpQueryInfo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
QueryInfoFlag:
HTTP_QUERY_RAW_HEADERS = 21
Receives all the headers returned by the server.
Each header is terminated by "\0". An additional "\0" terminates the list of headers.
HTTP_QUERY_CONTENT_LENGTH = 5
Retrieves the size of the resource, in bytes.
HTTP_QUERY_CONTENT_TYPE = 1
Receives the content type of the resource (such as text/html).
Find more at: http://msdn.microsoft.com/library/en-us/wininet/wininet/query_info_flags.asp
Proxy Settings:
INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration
INTERNET_OPEN_TYPE_DIRECT 1 // direct to net
INTERNET_OPEN_TYPE_PROXY 3 // via named proxy
INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS
; Examples:
; url1 = http://www.autohotkey.com
; url2 = http://www.autohotkey.com/download/AutoHotkeyInstall.exe
; MsgBox % HttpQueryInfo(url1)
; MsgBox % HttpQueryInfo(url2, 5)
; MsgBox % HttpQueryInfo(url2, 1)
*/
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
HttpQueryInfo(URL, QueryInfoFlag=21, Proxy="", ProxyBypass="") {
hModule := DllCall("LoadLibrary", "str", "wininet.dll")
If (Proxy != "")
AccessType=3
Else
AccessType=1
io_hInternet := DllCall("wininet\InternetOpenA"
, "str", "" ;lpszAgent
, "uint", AccessType
, "str", Proxy
, "str", ProxyBypass
, "uint", 0) ;dwFlags
If (ErrorLevel != 0 or io_hInternet = 0) {
DllCall("FreeLibrary", "uint", hModule)
return, -1
}
iou_hInternet := DllCall("wininet\InternetOpenUrlA"
, "uint", io_hInternet
, "str", url
, "str", "" ;lpszHeaders
, "uint", 0 ;dwHeadersLength
, "uint", 0x80000000 ;dwFlags: INTERNET_FLAG_RELOAD = 0x80000000 // retrieve the original item
, "uint", 0) ;dwContext
If (ErrorLevel != 0 or iou_hInternet = 0) {
DllCall("FreeLibrary", "uint", hModule)
return, -1
}
VarSetCapacity(buffer, 1024, 0)
VarSetCapacity(buffer_len, 4, 0)
Loop, 5
{
hqi := DllCall("wininet\HttpQueryInfoA"
, "uint", iou_hInternet
, "uint", QueryInfoFlag ;dwInfoLevel
, "uint", &buffer
, "uint", &buffer_len
, "uint", 0) ;lpdwIndex
If (hqi = 1) {
hqi=success
break
}
}
IfNotEqual, hqi, success, SetEnv, res, timeout
If (hqi = "success") {
p := &buffer
Loop
{
l := DllCall("lstrlen", "UInt", p)
VarSetCapacity(tmp_var, l+1, 0)
DllCall("lstrcpy", "Str", tmp_var, "UInt", p)
p += l + 1
res := res . "`n" . tmp_var
If (*p = 0)
Break
}
StringTrimLeft, res, res, 1
}
DllCall("wininet\InternetCloseHandle", "uint", iou_hInternet)
DllCall("wininet\InternetCloseHandle", "uint", io_hInternet)
DllCall("FreeLibrary", "uint", hModule)
return, res
}
;------------------------------------------------------------------
|
|
|
| Back to top |
|
 |
Tlams
Joined: 29 Dec 2009 Posts: 84 Location: France
|
Posted: Sun Mar 07, 2010 10:44 am Post subject: |
|
|
Ok ! Thx you
| Code: |
FileGetSize, b100X,C:\Users\Thomas\Desktop\mouse.cfg ,
url=http://tlams.free.fr/Metin2/maj/mouse.cfg
SIZE7:=HttpQueryInfo(URL,5)
if (size7="timeout" or size7=0 or size7=-1)
msgbox,SIZE=%size7%`nERROR
else
if b100X = %size7%
{
msgbox Maj inutile
}
else
{
UrlDownloadToFile, http://tlams.free.fr/Metin2/maj/mouse.cfg , C:\Users\Thomas\Desktop\mouse.cfg
}
TrayTip, information,Fichier à jour., 3, 17
Sleep 2000
return
/*
|
 |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 2214 Location: switzerland
|
Posted: Sun Mar 07, 2010 11:10 am Post subject: |
|
|
works for you Tlams ?
can't test it maybe I have no access
think need more brackets, specially after else ....
try this (needs httpquery, see above)
| Code: | FileGetSize, b100X, %A_scriptdir%\CurrentVersion.txt
url=http://www.autohotkey.com/download/CurrentVersion.txt
SIZE7:=HttpQueryInfo(URL,5)
if (size7="timeout" or size7=0 or size7=-1)
{
msgbox,SIZE=%size7%`nERROR
return
}
else
{
if (b100X=size7)
{
msgbox Maj inutile
return
}
else
{
UrlDownloadToFile,%url% , %A_scriptdir%\CurrentVersion.txt
TrayTip, information,Fichier à jour., 3, 17
Sleep 2000
}
}
return
|
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|