Hi guys,
Been using AHK for the last few weeks and loving it. Slowly automating my life.
I am currently trying to write a script that clicks somewhere on the screen, and then scrolls down an exact amount. The problem I am having is 'Click Wheeldown 1' is too much. I need it to be an exact amount, somewhere around 0.7, but I haven't been able to use decimals and can't find the proper solution online.
Furthermore, what would be the best way to measure that exact amount? Do a mouse coordinate measure between two, or is there something better you'd suggest? Essentially scrolling down a long list of usernames and doing actions on each, but the cursor has to land exactly in the middle of each username, consistently.
Thank you in advance, really appreciate your help.
How to mouse wheeldown less than 1 unit
Re: How to mouse wheeldown less than 1 unit
I'm not sure if that's possible personally, however another solution may be to just move the mouse based on the difference.
So if you scroll down and the mouse is say 20 pixels off, just do MouseMove,0,-20,,R Moves the mouse up 20 pixels.
You will of course have to do a bit of tweaking to get the right number.
So if you scroll down and the mouse is say 20 pixels off, just do MouseMove,0,-20,,R Moves the mouse up 20 pixels.
You will of course have to do a bit of tweaking to get the right number.
Some of my AHK programs: 3D Voxel Game - Platformer Game
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
Re: How to mouse wheeldown less than 1 unit
If you use AHK's window spy, what is the control under the cursor, when you hover over the scrollbar (it may be blank)?
Btw can you not use the arrow keys (or send arrow key presses) to line up the item to be under the cursor.
Basically I would consider sending messages to a ScrollBar or Edit control, or using the Acc library, to try to interact with the scrollbar.
Btw can you not use the arrow keys (or send arrow key presses) to line up the item to be under the cursor.
Basically I would consider sending messages to a ScrollBar or Edit control, or using the Acc library, to try to interact with the scrollbar.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: How to mouse wheeldown less than 1 unit
I'd been curious to know about how WheelUp/WheelDown is done, I checked the AHK source code and it appears that WM_MOUSEWHEEL is used. I'm not sure if this gives the granularity of control that you're looking for, however, when I used values of 1/-1, the scroll moved incredibly slowly.
Btw I searched the cpp files for 'WheelDown', and subsequently for 'VK_WHEEL_DOWN'. The source code is available here:
GitHub - Lexikos/AutoHotkey_L: AutoHotkey - macro-creation and automation-oriented scripting utility for Windows.
https://github.com/Lexikos/AutoHotkey_L
Btw I searched the cpp files for 'WheelDown', and subsequently for 'VK_WHEEL_DOWN'. The source code is available here:
GitHub - Lexikos/AutoHotkey_L: AutoHotkey - macro-creation and automation-oriented scripting utility for Windows.
https://github.com/Lexikos/AutoHotkey_L
Code: Select all
q:: ;test - WheelUp/WheelDown
w:: ;test - WheelUp/WheelDown
MouseGetPos, vPosX, vPosY, hWnd, hCtl, 2
if hCtl
hWnd := hCtl
vNum := 1
if InStr(A_ThisHotkey, "w")
vNum *= -1 ;negative means downwards
PostMessage, 0x20A, % vNum<<16, % vPosX|(vPosY<<16),, % "ahk_id " hWnd ;WM_MOUSEWHEEL := 0x20A
return
;e::SendInput {WheelUp}
;r::SendInput {WheelDown}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: How to mouse wheeldown less than 1 unit
I was wondering how you guys find something very well.jeeswg wrote:I'd been curious to know about how...
Now I see some of it (I've nerver thouched its source code, because I do not know C++).
Good job.
Re: How to mouse wheeldown less than 1 unit
Indeed nice one jeeswg, I might use it . But I need to come up with some convenient hotkey, ironically, I'm not a big fan of hotkeys
Added primitive acceleration and using timers,
Added primitive acceleration and using timers,
Code: Select all
wUp:=func("scroll").bind(1)
wDown:=func("scroll").bind(-1)
q::SetTimer, % wUp, 5
q up::
SetTimer, % wUp, off
scroll(0,true)
return
w::SetTimer, % wDown, 5
w up::
SetTimer, % wDown, off
scroll(0,true)
return
esc::exitapp
scroll(dir:=1,cls:=false){
static pdir:=0, ptic:=0, acc:=1
if cls
return pdir:=0, ptic:=0, acc:=1
MouseGetPos, vPosX, vPosY, hWnd, hCtl, 2
if hCtl
hWnd := hCtl
if (pdir!=dir)
ptic:=A_TickCount,acc:=1
pdir:=dir
if (A_TickCount-ptic>300/acc)
acc++,ptic:=A_TickCount
vNum := 1*dir*acc
PostMessage, 0x20A, % vNum<<16, % vPosX|(vPosY<<16),, % "ahk_id " hWnd ;WM_MOUSEWHEEL := 0x20A
return
}
Who is online
Users browsing this forum: DataLife, ewerybody, mcd, ShatterCoder and 171 guests