Hi all!
I have a problem with sending combination of control and key. Script always send only key without ctrl effect in any application.
I tried
#include "wd_core.au3"
#include "wd_helper.au3"
#include <Excel.au3>
HotKeySet("{ESC}","Quit")
Local $sDesiredCapabilities, $sSession
SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
; Login
_WD_Navigate($sSession, "https://accounts.google.com/signup/v2/webcreateaccount?continue=https%3A%2F%2Fwww.google.com%2F&hl=vi&dsh=S-553103207%3A1653362446062875&biz=false&flowName=GlifWebSignIn&flowEntry=SignUp")
Local Const $ExcelFile = @ScriptDir & "\_Excel1.xls"
$oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Error starting", "@error = " & @error)
$oWorkbook = _Excel_BookOpen($oExcel, $ExcelFile)
$bOpenWorkBook = True
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Error opening workbook","@error = " & @error)
$lastrow = $oExcel.ActiveSheet.UsedRange.Rows.Count
Local $browser = WinWait("[TITLE:Google - Google Chrome]", "", 10)
Local $excel= WinWait("[CLASS:XLMAIN]", "", 10)
For $iRow = 2 To $lastrow step + 1
;===========Copy Column A
WinActivate($excel)
Sleep(500)
$sCell = _Excel_RangeRead($oWorkbook, Default, "A" & $iRow) ;~ Workbook was opened so read cell A2
Sleep(500)
WinActivate($browser)
Sleep(500)
_ChromeSetInputValueByElement($sSession, 'id' ,'lastName', Send("^a"))
Sleep(500)
_ChromeSetInputValueByElement($sSession, 'id' ,'lastName', $sCell )
;===========Copy Column B
WinActivate($excel)
Sleep(500)
$sCell = _Excel_RangeRead($oWorkbook, Default, "B" & $iRow) ;~ Workbook was opened so read cell A2
Sleep(500)
WinActivate($browser)
Sleep(500)
_ChromeSetInputValueByElement($sSession, 'id' ,'firstName', Send("^a"))
Sleep(500)
_ChromeSetInputValueByElement($sSession, 'id' ,'firstName', $sCell )
;===========Copy Column C
WinActivate($excel)
Sleep(500)
$sCell = _Excel_RangeRead($oWorkbook, Default, "C" & $iRow) ;~ Workbook was opened so read cell A2
Sleep(500)
WinActivate($browser)
Sleep(500)
_ChromeSetInputValueByElement($sSession, 'id' ,'username', Send("^a"))
Sleep(500)
_ChromeSetInputValueByElement($sSession, 'id' ,'username', $sCell )
Next
Func SetupChrome()
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
;_WD_Option("DefaultTimeout", 1000)
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--disable-infobars"]}}}}'
EndFunc
;_WD_DeleteSession($sSession)
;_WD_Shutdown()
Func _ChromeSetInputValueByElement($sSession, $Elm, $Id, $Value)
$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@" & $Elm & "='" & $Id & "']")
_WD_ElementAction($sSession, $sButton, 'value', $Value)
EndFunc ;==>_ChromeSetInputValueById
Func _WD_ElementValue($sKey, $Value)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sKey)
_WD_ElementAction($sSession, $sElement, 'value', $Value)
EndFunc ;==>_WD_ElementValue
Func _WD_ElementClick($sKey)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sKey)
_WD_ElementAction($sSession, $sElement, 'click')
EndFunc
Func Quit()
Exit
EndFunc
but pasting in the input, the result is pasting the number 1 and the copied text.
Ex: Copy abcde, Paste: 1abcde
Please help me :((