Jump to content
LordTakahiro

Less Choppy MouseWheel

Recommended Posts

LordTakahiro

Good Morning/Afternoon/Evening all,

 

I am currently working on a script to scroll down a smartsheets page for a client of mine, but they do not like how choppy MouseWheel down looks. Is there a way to make this look smoother? I was thinking I could do MouseDown("Middle"), but I do not have the coordinates of this page to move the mouse down to make this look smoother. Below is the code that I currently have working with MouseWheel.

 

#include <MsgBoxConstants.au3>

HotKeySet("{F4}", "exitProg")       ; Press F4 to exit the program
HotKeySet("{F5}", "startStop")      ; Press F5 to start and stop the program (Program is still running, stops the program after it's current scroll loop)
$on = True                          ; Variable for the startstop function
$numScroll = 10                     ; (Interchangeable) Variable for the amount of mouseWheel Down scrolls will happen in 1 loop
$sleepTimer = 1000                  ; (Interchangeable) Variable for the amount of miliseconds the program will wait between iterations (1000 = 1 second)

Func startStop()                    ; Start and stops the program
    If $On = False Then
        $On = True
    Else
        $On = False
    EndIf
EndFunc

Func exitProg()                     ; Exits the program
    Exit
EndFunc


Func scrollDown($param)             ; Scrolls down the current active window $param times

    For $i = $param To 1 Step -1
    MouseWheel("down", 1)
    sleep(1000)
    Next


EndFunc


Func windowActivate()               ; Activates the Google Chrome window and gives scroll down $numScroll param

    $handle = WinGetHandle("[CLASS:Chrome_WidgetWin_1]")
    If @error Then
    MsgBox(4096, "Error", "Could not find the correct window")
    Else
    WinActivate($handle)
    scrollDown($numScroll)
    EndIf

EndFunc


While 1                             ; Main function that while the code is on, run windowActivate then once thats done, sleep for $sleepTimer
    While $On = True
        windowActivate()
        sleep($sleepTimer)
    WEnd
WEnd

 

 

Share this post


Link to post
Share on other sites
BrewManNH

You have it pause 1 second between mouse scrolls, shorten that to see if it looks better to you.

You could also look through the post linked below for more ideas.

 

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
LordTakahiro

Yeah, I changed it to 100 and it does seem better. I'll work with it a bit more to see if they want it to be something they like. They kind of just want it to slowly scroll down their smartsheets page, so I can't have it go down too fast, but at 1 second it's too choppy for them. 

Share this post


Link to post
Share on other sites
LordTakahiro

I ended up adding/changing a few variables and changing how my scrollDown function works to this:

 

$scrollTimer = 5000                 ; (Interchangeable) Variable for the amount of miliseconds the program will scroll down the page
$sleepTimer = 1000                  ; (Interchangeable) Variable for the amount of miliseconds the program will wait between iterations (1000 = 1 second)
$offsetY = 30                       ; (Interchangeable) Variable for the offset of the Y value. Determines how quick the page will scroll (Has to be over 15)
$moveTimer = 10000                  ; (Interchangeable) Variable for the amount of miliseconds the program will wait for the user to move the mouse to the scrollbar

Func scrollDown($param)             ; Scrolls down the current active window for $param miliseconds

    sleep($moveTimer)
    $currPos = MouseGetPos()
    $newY = $currPos[1] + $offsetY
    MouseDown ( "middle" )
    sleep(1000)
    MouseMove($currPos[0],$newY,10)
    sleep($param)
    MouseUp ("middle")
    sleep(1000)
    MouseMove($currPos[0],$currPos[1],10)


EndFunc

 

Share this post


Link to post
Share on other sites

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

×