Jump to content

Recommended Posts

Posted (edited)

I'm trying to use ControlSetText in AutoIt to input text into the "Name" and "Fuzzy Name" fields on this web page:
👉 https://www.trade.gov/data-visualization/csl-search

However, it doesn't seem to work. I suspect it's because the page uses modern web technologies (JavaScript-based elements), and maybe ControlSetText can't interact with them properly.

I tried inspecting the elements and using their IDs, but I'm still stuck. I'm very new to this, so I'd really appreciate any help or guidance. Here's the code I'm working with:

<input type="text" class="explorer__form__input" id="name" name="name" value="">
<input type="text" class="explorer__form__input" id="name" name="name" value="">
#include <AutoItConstants.au3>
; Open the browser and navigate to the URL
Run("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe https://www.trade.gov/data-visualization/csl-search")
WinWaitActive("CSL Search") ; Wait for the window title

Sleep(5000)

; Try to set the text in the "Name" field
ControlSetText("CSL Search", "CSL Search - International Trade Administration", "name", "Kromlüks")

Sleep(500)

 

Edited by mustilem23
Posted

The above method is the correct one
However, there is also the beginner's method. :)
 

;~ Opt("SendKeyDelay", 100) ; Slow motion

; Open the browser and navigate to the URL
Run("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe https://www.trade.gov/data-visualization/csl-search")

Local $hWnd = WinWaitActive("CSL Search", "", 5) ; Wait Max 5 sec for the window title

If $hWnd Then
    Send("{TAB 19}") ; go to the name field
    Send("Kromlüks") ; set the name

    Send("{TAB 5}") ; go to the search button
    Send("{ENTER}") ; execute the search
Else
    ConsoleWrite("I can't find the 'CSL Search' window." & @CRLF)
EndIf

 

I know that I know nothing

  • Moderators
Posted

Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


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)
On 4/22/2025 at 3:57 PM, ioa747 said:

Yukarıdaki yöntem doğru olanıdır
Ancak, başlangıç yöntemi de vardır.
:)
 

;~ Opt("SendKeyDelay", 100) ; Slow motion

; Open the browser and navigate to the URL
Run("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe https://www.trade.gov/data-visualization/csl-search")

Local $hWnd = WinWaitActive("CSL Search", "", 5) ; Wait Max 5 sec for the window title

If $hWnd Then
    Send("{TAB 19}") ; go to the name field
    Send("Kromlüks") ; set the name

    Send("{TAB 5}") ; go to the search button
    Send("{ENTER}") ; execute the search
Else
    ConsoleWrite("I can't find the 'CSL Search' window." & @CRLF)
EndIf

 

Thank you very much for your support. I was actually using a similar scenario myself, but in a video I saw that it’s possible to interact with websites using element IDs, which is why I’ve started researching this approach.

I don't have much coding knowledge, but as you can see, my current scenario isn’t very complex. I plan to improve and develop it further later on.

Edited by mustilem23
Posted
29 minutes ago, mustilem23 said:

in a video I saw that it’s possible to interact with websites using element IDs

it may be an old video ? It may not apply to 2025 :(

29 minutes ago, mustilem23 said:

don't have much coding knowledge, but as you can see, my current scenario isn’t very complex.

yes, and you'll need to use what @nine told you.

31 minutes ago, mustilem23 said:

I plan to improve and develop it further later on.

..later on today, this week, as an entry in a bucket list ? :D

I'd personally do what @ioa747 told you ( in code ) and add send Ctrl-A to select all, then Ctrl-C to copy to clipboard the text.
Because I never used the WebDriver and this copy and paste is easier to a new coder ( you ). Admittedly the WebDriver is the better approach if you know what you're doing.

And seeing what you did on the other thread you show to be very inexperienced, hence this commentary to you.

Ok, good luck and have fun :) 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)

Here to start you up.  This is meant to show you that it is not complicated to accomplish what you want :

#include "wd_helper.au3"

Local $sDesiredCapabilities = SetupChrome()
_WD_Startup()
Local $sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, "https://www.trade.gov/data-visualization/csl-search")
_WD_FrameEnter($sSession, 0)
Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='name']")
ConsoleWrite($sElement & @CRLF)
_WD_ElementAction($sSession, $sElement, 'value', "Test")

;_WD_DeleteSession($sSession)
_WD_Shutdown()

Func SetupChrome()
  _WD_Option('Driver', 'chromedriver.exe')
  _WD_Option('Port', 9515)
  _WD_Option('DriverParams', '--port=9515 --verbose --log-path="' & @ScriptDir & '\chrome.log"')
  Return '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"]}}}}'
EndFunc   ;==>SetupChrome

 

Edited by Nine
Posted
43 minutes ago, Nine said:

This is meant to show you that it is not complicated to accomplish what you want

As long as @mustilem23 knows all the dependencies of the au3WebDriver (WebDriver) project 🤭 . But yes, you're right (like so often), it's not that complicated as long as the documentation is read and understood. At least for the start.

Best regards
Sven

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

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