 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Jim_Karvo Guest
|
Posted: Wed Jul 01, 2009 8:38 am Post subject: |
|
|
Noone?  |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 561 Location: Galil, Israel
|
Posted: Wed Jul 01, 2009 8:02 pm Post subject: |
|
|
| Jim_Karvo wrote: | Noone?  |
here is MS nice helpful site,
<http://msdn.microsoft.com/en-us/library/aa385096(VS.85).aspx>
if helpful. _________________ Joyce Jamce |
|
| Back to top |
|
 |
neXt
Joined: 18 Mar 2007 Posts: 505
|
Posted: Mon Jan 04, 2010 5:29 pm Post subject: |
|
|
Jim_Karvo, If you still haven't figured it out 1 = True, your script worked...
NVM i fixed it my issue. Don't knwo why, but i had to specify full path to the errorlist file. _________________ simplified csv - easy way to handle csv files. |
|
| Back to top |
|
 |
Elgs Guest
|
Posted: Mon Jan 04, 2010 9:33 pm Post subject: |
|
|
| Can this great O.P. script be modified to connect to Windows built-in IPV6 FTP socket?? thank you |
|
| Back to top |
|
 |
Comrad Guest
|
Posted: Fri Jan 22, 2010 4:01 pm Post subject: Does this work now? |
|
|
| Andreone wrote: | AAARRRRRGGGGGG!
After a lot and a lot of tests, a lot of research, I'm still unable to get correct time values. There is clearly something wrong in the code because a C++/MFC application that use wininet.dll is able to provide times. I've look into the c++ code but cannot find hints. This is a nightmare.
Here's a new version of FileTimeToStr(ByRef @FileTime) that works fine (I tested it using Skan's post http://www.autohotkey.com/forum/topic8728-60.html ProcessCreationTime() (This is how I realize that binaries values MUST be passed as ByRef arguments).
The returned date/time is also compatible with ahk function FormatTime.
| Code: |
; FileTimeToSystemTime: http://msdn2.microsoft.com/en-us/library/ms724280.aspx
;~ typedef struct _SYSTEMTIME {
;~ WORD wYear;
;~ WORD wMonth;
;~ WORD wDayOfWeek;
;~ WORD wDay;
;~ WORD wHour;
;~ WORD wMinute;
;~ WORD wSecond;
;~ WORD wMilliseconds;
;~ } SYSTEMTIME;
FileTimeToStr(ByRef @FileTime)
{
VarSetCapacity(SystemTime, 16, 0)
DllCall("FileTimeToLocalFileTime", "uint", &@FileTime, "uint", &@FileTime)
DllCall("FileTimeToSystemTime", "uint", &@FileTime, "uint", &SystemTime)
str .= NumGet(SystemTime, 0, "ushort")
str .= StrLen(Word := NumGet(SystemTime, 2,"ushort")) == 1 ? ("0" . Word) : Word
str .= StrLen(Word := NumGet(SystemTime, 6,"ushort")) == 1 ? ("0" . Word) : Word
str .= StrLen(Word := NumGet(SystemTime, 8,"ushort")) == 1 ? ("0" . Word) : Word
str .= StrLen(Word := NumGet(SystemTime, 10,"ushort")) == 1 ? ("0" . Word) : Word
str .= StrLen(Word := NumGet(SystemTime, 12,"ushort")) == 1 ? ("0" . Word) : Word
return str
}
|
|
I am getting garbage with this code for the creation time. Does this have anything to do with NET 2.0 or higher? |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
|
| Back to top |
|
 |
