Jump to content
Sign in to follow this  
dahffey

Auto 3rd party logon HELP!!!!!

Recommended Posts

dahffey

I am trying to be as simple as possible:

1) Call program

2) Wait for logon screen to appear

3) Fill in username and password and Click enter

What happens is whne the program comes up, it sits and waits for me to click somewhere before continuing. I have tried about 2 dozen different commands to fix the focus issue. Someone please steer me the right way.

Thanks,

Derek

Run ("C:\Program Files\syngoDynamics\bin\KinetDxLauncher.exe /a rsntmain.exe")

WinWaitActive("[TITLE:syngo Dynamics Workplace; CLASS:Win32WorkstationWindow]", "")

ControlGetFocus("syngo Dynamics Workplace", "[CLASS:WindowsForms10.EDIT.app.0.d3a00f; INSTANCE:2]")

ControlClick("syngo Dynamics Workplace", "left", ", 20 , 40")

ControlSend("syngo Dynamics Workplace", "", "[CLASS:WindowsForms10.EDIT.app.0.d3a00f; INSTANCE:1]", "username")

ControlSend("syngo Dynamics Workplace", "", "[CLASS:WindowsForms10.EDIT.app.0.d3a00f; INSTANCE:2]", "password{ENTER}")

Share this post


Link to post
Share on other sites
EndFunc

I am trying to be as simple as possible:

1) Call program

2) Wait for logon screen to appear

3) Fill in username and password and Click enter

What happens is whne the program comes up, it sits and waits for me to click somewhere before continuing. I have tried about 2 dozen different commands to fix the focus issue. Someone please steer me the right way.

Thanks,

Derek

Run ("C:\Program Files\syngoDynamics\bin\KinetDxLauncher.exe /a rsntmain.exe")

WinWaitActive("[TITLE:syngo Dynamics Workplace; CLASS:Win32WorkstationWindow]", "")

ControlGetFocus("syngo Dynamics Workplace", "[CLASS:WindowsForms10.EDIT.app.0.d3a00f; INSTANCE:2]")

ControlClick("syngo Dynamics Workplace", "left", ", 20 , 40")

ControlSend("syngo Dynamics Workplace", "", "[CLASS:WindowsForms10.EDIT.app.0.d3a00f; INSTANCE:1]", "username")

ControlSend("syngo Dynamics Workplace", "", "[CLASS:WindowsForms10.EDIT.app.0.d3a00f; INSTANCE:2]", "password{ENTER}")

Maybe somehow the window is not opening as the active window. Why don't you add a condition to check for the existance of the window first?

Something like this perhaps?

If Not WinExists("titlehere") Then
Do

Sleep(500)

until WinExists("windowtitle")
EndIf
WinActivate("title")
Sleep(500)
ControlGetFocus("syngo Dynamics Workplace", "[CLASS:WindowsForms10.EDIT.app.0.d3a00f; INSTANCE:2]")
ControlClick("syngo Dynamics Workplace", "left", ", 20 , 40")
ControlSend("syngo Dynamics Workplace", "", "[CLASS:WindowsForms10.EDIT.app.0.d3a00f; INSTANCE:1]", "username")
ControlSend("syngo Dynamics Workplace", "", "[CLASS:WindowsForms10.EDIT.app.0.d3a00f; INSTANCE:2]", "password{ENTER}")
Edited by EndFunc

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites
marc0v

You probably got confused between ControlFocus, to focus a control, and ControlGetFocus to get the name of the currently focused control

But you don't need to use ControlFocus or ControlGetFocus.

Anyway, you first need to get the handle of the logon window

with the logon window TITLE : "my_logon_window_title" = "syngo Dynamics Workplace" ?

and/or the logon window CLASS : "my_logon_window_class" = "Win32WorkstationWindow" ?

Const $logon_window_title = "syngo Dynamics Workplace"
Const $logon_window_class = "Win32WorkstationWindow"
Const $edit_field_class = "WindowsForms10.EDIT.app.0.d3a00f"
Const $username_edit_instance = 1
Const $password_edit_instance = 2
Const $ok_button_classnn = "Button1" ; might be Button2 or 3...
Const $ms_timeout = 30000

Run("C:\Program Files\syngoDynamics\bin\KinetDxLauncher.exe /a rsntmain.exe")

$ms_waited = 0
Do
  $hwin = WinGetHandle("[TITLE:" & $logon_window_title & "; CLASS:" & $logon_window_class & "]")
  Sleep(250)
  $ms_waited = $ms_waited + 250
Until $hwin <> "" Or $ms_waited > $ms_timeout

If $hwin = "" Then
  MsgBox(0, "Error", "Logon window not found")
  Exit
EndIf

MsgBox(0, "Success", "Logon window handle : " & $hwin)

ControlSetText($hwin, "", "[CLASS:" & $edit_field_class & "; INSTANCE:" & $username_edit_instance & "]", "username here", 1)
ControlSetText($hwin, "", "[CLASS:" & $edit_field_class & "; INSTANCE:" & $password_edit_instance & "]", "password here", 1)

ControlClick($hwin, "", $ok_button_classnn, "primary", 1)

Once you got a valid $hwin, you can proceed with ControlClick and ControlSetText...

ControlClick("syngo Dynamics Workplace", "left", ", 20 , 40")

=> obviously an error with misplaced quotes

=> "primary" is better than "left" because mouse button can be swapped

=> syntax : ControlClick($hwin, "", CLASSNN of control, "primary", 1)

* $hwin is the handle of the window we got before

* look at documentation for parameters order and meaning

=> you need the CLASSNN (like Edit1, or Edit2) of the control you want to click

or an expression like : "[CLASS:WindowsForms10.EDIT.app.0.d3a00f; INSTANCE:1]"

if "WindowsForms10.EDIT.app.0.d3a00f" is the CLASS of the control

To set text, better than than ControlSend (which requires a ControlFocus before each sending) is ControlSetText

=> syntax : ControlSetText($hwin, "", CLASSNN of control, "username or password you want", 0 or 1 to force a window redraw)

* $hwin is the handle of the window we got before

* look at documentation for parameters order and meaning

=> same as controlclick, you need the CLASSNN (like Edit1, or Edit2) of the control you want to set the text

or an expression like : "[CLASS:WindowsForms10.EDIT.app.0.d3a00f; INSTANCE:1]"

if "WindowsForms10.EDIT.app.0.d3a00f" is the CLASS of the control

=> better than sending {ENTER} when the text has been set, is to ControlClick the "OK" button...

Use the autoit info tool (Au3Info.exe) to get the CLASS and INSTANCE of all needed controls within the logon window

(CLASSNN is the concatenation of CLASS + INSTANCE)

The "text" parameter in ControlClick and ControlSetText is optionnal and should be left empty : ""

Edited by marc0v

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.