AutoHotkey Community

It is currently May 27th, 2012, 6:42 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: August 2nd, 2011, 4:49 pm 
Offline
User avatar

Joined: June 22nd, 2011, 4:02 pm
Posts: 171
I have been using this code to generate middle mouse button clicks on my Windows XP SP3 laptop for almost a year and it has always worked flawlessly.
Code:
#NoEnv
#NoTrayIcon

SendMode Input
SetWorkingDir %A_ScriptDir%

RButton & LButton::SendMouse_MiddleClick()
$RButton::Send {RButton}

SendMouse_MiddleClick()
    {
    DllCall("mouse_event", "UInt", 0x20) ; middle button down
    DllCall("mouse_event", "UInt", 0x40) ; middle button up
    }
When I try this on Windows 7 Pro, however, it will completely lock up the system. Sometimes the Right Click context menu will pop up and when I dismiss it the left mouse button is stuck down. Other times the system will stop responding to mouse events altogether.

I've searched the manual, the forums, google and msdn with no luck. I can think of some possible reasons, but no solutions:
    Microsoft changed the mouse event
    This an issue with AutoHotkey_L (latest version)
    The DLL calls above have some bug that only affects Windows 7
:? Can anyone can point me in right direction to get this to work on Windows 7?

TIA


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2011, 4:53 pm 
Offline

Joined: October 19th, 2007, 8:30 pm
Posts: 136
Location: PA
Is UAC turned on? If so, turning it off would be a step to try if you can.

I just made a post asking how to get around Send commands not working when UAC is turned ON because I need it to be on.

It bugged me for an hour or two before I figured out the UAC was silently blocking keystrokes.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2011, 6:29 pm 
Offline

Joined: June 7th, 2010, 3:40 pm
Posts: 553
The MSDN on mouse_event says it was replaced by sendinput: http://msdn.microsoft.com/en-us/library/ms646310.aspx

Maybe check that out?

_________________
(Statistics script) M&K Counter 2.0
My FAST ini Lib
Minecraft NBT Lib


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2011, 6:52 pm 
Offline
User avatar

Joined: June 22nd, 2011, 4:02 pm
Posts: 171
Firewolf91 wrote:
Is UAC turned on? If so, turning it off would be a step to try if you can.

Thank you!! Turning off UAC solves the problem.

UAC is probably why some of my other scripts don't work on Windows 7.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2011, 3:32 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Why aren't you using the Click command? It uses mouse_event (or SendInput) internally...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2011, 4:30 am 
Offline
User avatar

Joined: June 22nd, 2011, 4:02 pm
Posts: 171
Lexikos wrote:
Why aren't you using the Click command?

I have another script that uses the middle mouse button as a hotkey, but that hotkey won't fire if I use something like
Code:
RButton & LButton::Click Middle
$RButton::Send {RButton}

because to quote the manual:
Manual wrote:
Hotkeys that use the keyboard hook cannot be triggered by means of the Send command. Similarly, mouse hotkeys cannot be triggered by commands such as Click because all mouse hotkeys use the mouse hook.

Using the DLL calls side-steps this restriction, allowing the originally posted code to fire the mouse button hotkey in the other script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2011, 6:33 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Clever. In that case, you should take care to pass all of the required parameters for safe and predictable results.
Code:
VOID WINAPI mouse_event(
  __in  DWORD dwFlags,
  __in  DWORD dx,
  __in  DWORD dy,
  __in  DWORD dwData,
  __in  ULONG_PTR dwExtraInfo
);
http://msdn.microsoft.com/en-us/library/ms646260


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 4th, 2011, 2:56 am 
Just tried this script with AHK 1.0.48.05,
did NOT lock up my system, but doesn't reliably pass middle clicks when 'clicking' on windows 7 taskbar program 'thumbnails' (to close them).

I'm reading up on WINAPI SendInput now


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: batto, Bing [Bot], JSLover and 64 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group