haichen
Joined: 05 Feb 2007 Posts: 189 Location: Osnabrück, Germany
|
Posted: Tue Mar 09, 2010 12:39 am Post subject: |
|
|
I tried AHKLerners version. Works with win7 (only FTP_putfile tested).
| Code: | LocalFile=puttest.txt
NewRemoteFile= puttest.txt
server= www.ftptestserver.de
port:=21
username= testuser
password:="123"
FTP_Init()
hConnect:=FTP_Open(Server, Port, Username, Password)
FTP_PutFile(hConnect,LocalFile, NewRemoteFile)
FTP_CloseSocket(hConnect)
FTP_Close()
return
;======
;ftpfunctions
;======
...
|
|
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Tue Mar 09, 2010 1:53 am Post subject: |
|
|
I will try that, thx. Why do you FTP_Init()?? It does nothing!?
And no, i dont get it! Script hangs with FTP_Open(). May be it is not usable with Vista? Do have anyone other any experience with these functions? _________________ {1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <-- |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Tue Mar 09, 2010 2:03 am Post subject: |
|
|
It works now!
But what is happening? The example http://www.autohotkey.com/forum/viewtopic.php?p=124490#124490 show us any value not 1 is an error.
| Quote: | | Code: | ; establish connection to FTP server
connect:
FtpConnection := Ftp_Open(FtpHost, FtpPort, FtpUsername, FtpPassword)
If (FtpConnection != 1)
{
MsgBox, Error connecting to FTP server.
GoSub, quit
}
Return |
|
But your example worked with the autohotkey.net. The return value of Ftp_Open() is something high about 1. _________________ {1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <-- |
|
| Back to top |
|
 |
lexikos* Guest
|
Posted: Tue Mar 09, 2010 2:42 am Post subject: |
|
|
| That example is not relevant to ahklerner's version, which returns 0 on failure or the ic_hInternet handle (potentially any non-zero value) on success. |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
|
| Back to top |
|
 |
flyingDman
Joined: 27 Feb 2009 Posts: 690 Location: Burbank, California
|
Posted: Mon Mar 15, 2010 11:23 pm Post subject: |
|
|
FTP_PutFile and FTP_GetFile are about 2 to 3 times faster than the NCFTP (see http://www.ncftp.com/) which I have used in the past. Thank you for adding these functions!
I have 2 questions: I do not seem to get FTP_SetCurrentDirectory and FTP_GetCurrentDirectory to work. My test is as follows:
| Code: | dirnam = /lrfiles
hConnect:=FTP_Open(Server, Port, Username, Password)
FTP_SetCurrentDirectory(hConnect,dirnam)
FTP_CloseSocket(hConnect)
FTP_Close()
hConnect:=FTP_Open(Server, Port, Username, Password)
FTP_GetCurrentDirectory(hConnect, getdirnam)
FTP_CloseSocket(hConnect)
FTP_Close()
MsgBox %getdirnam%
|
lrfiles is an existing subfolder and MsgBox %getdirnam% shows "/"
What I am I doing wrong?
2nd, I had hoped to find a function that would retrieve a remote directory listing. I now use | Code: | | Runwait %comspec% /c %a_temp%\ncftpls.exe -1 -u %id% -p %pw% ftp://%id%@%host% >%a_temp%\rmtdir.txt,,hide |
which works fine, but such a function in the library would be much cleaner and presumably faster.
Any help would be much appreciated! _________________ "Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom" but let's start to get the data... |
|
| Back to top |
|
 |
drainx1
Joined: 10 Apr 2009 Posts: 139 Location: Wichita,Kansas
|
Posted: Wed Mar 17, 2010 6:48 pm Post subject: |
|
|
ok, well, i have tried to do this, using what was given. and i cant upload anything. here is my code. what happens is in red.
| Code: |
FtpHost = 127.0.0.1
FtpPort = 21
FtpUsername = test1
FtpPassword = testpass1
localFile = C:\FtpTest.txt
remoteFile = test\FtpTest.txt
uploadFile()
^!h::
exitapp
return
uploadFile()
{
; establish connection to FTP server
GoSub, connect
; backup existing file -- DEBUG: to do
; N.B.: existing files are being overwritten automatically
; store file on FTP server
fileTransfer := FtpPutFile(localFile, remoteFile)
If (fileTransfer != 1)
{
MsgBox, Error uploading file.
GoSub, quit
}
; close connection
FtpClose()
; confirmation message
MsgBox, Upload complete.
; terminate script
GoSub, quit
}
Return
FtpPutFile(localFile, NewRemoteFile="", Flags=0) {
;Flags:
;FTP_TRANSFER_TYPE_UNKNOWN = 0 (Defaults to FTP_TRANSFER_TYPE_BINARY)
;FTP_TRANSFER_TYPE_ASCII = 1
;FTP_TRANSFER_TYPE_BINARY = 2
If NewRemoteFile=
NewRemoteFile := LocalFile
global ic_hInternet
r := DllCall("wininet\FtpPutFileA"
, "uint", ic_hInternet
, "str", LocalFile
, "str", NewRemoteFile
, "uint", Flags
, "uint", 0) ;dwContext
If (ErrorLevel != 0 or r = 0)
return 0
else
return 1
}
connect:
FtpConnection := FtpOpen(FtpHost, FtpPort, FtpUsername, FtpPassword)
If (FtpConnection != 1)
{
MsgBox, Error connecting to FTP server.
GoSub, quit
}
Return
FtpOpen(Server, Port=21, Username=0, Password=0 ,Proxy="", ProxyBypass="") {
IfEqual, Username, 0, SetEnv, Username, anonymous
IfEqual, Password, 0, SetEnv, Password, anonymous
If (Proxy != "")
AccessType=3
Else
AccessType=1
;#define INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration
;#define INTERNET_OPEN_TYPE_DIRECT 1 // direct to net
;#define INTERNET_OPEN_TYPE_PROXY 3 // via named proxy
;#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS
global ic_hInternet, io_hInternet
hModule := DllCall("LoadLibrary", "str", "wininet.dll")
io_hInternet := DllCall("wininet\InternetOpenA"
, "str", A_ScriptName ;lpszAgent
, "UInt", AccessType
, "str", Proxy
, "str", ProxyBypass
, "UInt", 0) ;dwFlags
If (ErrorLevel != 0 or io_hInternet = 0) {
FtpClose()
return 0
}
ic_hInternet := DllCall("wininet\InternetConnectA"
, "uint", io_hInternet
, "str", Server
, "uint", Port
, "str", Username
, "str", Password
, "uint" , 1 ;dwService (INTERNET_SERVICE_FTP = 1)
, "uint", 0 ;dwFlags
, "uint", 0) ;dwContext
If (ErrorLevel != 0 or ic_hInternet = 0)
return 0
else
return 1
}
FtpClose() {
global ic_hInternet, io_hInternet
DllCall("wininet\InternetCloseHandle", "UInt", ic_hInternet)
DllCall("wininet\InternetCloseHandle", "UInt", io_hInternet)
DllCall("FreeLibrary", "UInt", hModule)
}
quit:
FtpClose()
ExitApp
Return |
I just cant find whats wrong with it.
It connects correctly, but cant upload anything. _________________ Drainx1
Your favorite.
What says that we aren't a visualization of someones dream?
And that person could change the laws of physics without thinking a thing about it.
They could recreate the world, and not know what happened. |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
|
| Back to top |
|
 |
drainx1
Joined: 10 Apr 2009 Posts: 139 Location: Wichita,Kansas
|
Posted: Wed Mar 17, 2010 7:25 pm Post subject: |
|
|
do you think im using it for a keylogger?
im using it for a bussiness site, copy a document that i wrote and send it via ftp to a business site. _________________ Drainx1
Your favorite.
What says that we aren't a visualization of someones dream?
And that person could change the laws of physics without thinking a thing about it.
They could recreate the world, and not know what happened. |
|
| 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
|