Jump to content
Sign in to follow this  
Griff

detecting mouse clicks?

Recommended Posts

Hey all, I've been trying for a couple of days now to make a script that changes the whole screen into a volume slider, I've finally managed it using the scripts below, but its sluggish and relies on 2 other previously installed programs. I use strokeit (can be found here) to activate the first script when you press both buttons down, and then to activate the second script when one of these buttons is released. Unfortunately this doesn't always work, I was wondering if there is any way to use autoit to recognise pressing both mouse buttons and recognise releasing them as well.

Anyway, just of you're interested the code I use is this

$i = 0
Opt("WinTitleMatchMode", 3)
$last = 101
E:\volume

if winexists ("stickvol") then
   winkill ("stickvol")
endif
if winexists ("changevol") then
    winkill ("changevol")
endif   

AutoItWinSetTitle ( "changevol" )


while $i = 0
    $pos = mousegetpos ()   
    $value = int(100-$pos[1]/@desktopheight*100)
    if $value <> $last then
        runwait ("E:\volume\setvol.exe " & $value)
        splashimageon ("slider", "E:\volume\redbox.bmp", 15, 5, @desktopwidth-15, $pos[1], 1)
    else 
        sleep (200)
    endif
    $last = $value
Wend

and the second script is

$i = 0
Opt("WinTitleMatchMode", 3)

if winexists ("stickvol") then
    winkill ("stickvol")
endif
if winexists ("changevol") then
    winkill ("changevol")
endif
$pos = mousegetpos ()

autoitwinsettitle ("stickvol")
splashimageon ("slider", "E:\volume\redbox.bmp", 15, 5, @desktopwidth-15, $pos[1], 1)


while $i = 0
    if winexists ("changevol") then
        winkill ("changevol")
        $pos = mousegetpos ()
        splashimageon ("slider", "E:\volume\redbox.bmp", 15, 5, @desktopwidth-15, $pos[1], 1)
    endif
    sleep (3000)
Wend

I should probably mention, redbox.bmp is what it implies, a red box. and setvol.exe is a program i found that sets the volume to a percentage of the maximum (can be found here)

As an aside, does anybody know if its possible to change the volume in windows myself easily as well without using setvol.exe but changing the registry or something?

Thanks very much, and can I just add that I love autoit, I only found it last week, but have already made at least a dozen scripts for various things.

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...