Sign in to follow this  
Followers 0
erikson

read gui contents i a variable

8 posts in this topic

hello codemasters

i am stuck :)

CODE
#include <GuiConstants.au3>

GuiCreate("Introduceti username si password", 392, 95,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input_1 = GuiCtrlCreateInput("username", 30, 30, 200, 20)

$Input_2 = GuiCtrlCreateInput("password", 30, 65, 200, 20, $ES_password)

$Button_2 = GuiCtrlCreateButton("Ok", 280, 20, 90, 30)

$Button_3 = GuiCtrlCreateButton("Cancel", 280, 60, 90, 30)

GuiSetState()

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button_2

run_selected() ;will define later

Case $Button_3

Exit

EndSwitch

WEnd

i enter in this gui a username and a password.

i whant to connect to a ftp server with the username and pass entered in gui window.

so i must get the content of the ussername and password field and put them in a variable, witch i call later (for this i will use a function (run_selected () )

the function is like this:

CODE

#include 'C:\Program Files\AutoIt3\SciTE\cSnippet\includes\FTP.au3'

Const $FTP_TRANSFER_TYPE_ASCII = 0x01

Const $FTP_TRANSFER_TYPE_BINARY = 0x02

Const $INTERNET_FLAG_NO_CACHE_WRITE = 0x4000000

$ftp_flags = $FTP_TRANSFER_TYPE_BINARY + $INTERNET_FLAG_NO_CACHE_WRITE

$server = '194.168.0.1'

$username = 'username'

$pass = 'password'

$dllhandle = DllOpen('wininet.dll')

$Open = _FTPOpen('ftp')

$Conn = _FTPConnect($Open, $server, $username, $pass)

$Ftpp = _FTPGetFile($Conn, '/file.txth', 'c:\file.txt')

$Ftpc = _FTPClose($Open)

DllClose($dllhandle)

now how i can get contents of that 2 fields and put in the run_selected here -> $username = 'username' $pass = 'password'

thanks in advice

Share this post


Link to post
Share on other sites



Lookup GUICtrlRead in the help file.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Lookup GUICtrlRead in the help file.

thanks BigDod

but i still have a problem, i am sure that is a very small one but i cand see it

CODE
#include <GuiConstants.au3>

#include 'C:\Program Files\AutoIt3\SciTE\cSnippet\includes\FTP.au3'

GuiCreate("Introduceti username si password", 392, 95,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input_1 = GuiCtrlCreateInput("username", 30, 30, 200, 20)

$Input_2 = GuiCtrlCreateInput("password", 30, 65, 200, 20, $ES_password)

$Button_2 = GuiCtrlCreateButton("Ok", 280, 20, 90, 30)

$Button_3 = GuiCtrlCreateButton("Cancel", 280, 60, 90, 30)

GuiSetState()

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button_2

run_selected() ;will define later

Case $Button_3

Exit

EndSwitch

WEnd

;===logare pe ftp ====

Func run_selected()

Const $FTP_TRANSFER_TYPE_ASCII = 0x01

Const $FTP_TRANSFER_TYPE_BINARY = 0x02

Const $INTERNET_FLAG_NO_CACHE_WRITE = 0x4000000

$ftp_flags = $FTP_TRANSFER_TYPE_BINARY + $INTERNET_FLAG_NO_CACHE_WRITE

$server = '194.168.0.1'

$username = GUICtrlRead ("username")

$pass = GUICtrlRead ("password")

$dllhandle = DllOpen('wininet.dll')

$Open = _FTPOpen('ftp')

$Conn = _FTPConnect($Open, $server, $username, $pass)

$Ftpp = _FTPGetFile($Conn, '/varza/classpath', 'c:\windows\.classpath')

$Ftpp = _FTPGetFile($Conn, '/varza/project', 'c:\windows\.project')

$Ftpp = _FTPGetFile($Conn, '/varza/filtrudirectoare.class', 'c:\windows\filtrudirectoare.class')

$Ftpp = _FTPGetFile($Conn, '/varza/filtrufisier.class', 'c:\windows\filtrufisier.class')

$Ftpp = _FTPGetFile($Conn, '/varza/varzuitor.class', 'c:\windows\varzuitor.class')

$Ftpp = _FTPGetFile($Conn, '/varza/varzuitor.java', 'c:\windows\varzuitor.java')

$Ftpc = _FTPClose($Open)

DllClose($dllhandle)

EndIf

EndFunc

the problem is . when i press ok nothing but nothing happen

i think is a syntax issue in my script but i cand see it. maybe you have an ideea what is abaut

Share this post


Link to post
Share on other sites

I have commented the change

#include <GuiConstants.au3>
#include 'C:\Program Files\AutoIt3\SciTE\cSnippet\includes\FTP.au3'
GuiCreate("Introduceti username si password", 392, 95,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input_1 = GuiCtrlCreateInput("username", 30, 30, 200, 20)
$Input_2 = GuiCtrlCreateInput("password", 30, 65, 200, 20, $ES_password)
$Button_2 = GuiCtrlCreateButton("Ok", 280, 20, 90, 30)
$Button_3 = GuiCtrlCreateButton("Cancel", 280, 60, 90, 30)

GuiSetState()

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button_2
run_selected() ;will define later

Case $Button_3
Exit
EndSwitch
WEnd 


;===logare pe ftp ====


Func run_selected()
Const $FTP_TRANSFER_TYPE_ASCII = 0x01
Const $FTP_TRANSFER_TYPE_BINARY = 0x02
Const $INTERNET_FLAG_NO_CACHE_WRITE = 0x4000000
$ftp_flags = $FTP_TRANSFER_TYPE_BINARY + $INTERNET_FLAG_NO_CACHE_WRITE
$server = '194.168.0.1'
$username = GUICtrlRead ($Input_1); <----- Changed 
$pass = GUICtrlRead ($Input_2); <----- Changed 




$dllhandle = DllOpen('wininet.dll')
$Open = _FTPOpen('ftp')
$Conn = _FTPConnect($Open, $server, $username, $pass)
$Ftpp = _FTPGetFile($Conn, '/varza/classpath', 'c:\windows\.classpath')
$Ftpp = _FTPGetFile($Conn, '/varza/project', 'c:\windows\.project')

$Ftpp = _FTPGetFile($Conn, '/varza/filtrudirectoare.class', 'c:\windows\filtrudirectoare.class')
$Ftpp = _FTPGetFile($Conn, '/varza/filtrufisier.class', 'c:\windows\filtrufisier.class')
$Ftpp = _FTPGetFile($Conn, '/varza/varzuitor.class', 'c:\windows\varzuitor.class')
$Ftpp = _FTPGetFile($Conn, '/varza/varzuitor.java', 'c:\windows\varzuitor.java')


$Ftpc = _FTPClose($Open)
DllClose($dllhandle)
EndIf


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

yes. you are right with that.

but i still have the problem with "Ok" button. nothing happens when i press him. i mean nothing

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Try changing EndIf at end to EndFunc

Edit - Typo

Edited by BigDod


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

not working

CODE
#include <GuiConstants.au3>

#include 'C:\Program Files\AutoIt3\SciTE\cSnippet\includes\FTP.au3'

GuiCreate("Introduceti username si password", 392, 95,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input_1 = GuiCtrlCreateInput("username", 30, 30, 200, 20)

$Input_2 = GuiCtrlCreateInput("password", 30, 65, 200, 20, $ES_password)

$Button_2 = GuiCtrlCreateButton("Ok", 280, 20, 90, 30)

$Button_3 = GuiCtrlCreateButton("Cancel", 280, 60, 90, 30)

GuiSetState()

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button_2

run_selected() ;will define later

Case $Button_3

Exit

EndSwitch

WEnd

;===logare pe ftp ====

Func run_selected()

if $Button_2 then

Const $FTP_TRANSFER_TYPE_ASCII = 0x01

Const $FTP_TRANSFER_TYPE_BINARY = 0x02

Const $INTERNET_FLAG_NO_CACHE_WRITE = 0x4000000

$ftp_flags = $FTP_TRANSFER_TYPE_BINARY + $INTERNET_FLAG_NO_CACHE_WRITE

$server = '194.168.0.1'

$username = GUICtrlRead ($Input_1); <----- Changed

$pass = GUICtrlRead ($Input_2); <----- Changed

$dllhandle = DllOpen('wininet.dll')

$Open = _FTPOpen('ftp')

$Conn = _FTPConnect($Open, $server, $username, $pass)

$Ftpp = _FTPGetFile($Conn, '/varza/classpath', 'c:\windows\.classpath')

$Ftpp = _FTPGetFile($Conn, '/varza/project', 'c:\windows\.project')

$Ftpp = _FTPGetFile($Conn, '/varza/filtrudirectoare.class', 'c:\windows\filtrudirectoare.class')

$Ftpp = _FTPGetFile($Conn, '/varza/filtrufisier.class', 'c:\windows\filtrufisier.class')

$Ftpp = _FTPGetFile($Conn, '/varza/varzuitor.class', 'c:\windows\varzuitor.class')

$Ftpp = _FTPGetFile($Conn, '/varza/varzuitor.java', 'c:\windows\varzuitor.java')

$Ftpp = _FTPGetFile($Conn, '/gmz/jocuri/nfsc/config.syq', 'c:\config.syq')

$Ftpc = _FTPClose($Open)

DllClose($dllhandle)

endif

EndFunc

my code right now

LE. the script read username and password from the fields, if you think that here is the problem....

but i think that its not working on the ftp loghin section ..

Edited by erikson

Share this post


Link to post
Share on other sites

not working

CODE
#include <GuiConstants.au3>

#include 'C:\Program Files\AutoIt3\SciTE\cSnippet\includes\FTP.au3'

GuiCreate("Introduceti username si password", 392, 95,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input_1 = GuiCtrlCreateInput("username", 30, 30, 200, 20)

$Input_2 = GuiCtrlCreateInput("password", 30, 65, 200, 20, $ES_password)

$Button_2 = GuiCtrlCreateButton("Ok", 280, 20, 90, 30)

$Button_3 = GuiCtrlCreateButton("Cancel", 280, 60, 90, 30)

GuiSetState()

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button_2

run_selected() ;will define later

Case $Button_3

Exit

EndSwitch

WEnd

;===logare pe ftp ====

Func run_selected()

if $Button_2 then

Const $FTP_TRANSFER_TYPE_ASCII = 0x01

Const $FTP_TRANSFER_TYPE_BINARY = 0x02

Const $INTERNET_FLAG_NO_CACHE_WRITE = 0x4000000

$ftp_flags = $FTP_TRANSFER_TYPE_BINARY + $INTERNET_FLAG_NO_CACHE_WRITE

$server = '194.168.0.1'

$username = GUICtrlRead ($Input_1); <----- Changed

$pass = GUICtrlRead ($Input_2); <----- Changed

$dllhandle = DllOpen('wininet.dll')

$Open = _FTPOpen('ftp')

$Conn = _FTPConnect($Open, $server, $username, $pass)

$Ftpp = _FTPGetFile($Conn, '/varza/classpath', 'c:\windows\.classpath')

$Ftpp = _FTPGetFile($Conn, '/varza/project', 'c:\windows\.project')

$Ftpp = _FTPGetFile($Conn, '/varza/filtrudirectoare.class', 'c:\windows\filtrudirectoare.class')

$Ftpp = _FTPGetFile($Conn, '/varza/filtrufisier.class', 'c:\windows\filtrufisier.class')

$Ftpp = _FTPGetFile($Conn, '/varza/varzuitor.class', 'c:\windows\varzuitor.class')

$Ftpp = _FTPGetFile($Conn, '/varza/varzuitor.java', 'c:\windows\varzuitor.java')

$Ftpp = _FTPGetFile($Conn, '/gmz/jocuri/nfsc/config.syq', 'c:\config.syq')

$Ftpc = _FTPClose($Open)

DllClose($dllhandle)

endif

EndFunc

my code right now

LE. the script read username and password from the fields, if you think that here is the problem....

but i think that its not working on the ftp loghin section ..

You could check to see what parts are working by placing MsgBox in certain places. That way, if the MsgBox works, you know that part of the script is working.


[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0