JDallas23 Posted March 16, 2020 Posted March 16, 2020 (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 Edited March 27, 2020 by JDallas23 Replace Photo
Musashi Posted March 16, 2020 Posted March 16, 2020 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) ? "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 Melba23 Posted March 17, 2020 Moderators Posted March 17, 2020 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
ViciousXUSMC Posted March 17, 2020 Posted March 17, 2020 ControlSend() instead of Send, also I think you can open bomgar directly with parameters. As far what your asking its super simple just add a sleep() between your sends.
JDallas23 Posted March 23, 2020 Author Posted March 23, 2020 (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 March 23, 2020 by JDallas23 Forgot to add something else I added to the script for testing..
Nine Posted March 23, 2020 Posted March 23, 2020 When posting code use this tool. If you can edit your last post, please do so. Otherwise, maybe a mod could do it for your. JDallas23 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Musashi Posted March 23, 2020 Posted March 23, 2020 (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 March 23, 2020 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
JDallas23 Posted March 23, 2020 Author Posted March 23, 2020 Thanks @Musashi! I think $SEND_RAW is what I needed. Seems to be working thus far, will find out soon enough.
JDallas23 Posted March 27, 2020 Author Posted March 27, 2020 (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) Edited March 27, 2020 by JDallas23 Added Code
Nine Posted March 27, 2020 Posted March 27, 2020 Probably because the Username is already there ??? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
JDallas23 Posted March 27, 2020 Author Posted March 27, 2020 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now