Jump to content

Recommended Posts

Posted (edited)

Hello. My Autoit script is performing the autofill of username and password for the application Bomgar. The problem, is that it does not input the password correctly. I want Autoit to fill the username, then delay X amount of time before it attempts to autofill the password. How would I do that? Below is a snip of the script where it mentions autofilling the username and password. There is also an attached screenshot showing the logon box. 

;Sleep (30)
WinWait("Bomgar - Representative Login","",30)
WinActivate ($ConnectionClientPID)

    Send ($TargetUsername)
    Send ("{TAB}")
    Send ($TargetPassword)
    Send ("{ENTER}")
     _BlockInputEx(0)
    if ($ConnectionClientPID == 0) Then
        Error(StringFormat("Failed to execute process [%s]", $CLIENT_EXECUTABLE, @error))
     EndIf

Capture.PNG.6932f52f411594dc4a1f700fbe2c9486.PNGCapture.PNG

Edited by JDallas23
Replace Photo
Posted
3 minutes ago, JDallas23 said:

I want Autoit to fill the username, then delay X amount of time before it attempts to autofill the password. How would I do that?

Um, have you try to insert a Sleep (xxx) before Send ($TargetPassword) ?

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

  • Moderators
Posted

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (edited)

Hello @ViciousXUSMC and @Musashi - I added a 10 second delay before the password fills however it is still inputting the password incorrectly.

Incorrect Password:  W9->?n3VxV2Ynp   

Correct Password:    W9->?n3Xx+V2Ynp

I also tried adding this in to slow down the speed of which the password gets filled and that did not work--> Opt('SendKeyDelay', 400); default 5. higher number = slower

I noticed that for some reason it is not inputting the "+" character in the password. Any ideas why?

#AutoIt3Wrapper_UseX64=n
Opt("MustDeclareVars", 1)
AutoItSetOption("WinTitleMatchMode", 3) ; EXACT_MATCH!
AutoItSetOption("WinDetectHiddenText",1)

;============================================================
;             AutoIt Dispatcher Skeleton
;             ------------------------------
;
; Use this skeleton to create your own
; connection components integrated with the PSM.
; Areas you may want to modify are marked
; with the string "CHANGE_ME".
;
; Created : April 2013

;============================================================
#include "PSMGenericClientWrapper.au3"
#include "BlockInputEx.au3"
;=======================================
; Consts & Globals
;=======================================
Global Const $DISPATCHER_NAME                                    = "Bomgar Client" ; CHANGE_ME
Global Const $CLIENT_EXECUTABLE                                    = 'C:\Program Files\Bomgar\Bomgar Representative Console\help.enlink.com\bomgar-rep.exe' ; CHANGE_ME
Global Const $ERROR_MESSAGE_TITLE                                  = "PSM " & $DISPATCHER_NAME & " Dispatcher error message"
Global Const $LOG_MESSAGE_PREFIX                                 = $DISPATCHER_NAME & " Dispatcher - "

Global $TargetUsername
Global $TargetPassword
Global $TargetAddress
Global $TargetLogonDomain
Global $ConnectionClientPID = 0

;=======================================
; Code
;=======================================
Exit Main()

;=======================================
; Main
;=======================================
Func Main()
_BlockInputEx(1)
    ; Init PSM Dispatcher utils wrapper
    ToolTip ("Initializing...")
    if (PSMGenericClient_Init() <> $PSM_ERROR_SUCCESS) Then
        Error(PSMGenericClient_PSMGetLastErrorString())
    EndIf

    LogWrite("successfully initialized Dispatcher Utils Wrapper")

    ; Get the dispatcher parameters
    FetchSessionProperties()

    LogWrite("mapping local drives")
    if (PSMGenericClient_MapTSDrives() <> $PSM_ERROR_SUCCESS) Then
        Error(PSMGenericClient_PSMGetLastErrorString())
    EndIf

    LogWrite("starting client application")
    ToolTip ("Starting " & $DISPATCHER_NAME & "...")

    ; ------------------
    ; Handle login here! ; CHANGE_ME
    ; ------------------

    ; Execute RunAs command to run ssms under the PSM Shdaow User's profile, but pass the network credentials of
       ; the target (specified by the "2" logon type)
    $ConnectionClientPID = RunAs($TargetUsername,$TargetLogonDomain,$TargetPassword,2,$CLIENT_EXECUTABLE)

;Sleep (30)
WinWait("Bomgar - Representative Login","",30)
WinActivate ($ConnectionClientPID)

    Send ($TargetUsername)
    Send ("{TAB}")
    Sleep (10000)
    Send ($TargetPassword)
    Send ("{ENTER}")
     _BlockInputEx(0)
    if ($ConnectionClientPID == 0) Then
        Error(StringFormat("Failed to execute process [%s]", $CLIENT_EXECUTABLE, @error))
     EndIf

    ; Send PID to PSM as early as possible so recording/monitoring can begin
     LogWrite("sending PID to PSM")
     if (PSMGenericClient_SendPID($ConnectionClientPID) <> $PSM_ERROR_SUCCESS) Then
         Error(PSMGenericClient_PSMGetLastErrorString())
     EndIf

    ; Terminate PSM Dispatcher utils wrapper
    LogWrite("Terminating Dispatcher Utils Wrapper")
    PSMGenericClient_Term()

    Return $PSM_ERROR_SUCCESS
