You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GDAX自动下单金额输入未被识别,如何用VBA手动触发IE DOM事件

Fixing GDAX Auto-Order Input Recognition in VBA (IE)

Hey there, I’ve dealt with similar DOM event headaches when automating IE with VBA, so let’s get your GDAX auto-order working properly. The core issue here is that modern sites like GDAX don’t just rely on input field values—they use JavaScript events to sync UI elements like that "Total (LTC)" field. Manually setting the input’s value won’t trigger those events, which is why the site doesn’t recognize your automated input. Here’s how to fix it:

Step 1: Locate the Amount Input Element

First, you need to correctly target the amount input field. Use IE’s Developer Tools (F12) to find the element’s ID, class name, or selector. For example, if the input has an ID like amount:

Dim IE As Object
Dim amountInput As Object
Set IE = CreateObject("InternetExplorer.Application")

' Navigate to your GDAX order page and wait for load
IE.Visible = True
IE.Navigate "https://pro.coinbase.com/trade/LTC-USD" ' Replace with your specific order URL
Do While IE.Busy Or IE.ReadyState <> 4
    DoEvents
Loop

' Target the input element (update the selector to match your actual field)
Set amountInput = IE.Document.getElementById("amount")

Step 2: Set the Value + Trigger Critical Events

Simply setting amountInput.Value won’t cut it—you need to manually fire the events the site listens for. Most trading platforms rely on input, change, or keyup events. Test these combinations:

Option 1: Use FireEvent (Older IE Versions)

This works for IE 10 and earlier:

' Set your desired order amount
amountInput.Value = "0.75"

' Trigger events to sync the UI
amountInput.FireEvent "oninput"
amountInput.FireEvent "onchange"
' Optional: Add keyup if the site relies on keystroke detection
amountInput.FireEvent "onkeyup"

Option 2: Use dispatchEvent (IE 11+)

If FireEvent doesn’t work (common in newer IE builds), create and dispatch proper event objects:

amountInput.Value = "0.75"

' Create and dispatch an "input" event
Dim inputEvent As Object
Set inputEvent = IE.Document.createEvent("HTMLEvents")
inputEvent.initEvent "input", True, False
amountInput.dispatchEvent inputEvent

' Create and dispatch a "change" event to confirm the input
Dim changeEvent As Object
Set changeEvent = IE.Document.createEvent("HTMLEvents")
changeEvent.initEvent "change", True, False
amountInput.dispatchEvent changeEvent

Step 3: Confirm Which Events GDAX Uses

To know exactly which events to trigger:

  1. Open IE Developer Tools (F12)
  2. Go to the "Elements" tab and select the amount input field
  3. Switch to the "Events" tab to see all registered listeners (look for input, change, or blur—these are the most likely culprits)

Bonus: Wait for Element Readiness

Ensure the input field is fully loaded before interacting with it:

Do While amountInput Is Nothing
    On Error Resume Next
    Set amountInput = IE.Document.getElementById("amount")
    On Error GoTo 0
    DoEvents
Loop

This should force GDAX to recognize your automated input and update the Total (LTC) field just like when you type manually.

内容的提问来源于stack exchange,提问作者Nils

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:31:16