AutoHotkey Community

It is currently May 26th, 2012, 8:02 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: July 10th, 2009, 9:05 am 
Hi, i try to build a nice program to make some things easyer.
1 you can select a pdf, than he copy that pdf to a folder, 2 than you run a bat (for here he copy somethings) and 3 its can be upload by one click to a ftp, also thats works al fine. The ftp settings are in the script and ist works perfect, but i want that so when click to send he first ask for login name and pasword before sending, so that i not have to use login and name in the script, server is localhost. Can someone help me with this?

Thanks x
LD

Code:
Gui, Add, Button, x5 y45 w70 h30 gchoosedir, 1  Select
Gui, Add, Button, x100 y45 w70 h30 gbat, 2  Make
Gui, Add, Button, x195 y45 w70 h30 vupload gupload, 3  Upload!
; Generated using SmartGUI Creator 4.0
Gui, Show, x131 y91 h120 w280, Auto Updater
Return

GuiClose:
ExitApp

choosedir:
FileDelete, C:\source\source.pdf
FileSelectFile, file, 3, ,
FileCopy, %file%, C:\source\source.pdf
Gui,Submit,Nohide
MsgBox,select
return


bat:
run copy.bat
MsgBox,copy ready
return

upload:

FileDelete, C:\source\ftp_script.log
FileDelete, C:\source\ftp_script.txt
ftp_script = open localhost
ftp_script = %ftp_script%`r`nname
ftp_script = %ftp_script%`r`npasword
ftp_script = %ftp_script%`r`nls -l
ftp_script = %ftp_script%`r`nput c:\source\source.pdf


ftp_script = %ftp_script%`r`nquit

FileAppend, %ftp_script%, ftp_script%value%.txt

RunWait, cmd /c ftp -s:ftp_script%value%.txt > ftp_script%value%.log,, Hide

found_ls := false
text_ls=

Loop, Read, ftp_script%value%.log
{
   if ( InStr( a_LoopReadLine, "Directory send OK." ) )
      break
     
   if ( found_ls )
      text_ls := text_ls "`r`n" a_LoopReadLine

   if ( InStr( a_LoopReadLine, "Here comes the directory listing." ) )
      found_ls := true
}

MsgBox, % text_ls
return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 10th, 2009, 12:16 pm 
Offline

Joined: March 24th, 2005, 11:50 am
Posts: 398
Location: germany
You can use edit fields in your gui to enter the name and password, or you could start a second gui after you hit the upload-button. Here you could enter the name and password.
Gui, Add, Edit, vName, Name
and
Gui, Add, Edit, vPassword, Password
should be suitable in your script. You only should reread the name and Password before uploading.

Read about edit fields in the GUI section of the Help-File

Best regards
Garath


Report this post
Top
 Profile  
Reply with quote  
 Post subject: oke
PostPosted: July 10th, 2009, 3:24 pm 
Oke, is there a example so i can see it.
I have now add:

Gui, Show, x131 y91 h120 w280, Auto Updater
Gui, Add, Edit, vName, Name
Gui, Add, Edit, vPassword, Password
return
After Upload: Its nice but don't work



Code:
Gui, Add, Button, x5 y45 w70 h30 gchoosedir, 1  Select
Gui, Add, Button, x100 y45 w70 h30 gbat, 2  Make
Gui, Add, Button, x195 y45 w70 h30 vupload gupload, 3  Upload!
; Generated using SmartGUI Creator 4.0
Gui, Show, x131 y91 h120 w280, Auto Updater
Return

GuiClose:
ExitApp

choosedir:
FileDelete, C:\source\source.pdf
FileSelectFile, file, 3, ,
FileCopy, %file%, C:\source\source.pdf
Gui,Submit,Nohide
MsgBox,select
return


bat:
run copy.bat
MsgBox,copy ready
return

upload:
Gui, Show, x131 y91 h120 w280, Auto Updater
Gui, Add, Edit, vName, Name
Gui, Add, Edit, vPassword, Password
return

FileDelete, C:\source\ftp_script.log
FileDelete, C:\source\ftp_script.txt
ftp_script = open localhost
ftp_script = %ftp_script%`r`nname
ftp_script = %ftp_script%`r`npasword
ftp_script = %ftp_script%`r`nls -l
ftp_script = %ftp_script%`r`nput c:\source\source.pdf




ftp_script = %ftp_script%`r`nquit

FileAppend, %ftp_script%, ftp_script%value%.txt

RunWait, cmd /c ftp -s:ftp_script%value%.txt > ftp_script%value%.log,, Hide

found_ls := false
text_ls=

Loop, Read, ftp_script%value%.log
{
   if ( InStr( a_LoopReadLine, "Directory send OK." ) )
      break
     
   if ( found_ls )
      text_ls := text_ls "`r`n" a_LoopReadLine

   if ( InStr( a_LoopReadLine, "Here comes the directory listing." ) )
      found_ls := true
}

MsgBox, % text_ls
return


Report this post
Top
  
Reply with quote  
 Post subject: submit
PostPosted: July 10th, 2009, 3:44 pm 
read up on Gui, submit command


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 10th, 2009, 7:02 pm 
Oke, can you get a code for me? Where to place in the script?
Thankssss x


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2009, 1:32 pm 
why not incl da script?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2009, 2:28 pm 
Offline

