Blaarkies / freeways-helping-hand

Autohotkey script to draw Bezier Curves (quad/cubic)
MIT License
9 stars 0 forks source link

Line overlay doesn't show up properly with DPI Scaling enabled / System error beeps when drawing lines #1

Open drewjc75 opened 2 years ago

drewjc75 commented 2 years ago

I have a 4k monitor with 150% display scaling enabled and because of this, the line overlays draw in the wrong place on the screen. I was able to remedy this by adding the -DPIScale flag to line 20 of static-gui.ahk.

Also, it looks like the window is losing focus and that causes the system to beep whenever the script attempts to start drawing a line. It doesn't seem to actually affect any functionality, but I was at least able to get the system to (mostly) stop yelling at me by adding a WinActivate, Freeways in the drawPath() and drawCheckpointLabels() functions of static-gui.ahk, after the call to lineShow(). It doesn't seem to work all the time, but it does seem to take care of it most of the time. There may be a better way to handle this, but as a band-aid solution, it seems to at least partially work.

I'm not necessarily expecting you to fix these—I just figured I'd mention it in case anybody else looks in the issues for this project.

Blaarkies commented 2 years ago

This is awesome feedback, thanks for taking the time to post it 😄

I haven't been able to test it on anything above 1080p, or with any scaling setup, im glad there seems to be an easy fix for this.

The window losing focus was due to an issue where the mouse click would get captured by this transparent window overlay (or only when the mouse moves onto the dots in the line?), it became difficult to debug and get to the root cause of this, so I found that hiding that window just before the automated drawing starts helps to mitigate it. That might be giving this problem now 🤔

I hope the sound beeps aren't too obnoxious, they are meant as a little bit of feedback to the user. Im also really glad you could piece together what the code was doing, i haven't documented/commented in the code nearly enough.

I don't have any concrete plans on updating this yet, so if you want to make a pull request for this i would be more than happy to review it and merge it in if all is fine.

I have been tinkering around with hotkeys and simulated mouse/keyboard inputs in Python, and it seems to be able to handle the same things. I have been thinking of making a Python version of this that handles entire roads by building splines, instead of just drawing a single curve at a time. Imagine setting up this blueprint that shows the whole road-network-plan for the current map, and being able to edit the curve-nodes wherever it seems a bit off, and then calling the draw function which physically draws all roads according to the blueprint. Then if you notice something wrong with a tiny patch of road, you just edit that spline without redoing everything else. I want to make the spline logic modular though, maybe other games could also use that one day.

drewjc75 commented 2 years ago

I hope the sound beeps aren't too obnoxious, they are meant as a little bit of feedback to the user. Im also really glad you could piece together what the code was doing, i haven't documented/commented in the code nearly enough.

I should point out that the sounds I'm referring to are NOT the SoundBeep commands, but the Windows "Asterisk" sound effect, which signifies to me that something is attempting to act on a window it doesn't have access to (for example, the mouse attempting to click on the transparent overlay window, perhaps). It could also be that it might not be hiding the transparent window fast enough, and perhaps a Sleep command just prior to drawing with the mouse might take care of it. I'll experiment a little bit to see if either activating the Freeways window prior to clicking the mouse or adding a Sleep command prior to drawing might work better. If I figure something out, I'll submit a pull request for you. 👍