thalesduarte wrote: ↑22 Apr 2022, 12:58
Dont work, returns blank text box
1. You clear page:="" in your F1 hotkey so you lose the session there already, that is never going to work
2. I don't think you can get the value of a input
before you've submitted it - at least not that I know, if the page has loaded, the value of the keywords input is empty of course. (Not saying it can't be done, but I simply don't know how)
Try this script, it starts chromium and shows a message box, but enter some keywords in the ahk search box first and hit enter to search - THEN press OK, now the msgbox should show they keywords you have entered. For me it does anyway.
Code: Select all
#SingleInstance, force
#Include %A_ScriptDir%\lib
#Include Rufaydium.ahk
ChromeDriver := A_ScriptDir "\chromedriver.exe"
url:="https://www.autohotkey.com/boards/"
; choose different driver in order to automate different Browser
Driver := new RunDriver(ChromeDriver) ; running driver
Chrome := new Rufaydium(Driver) ; this will return control over Browser
; choosing Browser Capabilities, by using Capabilities you can make custom profile for specific need
Chrome.capabilities := Capabilities.ChromeDefault
; this is how we create session
Page := Chrome.NewSession()
Page.Navigate(url)
GS := Chrome.getSessionByUrl(url)
MsgBox, Enter keywords, start search, wait for results, press OK
Element := GS.getElementsbyXpath("//*[@id=""keywords""]")
msgbox, % element[1].value
GS:=""
Page := ""
Chrome.QuitAllSessions()
driver.exit()
ExitApp
Alternative method would be to copy it to the clipboard
Code: Select all
element:=GS.getElementbyID("keywords")
Element.SendKey(key.ctrl "a")
Element.SendKey(key.ctrl "c")
Sleep 100
MsgBox % clipboard