How to pass runtime parameter using masked/hidden input

Asked by Ramprasad on 2012-04-13

Is it possible to pass a run time parameter to a variable in sikuli code.

I had hardcoded password in my code and I need to pass it in runtime..Is it possible?

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2012-04-16
Last query:
2012-04-16
Last reply:
2012-04-16
RaiMan (raimund-hocke) said : #1

use the input() feature:

pass = input("pls. enter password")

Ramprasad (ramprasad-info) said : #2

Thanks RaiMan.

Is there option available to mask the typed word with asterisk?

Best RaiMan (raimund-hocke) said : #3

This is not available currently as a feature of input() (is on the agenda though).

As a workaround, you can use the underlying Java classes directly.

A working example:

import javax.swing.JOptionPane as JOP
import javax.swing.JPasswordField as JPF

pwdF = JPF()
pwdValid = "123456"
isValid = False
trials = 3

while trials > 0:
    trials -= 1
    result = JOP.showConfirmDialog(None, pwdF,
        "Please enter Password ( 3 trials )",
        JOP.OK_CANCEL_OPTION)
    if result <> 0:
        break
    if pwdValid <> pwdF.getText():
        continue
    else:
        isValid = True
        break

if isValid:
    popup("Hello welcome")
else:
    popup("Sorry, go to hell!")

Ramprasad (ramprasad-info) said : #4

Thanks RaiMan,

That solved my problem.

Ramprasad (ramprasad-info) said : #5

Thanks RaiMan, that solved my question.

Ramprasad (ramprasad-info) said : #6

import javax.swing.JOptionPane as JOP
import javax.swing.JPasswordField as JPF
pwdF = JPF()
JOP.showConfirmDialog(None, pwdF,
        "Please enter Password",
        JOP.OK_CANCEL_OPTION)
passwd = pwdF.getText()

RaiMan (raimund-hocke) said : #7

does it work?

Ramprasad (ramprasad-info) said : #8

yes it does