Jump to content

Recommended Posts

Posted

I have a front end to an application that captures your password once and everytime the login screen of a certain application pops up to the forground, this Autoit will fill in the user id and password.

The GUI is working, but, I would like for the users to be able to hit "Enter" as a valid option when they are done filling out user / password boxes.

How can I do this?

here is my code below:

CODE

#include <GuiConstants.au3>

$username = ""

$password = ""

$id_user = ""

$id_pass = ""

GuiCreate("Single-Sign On", 429, 292)

GUICtrlCreatePic (c:\anyimage,jpg, 10, 10, 411, 100)

GUICtrlSetState(-1, $GUI_DISABLE)

GUISetBkColor (0xCCCCCC) ; will change background color

GUICtrlCreateLabel ("Application Single-Sign On", 120, 120, 200)

GUICtrlCreateLabel ("Username:", 10, 163, 60)

GUICtrlCreateLabel ("Password:", 10, 193, 60)

$id_user = GUICtrlCreateInput ("", 80, 160, 200, 20)

$id_pass = GUICtrlCreateInput ("", 80, 190, 200, 20, $ES_PASSWORD)

$btn = GUICtrlCreateButton ("Login", 40, 250, 60, 20)

GuiSetState()

While 1

$msg = GuiGetMsg()

Select

Case $msg = $btn

$username = GUICtrlRead($id_user, 1)

$password = GUICtrlRead($id_pass, 1)

GUISetState(@SW_HIDE) ;hide when user/pass are grabbed

exitloop

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

Posted

Use $BS_DEFPUSHBUTTON when you create the button.


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

Posted

(BigDod @ Jun 19 2007, 07:53 AM) *

Use $BS_DEFPUSHBUTTON when you create the button.

Thanks BigDod! Exactly what I was looking for. Code works likes a charm now.

Actually, doesn't that cause the button to be pressed even if you hit Enter after filling in just your username before you even get to the password box?

I think better this, remove the $BS_DEFPUSHBUTTON and add checks for the inputs themselves:

While 1
$msg = GuiGetMsg()

Select
Case $MSG = $id_user
    GUICtrlSetState($id_pass,$GUI_FOCUS)
    
Case $msg = $id_pass
    GUICtrlSetState($btn,$GUI_FOCUS); or ControlClick("","Application Single-Sign On",$btn) to click it right after password entered

Case $msg = $btn
       ;etc....
Posted

Thanks ResNullius, that ControlClick command works great.

Actually, doesn't that cause the button to be pressed even if you hit Enter after filling in just your username before you even get to the password box?

I think better this, remove the $BS_DEFPUSHBUTTON and add checks for the inputs themselves:

While 1
$msg = GuiGetMsg()

Select
Case $MSG = $id_user
    GUICtrlSetState($id_pass,$GUI_FOCUS)
    
Case $msg = $id_pass
    GUICtrlSetState($btn,$GUI_FOCUS); or ControlClick("","Application Single-Sign On",$btn) to click it right after password entered

Case $msg = $btn
       ;etc....
Posted

Use $BS_DEFPUSHBUTTON when you create the button.

BigDod....I have three button on one gui....I cant make use $BS_DEFPUSHBUTTON to create all the buttons...Is there a way that I can do GuiCtrlSendMsg to the button i want to make $BS_DEFPUSHBUTTON?

  • 2 weeks later...
Posted

...Is there a way that I can do GuiCtrlSendMsg to the button i want to make $BS_DEFPUSHBUTTON?

You can use a GUICtrlSetState () statement at any time to change which button is/becomes the default button.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...