Sign in to follow this  
Followers 0
YellowLab

Primary/Secondary Mouse Buttons Spontaneously Swapping

3 posts in this topic

I have a GUI that I am using OnEventMode for. I have a GUISetOnEvent($GUI_EVENT_SECONDARYDOWN) for the main GUI and an event for certain elements in the gui set to the primary click, GUICtrlSetOnEvent...

Basically, the secondary click will rotate an image 45 deg clockwise with the primary click rotating the image 45 deg counterclockwise or moving the control. After some period of time, sometimes five minutes, sometimes more (probably after a certain sequence of events occurs), the primary and secondary mouse buttons swap. If I right click on the the task bar, they are corrected.

Has anyone ever experienced or seen this happen? I know that it is not good manners to ask for help without posting code, but it is nearly 4000 lines long and I don't have the foggiest idea where this is coming from.

Here are my GUISetOnEvent and GUICtrlSetOnEvent functions for starters:

CODE

Func _SpecialEvents()

Switch @GUI_CtrlId

Case $GUI_EVENT_SECONDARYDOWN ;right click

Local $arTemp = GUIGetCursorInfo($hMain)

If _ArraySearch($arControls,$arTemp[4])>=0 Then

;rotate CW

_RotatePiece(_ArraySearch($arControls,$arTemp[4]),$MY_CW)

ElseIf _ArraySearch($arText,$arTemp[4])>=0 Then

;Edit Text

_EditText($arTemp[4])

EndIf

EndSwitch

EndFunc ;==>_SpecialEvents

Func _LeftClick()

Local $nCID=@GUI_CtrlId, $arTemp

$arTemp=MouseGetPos()

Sleep($arSettings[$MY_SETTINGS_LCSENSITIVITY][1])

Local $Temp=GUIGetCursorInfo($hMain) ;after sleep - if the left button is still down, then piece is moving

If $Temp[2]=1 Then

If $arSettings[$MY_SETTINGS_MOVE][1]='All' And $arControls[_ArraySearch($arControls,$nCID)][$MY_CONTROL_HOME]=0 Then

_MoveAll($arTemp)

Else

_MoveControl($nCID, $arTemp) ;send CtrlID and original mouse position

EndIf

Else

;rotate CCW

_RotatePiece(_ArraySearch($arControls,$nCID),$MY_CCW)

EndIf

EndFunc ;==>_LeftClick

I recently found MrCreator's MouseSetOnEvent UDF (http://www.autoitscript.com/forum/index.php?showtopic=64738) and wonder if this may solve the issue...

Any help is greatly appreciated.

Thank you,

Bob


You can't see a rainbow without first experiencing the rain.

Share this post


Link to post
Share on other sites



It would appear the Event Mode may not be the best for handling this situation. I may spend some time rewriting the code to take that out; Mr. Creator's MouseSetOnEvent UDF does prevent the problem by blocking input from the opposite mouse button that was initially clicked. However, it causes a noticeable lag in the "movement" of the control.

My feeling is that if an event isn't fully completed and several mouse clicks get queued that something somewhere gets confused. Don't know how, I just know that it happens and this prevents it:

CODE

Func _LeftClick()

Local $nCID=@GUI_CtrlId, $arTemp

$arTemp=MouseGetPos()

_MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT, "__Dummy")

Sleep($arSettings[$MY_SETTINGS_LCSENSITIVITY][1])

Local $Temp=GUIGetCursorInfo($hMain) ;after sleep - if the left button is still down, then piece is moving

If $Temp[2]=1 Then

If $arSettings[$MY_SETTINGS_MOVE][1]='All' And $arControls[_ArraySearch($arControls,$nCID)][$MY_CONTROL_HOME]=0 Then

_MoveAll($arTemp)

Else

_MoveControl($nCID, $arTemp) ;send CtrlID and original mouse position

EndIf

Else

;rotate CCW

_RotatePiece(_ArraySearch($arControls,$nCID),$MY_CCW)

EndIf

_MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT)

EndFunc ;==>_LeftClick

Func _SpecialEvents()

Switch @GUI_CtrlId

Case $GUI_EVENT_SECONDARYDOWN ;right click

Local $arTemp = GUIGetCursorInfo($hMain)

If _ArraySearch($arControls,$arTemp[4])>=0 Then

;rotate CW

_MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "__Dummy")

_RotatePiece(_ArraySearch($arControls,$arTemp[4]),$MY_CW)

_MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "")

ElseIf _ArraySearch($arText,$arTemp[4])>=0 Then

;Edit Text

_EditText($arTemp[4])

EndIf

EndSwitch

EndFunc ;==>_SpecialEvents

By not using EventMode, I don't believe events queue up in a similar manner.

Bob


You can't see a rainbow without first experiencing the rain.

Share this post


Link to post
Share on other sites

One more update:

The functions didn't fully work in stopping the button swap. This is befuddling.

I switched out of OnEventMode for my script (it didn't take as long to convert as I thought) and everything works great.

If anyone has any ideas on the OnEventMode script, I would be willing to try it out.

Bob


You can't see a rainbow without first experiencing the rain.

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