EndFunc

;==================================
; Functions
;==================================
; #FUNCTION# ====================================================================================================================
; Name...........: Error
; Description ...: An exception handler - displays an error message and terminates the dispatcher
; Parameters ....: $ErrorMessage - Error message to display
;                    $Code          - [Optional] Exit error code
; ===============================================================================================================================
Func Error($ErrorMessage, $Code = -1)

    ; If the dispatcher utils DLL was already initialized, write an error log message and terminate the wrapper
    if (PSMGenericClient_IsInitialized()) Then
        LogWrite($ErrorMessage, True)
        PSMGenericClient_Term()
    EndIf

    Local $MessageFlags = BitOr(0, 16, 262144) ; 0=OK button, 16=Stop-sign icon, 262144=MsgBox has top-most attribute set

    MsgBox($MessageFlags, $ERROR_MESSAGE_TITLE, $ErrorMessage)

    ; If the connection component was already invoked, terminate it
    if ($ConnectionClientPID <> 0) Then
        ProcessClose($ConnectionClientPID)
        $ConnectionClientPID = 0
    EndIf

    Exit $Code
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: LogWrite
; Description ...: Write a PSMWinSCPDispatcher log message to standard PSM log file
; Parameters ....: $sMessage - [IN] The message to write
;                  $LogLevel - [Optional] [IN] Defined if the message should be handled as an error message or as a trace messge
; Return values .: $PSM_ERROR_SUCCESS - Success, otherwise error - Use PSMGenericClient_PSMGetLastErrorString for details.
; ===============================================================================================================================
Func LogWrite($sMessage, $LogLevel = $LOG_LEVEL_TRACE)
    Return PSMGenericClient_LogWrite($LOG_MESSAGE_PREFIX & $sMessage, $LogLevel)
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: PSMGenericClient_GetSessionProperty
; Description ...: Fetches properties required for the session
; Parameters ....: None
; Return values .: None
; ===============================================================================================================================
Func FetchSessionProperties() ; CHANGE_ME
    if (PSMGenericClient_GetSessionProperty("Username", $TargetUsername) <> $PSM_ERROR_SUCCESS) Then
        Error(PSMGenericClient_PSMGetLastErrorString())
    EndIf

    if (PSMGenericClient_GetSessionProperty("Password", $TargetPassword) <> $PSM_ERROR_SUCCESS) Then
        Error(PSMGenericClient_PSMGetLastErrorString())
    EndIf

    ;if (PSMGenericClient_GetSessionProperty("Address", $TargetAddress) <> $PSM_ERROR_SUCCESS) Then
    ;    Error(PSMGenericClient_PSMGetLastErrorString())
    ;EndIf

    if (PSMGenericClient_GetSessionProperty("LogonDomain", $TargetLogonDomain) <> $PSM_ERROR_SUCCESS) Then        ;Added CWA
        Error(PSMGenericClient_PSMGetLastErrorString())
    EndIf

EndFunc

Edited by JDallas23
Forgot to add something else I added to the script for testing..
Posted (edited)
47 minutes ago, JDallas23 said:

I noticed that for some reason it is not inputting the "+" character in the password. Any ideas why?

see Help for Send  -->  '+' : this tells AutoIt to send a SHIFT keystroke

Use the flag :

SEND_RAW (1) = keys are sent raw
#include <AutoItConstants.au3>

Global $hWnd
Global $TargetUsername = "Testuser"
Global $TargetPassword = "W9->?n3Xx+V2Ynp"

Run("notepad.exe")
$hWnd = WinWait("[CLASS:Notepad]", "", 10)

Send ($TargetUsername)
Send ("{ENTER}")
Sleep (500)

Send ($TargetPassword)
Send ("{ENTER}")
Sleep (500)

Send ($TargetPassword, $SEND_RAW)
Send ("{ENTER}")

BTW : I hope, this is not a real password ;)

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted (edited)

Hey guys! I am running into an issue. For some users it is working and for others it is not. For the users it is not working properly I notice that AutoIt is putting the username in twice. My script only references Send ($TargetUsername) one time. Any ideas?

Send ($TargetUsername)
    Send ("{TAB}")
    Sleep (1000)

    Opt('SendKeyDelay', 80); default 5. higher number = slower

    Send ($TargetPassword, $SEND_RAW)
    Send ("{ENTER}")
    Sleep (500)

Capture.PNG

Edited by JDallas23
Added Code
Posted

Hello @Nine. What you just said helped! Thanks everyone for your input, it was a combination of two things that needed to be fixed - I had to send the password in raw, and also I had some users clicking the box to remember their username and password. For the wiiiin!

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...