Jump to content

MouseOnEvent UDF!


MrCreatoR
 Share

Recommended Posts

MCreatoR, Thank you very much!

I confirm that it fixed.

 

Your UDF very useful for me. It saved me money for buy a new mouse.
At first I could not imagine that will solve this problem in my mouse with a script.
This is a good example of why Autoit and it's unique community so useful

Link to comment
Share on other sites

Update:

 
 
 
Unfortunately, there is a new problem.
After a while, the function does not work anymore and it does not block the
double click and I have to restart the script.

Please fix it
Link to comment
Share on other sites

Update:

 
 
 
Unfortunately, there is a new problem.
After a while, the function does not work anymore and it does not block the
double click and I have to restart the script.

Please fix it

This happens with my script as well?

#include <GUIConstantsEx.au3>
#include "MouseOnEvent.au3"

HotKeySet("{ESC}", "_Quit")

$a__MSOE_DblClk_Data[0] = 200
_MouseSetOnEvent($MOUSE_PRIMARYDBLCLK_EVENT, "_MousePrimaryDblClk_Event")

While Sleep(10)
WEnd

Func _MousePrimaryDblClk_Event()
    Return 1
EndFunc

Func _Quit()
    Exit
EndFunc

 

have you updated the UDF or just made the changes as i posted?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

This happens with my script as well?

#include <GUIConstantsEx.au3>
#include "MouseOnEvent.au3"

HotKeySet("{ESC}", "_Quit")

$a__MSOE_DblClk_Data[0] = 200
_MouseSetOnEvent($MOUSE_PRIMARYDBLCLK_EVENT, "_MousePrimaryDblClk_Event")

While Sleep(10)
WEnd

Func _MousePrimaryDblClk_Event()
    Return 1
EndFunc

Func _Quit()
    Exit
EndFunc

 

have you updated the UDF or just made the changes as i posted?

 

"This happens with my script as well?"
I tested the new UDF with this code only

 

"have you updated the UDF or just made the changes as i posted?"
I downloaded the new UDF. I didn't manually changed  it

Link to comment
Share on other sites

I need a reproducing steps, i don't get the same results.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

As I feared, I was wrong. I did not use exactly your code.
I changed the Sleep(10) to Sleep(10000)
Do you think it matters? Anyway, I'll try it with Sleep(10) and update you about the problem

 

Update:
Again - same problem.
But I think that with Sleep(10) it takes more time until the function stop working. I am not sure..
It took about 30 mins or more until it stop working.
 Probably a lot more time then before. Again - I am not sure.

 

You have to play with it and run the function for a long time until it happens

 

EDIT: I think I was wrong. It still works. I just did slow double click and not fast one.
 

EDIT 2:
The problem  occurred again after a long time use

Edited by Guest
Link to comment
Share on other sites

  • 2 months later...

Hi, i'm having problems unsetting the event on primary down.

Basically even though i've tested that the unset code is begin run and my clicks are enabled again i'm finding the primary down event firing every so often(I have a tooltip to show me this). I'm certain the script is not running the code to set the event again too.

Any ideas?

Link to comment
Share on other sites

On 27.01.2016 at 4:48 PM, Bizzaro said:

Any ideas?

I need to see the code.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 2 weeks later...

I've been using a special mouse function to paste a value into an external GUI.

_MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT, "MouseSECONDARYUP_Event", 0, 1)

Upon a secondary click, the function performs Send["^v"].  That part works fine.

The problem is that the right mouse click gets through to the other application and calls up a right-click edit menu.

I was under the impression that $iBlockDefProc = 1 would prevent the other GUI from seeing the click action.  Have I missed something?  (BTW, I've tried processing both the UP and DOWN actions and get the same result.)

Thanks in advance for any advice.

 

Link to comment
Share on other sites

On 10.02.2016 at 11:24 PM, qwert said:

I've been using a special mouse function to paste a value into an external GUI.

_MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT, "MouseSECONDARYUP_Event", 0, 1)

Upon a secondary click, the function performs Send["^v"].  That part works fine.

The problem is that the right mouse click gets through to the other application and calls up a right-click edit menu.

I was under the impression that $iBlockDefProc = 1 would prevent the other GUI from seeing the click action.  Have I missed something?  (BTW, I've tried processing both the UP and DOWN actions and get the same result.)

Thanks in advance for any advice.

 

Perhaps the application calls the menu after mouse down, not up.

Try to block the 

$MOUSE_SECONDARYDOWN_EVENT

event as well.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 4 weeks later...
  • 3 weeks later...
On 29.10.2015 at 11:01 PM, MrCreatoR said:

What about this example:

#include <GUIConstantsEx.au3>
#include "MouseOnEvent.au3"

HotKeySet("{ESC}", "_Quit")

$a__MSOE_DblClk_Data[0] = 200
_MouseSetOnEvent($MOUSE_PRIMARYDBLCLK_EVENT, "_MousePrimaryDblClk_Event")

While Sleep(10)
WEnd

Func _MousePrimaryDblClk_Event()
    Return 1
EndFunc

Func _Quit()
    Exit
EndFunc

?

MRCreatoR, I tried this with the lasted version. after few minutes it stops working. the CPU problem solved in this version but it just stop working (stop blocking the 200ms double click)

 

I really need it to work ..  Please fix this bug.

Thank you.

Link to comment
Share on other sites

  • Developers
18 minutes ago, gil900 said:

I really need it to work ..  Please fix this bug.

What about you debug it yourself and propose the fix to the UDF? ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

1 hour ago, Jos said:

What about you debug it yourself and propose the fix to the UDF? ;)

