Skip to content

lod114d: Control.click sleeps before, between and after the button events - #92

Closed
ResurrectedTrader wants to merge 1 commit into
mainfrom
control-click-timing
Closed

ResurrectedTrader wants to merge 1 commit into
mainfrom
control-click-timing

Conversation

@ResurrectedTrader

Copy link
Copy Markdown
Owner

d2bs: clickControl (reference/d2bs/Control.cpp) does Sleep(100), button down, Sleep(100), button up, Sleep(100) - about 300 ms per click. control.click() and the click steps of login / createGame / joinGame all go through it.

d2bsng before: Control::Click posted button down, slept 100 ms, posted button up and returned at once. A script that looks up the next control right after a click (kolbot Locations.js clicks the TCP/IP button and then looks up and clicks the Host / Join button straight after) could still see the old screen.

Fix: Control::Click sleeps 100 ms before, between and after the two events, as d2bs does. The sleeps run without any game lock held (the click position is resolved in an inner scope first, and the binding already calls Click on a copy of the handle after its lock is dropped).

createGame, joinGame and createCharacter ran some of their clicks inside GameThread::Execute, which would have put the new sleeps on the game thread and stalled frames. Those clicks now run on the calling thread, as login's already do; Control::Find and Click take their own read lock. Only the edit-box text is still set on the game thread.

Restores: scripts that call getControl right after control.click() see the screen the click opened. createGame also waits about 400 ms after clicking the Create tab before it checks that the tab opened, as d2bs does, instead of 200 ms.

Not live-tested. Built Win32 Release, build.ps1 test passes, check-format clean.

🤖 Generated with Claude Code

…ents

Reference clickControl (reference/d2bs/Control.cpp) sleeps 100 ms before
the button-down, between down and up, and after the button-up, so a click
takes about 300 ms and the script's next getControl sees the screen the
click led to. Control::Click only slept between the two events and
returned right after the button-up.

Click now sleeps at all three points. The createGame / joinGame /
createCharacter clicks ran inside GameThread::Execute, which would put
those sleeps on the game thread; they now run on the calling thread as
login's already do (Control::Find and Click take their own read lock),
and only the edit-box text is still set on the game thread.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ResurrectedTrader

Copy link
Copy Markdown
Owner Author

This works fine, so lets skip.

@ResurrectedTrader
ResurrectedTrader deleted the control-click-timing branch October 8, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant