Sign in to follow this  
Followers 0
Exit

[solved] disable/enable mouse

13 posts in this topic

#1 ·  Posted (edited)

My optical USB mouse sometimes refuses to work . Plug out / plug in the USB connector heals the problem.

Since my PC is located below the desk, it takes some sportive moments to do health care. :sweating:

I looked for a better solution and found that invoking system control panel for mouse and then deact/act the driver did the job.

So I've written a small script to do it for me:

;;~ reset mouse (does NOT work)
ShellExecute("main.cpl",",4")
WinWaitActive("[class:#32770]","",3)
Sleep(1000)
ControlClick("[class:#32770]","","Button2")
Sleep(1000)
ControlSend("[active]","", "","^{TAB}")
Sleep(1000)
ControlClick("[active]","","Button4")
Sleep(1000)
ControlSend("[active]","", "","{TAB}")
Sleep(5000) ; to check that selction before ENTER
ControlSend("[active]","", "","{ENTER}")
MsgBox(Default, Default, "Just try it yourself now ",3)

The dialog shows the same panels as the 'by hand' method.

But the click on the 'deactivate' and 'confirn' buttons have no effect. Strange. :x

How to disable and enable the mouse driver by a script ?

Edited by Exit

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

if the use of a little "external" utility is allowed then maybe you could use DevCon as explained here

.....else forget this post

Edited by Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

I don't know if you've already tried, but sometimes automatisation requires admin rights. Try #RequireAdmin

Share this post


Link to post
Share on other sites

if the use of a little "external" utility is allowed then maybe you could use DevCon as explained here

.....else forget this post

I tried DevCon.exe already with no success.

But nevertheless, thanks for your effort.

I don't know if you've already tried, but sometimes automatisation requires admin rights. Try #RequireAdmin

#RequireAdmin was also unrewarding. Again, thanks for your effort.

@ALL: Did you tried my code on your PC ? Same findings ?


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

ofaq1z.jpg


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

ofaq1z.jpg

Can you give me please the download link of your devcon_x64.exe.

Or send it via PM.

Thanks

Here the log on my PC:

post-45639-0-49478700-1400503350_thumb.j

 

Edited by Exit

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

If you have a x64 system you can't use the x86 version, it will not work. PM sent, the official way is to download the entire Windows Developer Kit for a couple of KB

Oh, and don't forget to run CMD as administrator

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

If you have a x64 system you can't use the x86 version, it will not work. PM sent, the official way is to download the entire Windows Developer Kit for a couple of KB

Oh, and don't forget to run CMD as administrator

Many thanks. Your PM'ed version works like a charm.

In the meantime I already downloaded and installed WDK.

I'll browse it and probably discard it soon.

But there is a question left: Why does my script does not work ? Any thoughts?


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

I might see your problem :) There are tons of [class:#32770] running on a windows machine. It's a common class, you need something unique. Try to replace it with the actual title. I think it should work.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I might see your problem :) There are tons of [class:#32770] running on a windows machine. It's a common class, you need something unique. Try to replace it with the actual title. I think it should work.

As you can see from the screenshot, it is no problem with [class:#32770]

post-45639-0-20918700-1400517683_thumb.j

Did you run the script?

Edited by Exit

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

This script now makes the job:

;~ reset mouse
RunWait('"' & @ComSpec & '" /c ' &@UserProfileDir& '\Data\Software\DevCon\devcon\devcon_x64\devcon.exe disable *mouse*', '', @SW_HIDE)
RunWait('"' & @ComSpec & '" /c ' &@UserProfileDir& '\Data\Software\DevCon\devcon\devcon_x64\devcon.exe enable *mouse*', '', @SW_HIDE)

But the script from first post refuses to do the job. Strange !


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

Probably because you ran your script in x86 mode. Try with x64.

Bingo ..... The x64 version did the trick. :thumbsup:


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

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  
Followers 0