Jos

I contribute to the community by sharing other UDFs  and at the moment I do not have time to debug it.. and for me it will take nore time to fix it then the developer of this UDF

Link to comment
Share on other sites

  • 2 months later...

Hello folks!

Of all the AutoIt mouse control functions here in the forum, it seems to me that MouseOnEvent UDF is the most popular, and regularly mentioned in other threads concerning this subject, so I guess this is the right place to ask.

I would like to know if it's possible to assign the Win key + Mouse wheel (Up or Down) to a function, while blocking Win key to not trigger Start menu, and blocking mouse wheel to not do its normal scroll functions.

I'm actually have this scenario working fairly well, but unfortunately using that other "competitor" scripting language, so I've got a weird feeling that I'm dealing with the devil... :evil:

Thanks in advance,

RegiOween

Link to comment
Share on other sites

  • 6 months later...
  • 2 weeks later...
On 12/10/2016 at 3:28 PM, flibustier said:

any ideas how to use mouse x3, x4, etc buttons? or please, explane how to read mouse buttons key codes

flibustier, take a look at _IsPressed function, the X1 mouse button has the code 05, and the X2 mouse button has the code 06, but I don't know about the extra X buttons, since they're not standard.

Link to comment
Share on other sites

2 hours ago, flibustier said:

yep, i checked sources about x1, x2, but x3 x4 are really problem and i dont know any software to read key code when the key is pressed

I got a Logitech G600 mouse with 20 programmable buttons (http://gaming.logitech.com/en-us/product/g600-mmo-gaming-mouse), then what I do is remap the buttons to key combinations (like Win+F1, Win+F2, whatever) so AutoIt can recognize them.
If your mouse has some driver software, probably you can try this alternative as well.

Link to comment
Share on other sites

x64 issue

I was playing with this UDF a couple of weeks ago. It turned out that it didn't work as 64 bit code. I gave it up and created my own mouse click handler.

In the meantime, I've skimmed through most posts. There are several posts on the x64 issue but no solutions. And I've played a little more especially with "DoubleClick Monitor.au3"

If you debug the code you'll see that the issue is caused by the __MouseSetOnEvent_DoubleClickExpire callback function. This function is registered with DllCallbackRegister in _Timer_SetTimer. The problem arises because the handle returned by DllCallbackRegister is released with DllCallbackFree in _Timer_KillTimer while __MouseSetOnEvent_DoubleClickExpire is still running.

This is obviously not a problem when the code is run as 32 bit code, but it's a problem when the code is run as 64 bit code.

The best solution is to redesign the UDF a little bit to avoid that the handle of a callback function is released while the callback function is still running.

But you can use an easy workaround. Add this code to the bottom of MouseOnEvent.au3:

; #FUNCTION# ====================================================================================================================
; Author ........: Gary Frost
; Modified.......: Squirrely1
; ===============================================================================================================================
Func _Timer_KillTimerEx($hWnd, $iTimerID)
  Static $hCallBackPrev = 0
  Local $aResult[1] = [0], $hCallBack = 0, $iUBound = UBound($__g_aTimers_aTimerIDs) - 1
  For $x = 1 To $iUBound
    If $__g_aTimers_aTimerIDs[$x][0] = $iTimerID Then
      If IsHWnd($hWnd) Then
        $aResult = DllCall("user32.dll", "bool", "KillTimer", "hwnd", $hWnd, "uint_ptr", $__g_aTimers_aTimerIDs[$x][1])
      Else
        $aResult = DllCall("user32.dll", "bool", "KillTimer", "hwnd", $hWnd, "uint_ptr", $__g_aTimers_aTimerIDs[$x][0])
      EndIf
      If @error Or $aResult[0] = 0 Then Return SetError(@error, @extended, False)
      $hCallBack = $__g_aTimers_aTimerIDs[$x][2]
      ;If $hCallBack <> 0 Then DllCallbackFree($hCallBack) ; This line is causing the error
      If $hCallBackPrev <> 0 Then
        DllCallbackFree($hCallBackPrev)
        $hCallBackPrev = 0
      EndIf
      If $hCallBack <> 0 Then $hCallBackPrev = $hCallBack
      For $i = $x To $iUBound - 1
        $__g_aTimers_aTimerIDs[$i][0] = $__g_aTimers_aTimerIDs[$i + 1][0]
        $__g_aTimers_aTimerIDs[$i][1] = $__g_aTimers_aTimerIDs[$i + 1][1]
        $__g_aTimers_aTimerIDs[$i][2] = $__g_aTimers_aTimerIDs[$i + 1][2]
      Next
      ReDim $__g_aTimers_aTimerIDs[UBound($__g_aTimers_aTimerIDs - 1)][3]
      $__g_aTimers_aTimerIDs[0][0] -= 1
      ExitLoop
    EndIf
  Next
  Return $aResult[0] <> 0
EndFunc

And replace all occurrences of "_Timer_KillTimer(" with "_Timer_KillTimerEx(".

In _Timer_KillTimerEx release of the handle is postponed until _Timer_KillTimerEx runs the next time. At this time the instance of __MouseSetOnEvent_DoubleClickExpire which belongs to the handle has finished running.

Link to comment
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
 Share

×
×
  • Create New...