Joined: June 19th, 2007, 12:04 am
Posts: 174
I would definitely check out this topic for the password end of it: http://www.autohotkey.com/forum/topic41428.html&highlight=computer+lock

If you need help, let me know.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2009, 2:37 pm 
Thanks!!
If you want to help, thanks alot.

The script is working fine but only i want to make a extra thing when in step3 before sending the pdf thats ask for name and password for the ftp, not the server adres but only the name and password.
I have search the forum and find something what likes that but i can't fixid in my script, maybe some help me with that.
Thanks again.
X


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2009, 4:14 pm 
Offline

Joined: March 24th, 2005, 11:50 am
Posts: 398
Location: germany
First of all you should only get the variables by clicking the upload button.
like this code:
Code:
Gui, Add, Button, x5 y45 w70 h30 gchoosedir, 1  Select
Gui, Add, Button, x100 y45 w70 h30 gbat, 2  Make
Gui, Add, Button, x195 y45 w70 h30 vupload gupload, 3  Upload!
Gui, Add, Text,x5 y90, Name:
Gui, Add, Edit,x70 y90 vName, Name
Gui, Add, Text,x5 y120, Password:
Gui, Add, Edit,x70 y120 vPassword, Password
; Generated using SmartGUI Creator 4.0
Gui, Show, x131 y91 h150 w280, Auto Updater
Return

GuiClose:
ExitApp

choosedir:
;FileDelete, C:\source\source.pdf
FileSelectFile, file, 3, ,
;FileCopy, %file%, C:\source\source.pdf
Gui,Submit,Nohide
MsgBox,select
return


bat:
;run copy.bat
MsgBox,copy ready
return

upload:
Gui, submit, nohide
;Place your upload-code here
msgbox, Name:%Name%`nPassword:%Password%
return

;FileDelete, C:\source\ftp_script.log
;FileDelete, C:\source\ftp_script.txt
ftp_script = open localhost
ftp_script = %ftp_script%`r`nname
ftp_script = %ftp_script%`r`npasword
ftp_script = %ftp_script%`r`nls -l
ftp_script = %ftp_script%`r`nput c:\source\source.pdf




ftp_script = %ftp_script%`r`nquit

;FileAppend, %ftp_script%, ftp_script%value%.txt

;RunWait, cmd /c ftp -s:ftp_script%value%.txt > ftp_script%value%.log,, Hide

found_ls := false
text_ls=

Loop, Read, ftp_script%value%.log
{
   if ( InStr( a_LoopReadLine, "Directory send OK." ) )
      break
     
   if ( found_ls )
      text_ls := text_ls "`r`n" a_LoopReadLine

   if ( InStr( a_LoopReadLine, "Here comes the directory listing." ) )
      found_ls := true
}

MsgBox, % text_ls
return



the other possibility would be a second gui or the inputbox
http://www.autohotkey.com/docs/commands/InputBox.htm
Descriptions and examples can be found in the help file.
if you need more specific help, ask about it :wink:


Last edited by garath on July 11th, 2009, 10:36 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2009, 4:22 pm 
Oke Thanks.

Thats nice, but if i put in the name and password, the gui has gone and i see only a popup that shows my name and pasword.

Can it be so that put in name and password like now is, than i click on upload, he upload the file and than after that he gives a message, like upload compleet, but the gui stay on top?
I see he sending nothing now.
x


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2009, 10:43 pm 
Offline

Joined: March 24th, 2005, 11:50 am
Posts: 398
Location: germany
You have to use the nohide option to do not hide the Gui, i painted the changes in red in my last example.
Place the Upload-code in the upload part, marked also in red.
I commented some parts of your code out, because I dont want to read an write on my PC. Remove the ; in the green code parts, or adjust your code accordingly.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2009, 8:24 pm 
Thanks Again
But sorry i am blond mmm.

I have put the the next code into the script, and he want to send it, but in the log i see that he try to login with username: name and pasword: pasword, not what i put in the edit bar.
Code:
upload:
Gui, submit, nohide
;Place your upload-code here
msgbox, Name:%Name%`nPassword:%Password%


FileDelete, C:\swftools\ftp_script.log
FileDelete, C:\swftools\ftp_script.txt

ftp_script = open localhost
ftp_script = %ftp_script%`r`nname
ftp_script = %ftp_script%`r`npasword
ftp_script = %ftp_script%`r`nls -l


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2009, 8:46 pm 
Offline

Joined: March 24th, 2005, 11:50 am
Posts: 398
Location: germany
You forgot the %-Signs, try the following code example:

Code:
name = LadyDutch
pasword = blond

ftp_script = open localhost
ftp_script = %ftp_script%`r`n%name%
ftp_script = %ftp_script%`r`n%pasword%
ftp_script = %ftp_script%`r`nls -l
ftp_script = %ftp_script%`r`nput c:\source\source.pdf

msgbox, %ftp_script%

we want the variable value from "name" and "pasword" in the string variable "ftp-script"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2009, 11:01 pm 
Wow Thankssss
It works!!!

Again, Thanks for youre help.

x


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Retro Gamer, wolverineks and 66 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group