Sign in to follow this  
Followers 0
Cruz

Using Send() command to send a password...

20 posts in this topic

I am using the Send() command to send a password to another program but if the $password variable contains anything other than just alphanumeric characters (i.e. PaSSword!, PA55word#) the special characters are dropped when I use the variable.

$password = GUICtrlCreateInput("",80,60,150,20,)

...

...

...

Send(GUICtrlRead($password))

Is there a better way of doing this??

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

YESSSS !!!!!!!!!!!!!

I got it

#include <GUIConstants.au3>
#include <Misc.au3>
#include <Array.au3>
;Dim $array

GUICreate(" My GUI input acceptfile", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateLabel ( "Please type in your password", 10,  5, 300, 20)

$passwd = GUICtrlCreateInput ("", 10,  35, 300, 20); will not accept drag&drop files

$btn = GUICtrlCreateButton ("Ok", 40,  75, 60, 20)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$btn2 = GUICtrlCreateButton ("Exit", 200,  75, 60, 20)

GUISetState () 

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
        Case $msg = $btn2
           Exit
       Case $msg = $btn
          
           Call("Set_passwd")
            
       EndSelect
Wend

Func Set_passwd()
    
; for testing
    Run("notepad.exe")
    WinWaitActive("")
    Sleep(1000)

    
    $pass = GUICtrlRead($passwd)
    $array = StringSplit($pass,"")
;_ArrayDisplay($array)
    For $x = 1 to $array[0]
    ;MsgBox(0,"test", $array[$x],1)
        if $array[$x] >= Chr(48) And $array[$x] <= Chr(57) Or $array[$x] >= Chr(65) And $array[$x] <= Chr(90) Or $array[$x] >= Chr(97) And $array[$x] <= Chr(122) Then Send($array[$x])
        if $array[$x] = " " Then Send(Chr(32),1)    
        if $array[$x] = "!" Then Send(Chr(33),1)
        if $array[$x] = '"' Then Send(Chr(34),1)    
        if $array[$x] = "#" Then Send(Chr(35),1)        
        if $array[$x] = "$" Then Send(Chr(36),1)    
    ; until you get all you want
    Next
EndFunc

Kept trying and whala...

Yes.... Yes... Yes......

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

BUMPER...

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I am using the Send() command to send a password to another program but if the $password variable contains anything other than just alphanumeric characters (i.e. PaSSword!, PA55word#) the special characters are dropped when I use the variable.

$password = GUICtrlCreateInput("",80,60,150,20,)

...

...

...

Send(GUICtrlRead($password))

Is there a better way of doing this??

Share this post


Link to post
Share on other sites

@r4v3n

Did you forget to type something (ie a question or comment)



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

Thanks for your help Valuater!!

;)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

What about sending the variable as raw keys? That way special keys aren't interpreted as shifts and what not?

That and ControlSend is a much safer alternative for sending keystrokes to an application...

test.au3

Edited by MSLx Fanboy

Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

for gods sake not you too ;)

why do you guys keep using call ?

You mentioned this before and i didn't reply... so

this is the use (as i understand) of Call()

Create GUI

Create $button

set state

While

$m = get message

if $m = $button then Call("my_function")

wend


Func my_function

message box

endfunc

isn't this a correct use of Call()

????

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Yes, it's correct, but it isn't needed.

There are two pissibilities to call a function:

1. Call("FuncName")

2. FuncName()

With the second command you can send additional parameters to the function. It's the standard format.

For example:

ShowMyName("Buffo")

Func ShowMyName($name)
MsgBox(0, "Your name is", $name)
EndFunc

Cu,

Buffo

Share this post


Link to post
Share on other sites

Yes, it's correct, but it isn't needed.

Buffo

thx

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Yes, it's correct...

That is a matter of some debate. Just take a look at a few opinions:

http://www.autoitscript.com/forum/index.ph...lite=call%28%29

...two pissibilities...

Great typo!

Some would say that if FuncName() will work and you use Call(), you are wrong.

I do not really care - I just could not pass up posting about the "pissibilities"..............later


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Plato PM'ed me with a question about just using

Send(GUICtrlRead($passwd), 1)

and yes...... it worked

#include <GUIConstants.au3>

GUICreate(" My GUI input acceptfile", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateLabel ( "Please type in your password", 10, 5, 300, 20)

$passwd = GUICtrlCreateInput ("", 10, 35, 300, 20); will not accept drag&drop files

$btn = GUICtrlCreateButton ("Ok", 40, 75, 60, 20)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$btn2 = GUICtrlCreateButton ("Exit", 200, 75, 60, 20)

GUISetState () 

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $btn2
Exit
Case $msg = $btn

Send(GUICtrlRead($passwd), 1)

EndSelect
Wend

to call or not to call was not the question (plato)

thx

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

As for call...it really is pointless. I mean a function to call another function? Yeah...

Share this post


Link to post
Share on other sites

Which function is calling what function... i don't see it here in any of these posts?????

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Call("Set_passwd")

if $m = $button then Call("my_function")

Well, Call is useless here its not batchfile

If you would you also would need to call call and call that also

like call("call(""call(""""call(""""""infiniti"""""")""""")"")

Explain why please ;)

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Well, Call is useless here its not batchfile

If you would you also would need to call call and call that also

like call("call(""call(""""call(""""""infiniti"""""")""""")"")

Explain why please ;)

neither of those were inside of a function

they were inside a while/wend loop

and according to the help file

For $i = 1 to 2
    $ret = Call("test" & $i)
    MsgBox(4096,"", $ret)
Next

Func test1()
    Return "Hello"
EndFunc

Func test2()
    Return "Bye"
EndFunc

the function Call() is utilized within a loop..... and utilizes two different functions

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

I only ever use call if I would want a user to execute a certain function...

Say I make a Gui with a bunch of labels and an input box

let him type it in exactly, then it just calls it.

That's still not the easiest way to do it...but don't forget, params for functions must have defaults, or I'm pretty sure it will error. It took me forever to remember that when I had a COM Error function...what a nightmare that was...interfacing an error function with a com object and a normal function...


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

Like MSLx, I thought that "to call or not to call" was based on needing a variable as the (or part of the) function name. See this post that caused Call() to be added to AutoIt3: http://www.autoitscript.com/forum/index.ph...338&st=0&p=1626

Thanks Valuater for testing/posting.

I was too tired to test what MSLx tried to inject in post #8:

"What about sending the variable as raw keys? That way special keys aren't interpreted as shifts and what not?"

and perhaps Cruz should heed the other suggestion in that post:

"That and ControlSend is a much safer alternative for sending keystrokes to an application..."

later


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

"What about sending the variable as raw keys? That way special keys aren't interpreted as shifts and what not?"

and perhaps Cruz should heed the other suggestion in that post:

"That and ControlSend is a much safer alternative for sending keystrokes to an application..."

The Send(GUICtrlRead($variable),1) command with raw keys option worked. A couple of my users had special characters in their passwords and this command worked perfecty.

Thanks for the help guys, I am really learning from reading this forum.

-Cruz

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