This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Feature Updates
 Completed Requests
 [COMPLETE] Hide mouse cursor after X seconds
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

beholder

60 Posts

Posted - 08/12/2012 :  13:05:38  Show Profile
Hey bud, here is a cheap feature providing nice new functionality:
hide mouse cursor after pre-set time. Then re-appear mouse if it is moved.

Currently I am using an AHK script for this, here is a part of it:

OnExit, ShowCursor ; Ensure the cursor is made visible when the script exits. 

iHideMouseCursorAfter := 5 		; hide mouse after seconds
iReHideMouseWhenHidden := 1	; hide mouse cursor after this time (seconds) if some program makes it shown

SystemCursor(0)																	; hide mouse now, this is the default state
MouseGetPos, OrigX, OrigY
iHideMouseCursorAfter := iHideMouseCursorAfter * 2
iReHideMouseWhenHidden := iReHideMouseWhenHidden * 10
Loop {																						; main loop
	Sleep 100																			; checking for mouse move every 100 ms
	iCounter++
	if (iCounter == iReHideMouseWhenHidden)
	{
		iCounter := 0
		SystemCursor(0)															; re-hide mouse cursor, even if it's hidden
	}
	MouseGetPos, NewX, NewY
	if (NewX <> OrigX or NewY <> OrigY)								; if mouse moved
	{
		SystemCursor(1)															; show mouse cursor
		iGetOut  := 0
		while (iGetOut < iHideMouseCursorAfter)					; check if mouse was not moved for the above specified time
		{
			MouseGetPos, OrigX, OrigY
			Sleep 500																	;  timer ticking every 1/2 second
			MouseGetPos, NewX, NewY									
			if (NewX <> OrigX or NewY <> OrigY) 					; checking if mouse has moved while cursor being shown
			{
				iGetOut := 0															; reset timer if mouse moved
			} Else {
				iGetOut := iGetOut + 1
			}
		}
		SystemCursor(0)															; hide mouse cursor
		MouseGetPos, OrigX, OrigY										; save current mouse position
	}
}


I am not posting systemCursor() here since it just turns the cursor on and off depending on hte parameter.

It would be very nice if all this was possible to do in the mouse utility itself, not via external script. And I think it would benefit S+ tremendously.

Rob

USA
2615 Posts

Posted - 08/12/2012 :  23:03:00  Show Profile  Visit Rob's Homepage
The only issue I see with replicating this is that S+ executes an action then waits for another gesture...not monitor for events outside of an action sequence.

What is the use case for this, so I can better understand the reasoning behind your need for this fucntionality? Maybe that will help me come up with something. Is it like for watching a movie or something?
Go to Top of Page

beholder

60 Posts

Posted - 08/14/2012 :  21:03:59  Show Profile
Exactly, it's perfect for tube movies, flash games, apps like that. I know that for normal movies programs like BSplayer and such manage this cursor hiding by themselves. But it happened like billion times that the cursor was stuck in front of youtube mov when it was not in fullscreen. Or a flash game.

I had the cursor stuck in eye-view so many time that I took the time and nerve and found the AHK solution so it never bothers me again. And really: it was like a miracle. What was once a daily nuisance -- I never had since. NOT ONCE. That's how powerful this simple functionality is. (now I get the nerve on other computers which don't have the AHK script running )

But now it bothers me that I use a perfect mouse utility which manages many other things but doesn't have this simple setting. For example, your util manages "mouse wheel relay" -- GOD I'VE BEEN SEARCHING FOR THAT FOR SO LONG, I even made a custom AHK script to manage the relay because I was so used to it from Genius Netscroll+ mouse drivers, other mice didn't support this. Glad I don't have to use it anymore. Now I'd like to do the same thing with cursor hiding (= control it with more efficient software directly related to rodent issues).

But that's not the only reason why I have told you about this (I have this working fine with AHK, thank you very much). I told you because your software could gain a very nice "cheap" functionality which will again set it apart from other low-grade mouse utils. In theory, the more simple and easy features like this, the more will S+ fly.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 08/14/2012 :  21:12:44  Show Profile  Visit Rob's Homepage
I agree completely, it seems to fit in perfectly with the spirit of S+.

I will add it, but it may take a little while. Apparently, you can't simply turn the cursor off, you have to replace the standard arrow with a blank cursor, then reload the standard cursor when you want the cursor to be shown again. Meaning, it's not like a simple Windows API call to hide the cursor (it looked like it at first, but it's more complicated).

That's why I've left this open.
Go to Top of Page

beholder

60 Posts

Posted - 08/15/2012 :  08:46:29  Show Profile
Here is the hide/show routine AHK uses, not sure but maybe it helps. I don't understand it, I just copied it and hacked the logic that uses it:
SystemCursor(OnOff=1) ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
{
	static AndMask, XorMask, $, h_cursor
		,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
		, b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 ; blank cursors
		, h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13 ; handles of default cursors
	if (OnOff = "Init" or OnOff = "I" or $ = "") ; init when requested or at first call
	{
		$ = h ; active default cursors
		VarSetCapacity( h_cursor,4444, 1 )
		VarSetCapacity( AndMask, 32*4, 0xFF )
		VarSetCapacity( XorMask, 32*4, 0 )
		system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
		StringSplit c, system_cursors, `,
		Loop %c0%
		{
			h_cursor := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
			h%A_Index% := DllCall( "CopyImage", "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
			b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
				, "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
		}
	}
	if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
		$ = b ; use blank cursors
	else
		$ = h ; use the saved cursors

	Loop %c0%
		{
		h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
		DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
		}
}
Go to Top of Page

Rob

USA
2615 Posts

Posted - 08/16/2012 :  12:35:19  Show Profile  Visit Rob's Homepage
Added this functionality in 2.2.9

By the way, you can add the call to Global Lua so you don't have to make an action, since it sounds like you want this to happen all of the time.
acAutoHideMouseCursor(5000,1000) --or whatever timeouts you want
Go to Top of Page

beholder

60 Posts

Posted - 08/16/2012 :  20:35:42  Show Profile
Good call, it really works out-of-box in the 2.2.9 global Lua.
Perfect, another thing I can cross out off my AHK script.

T H A N K Y O U.
Go to Top of Page

beholder

60 Posts

Posted - 08/16/2012 :  20:43:23  Show Profile
AAH!! I forgot about this!
In my AHK script I have added a routine that ran on app exit of the autohotkey, to show the mouse cursor.

You also should do this when exiting S+ because I did hide the cursor and then exited S+ app which basically disappeared the cursor for good. It was funny to navigate XP start menu with a ghost cursor.

I am sorry I noticed this too late, when I deleted the mouse-hiding code from my AHK script.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 08/17/2012 :  01:00:43  Show Profile  Visit Rob's Homepage
I updated the code to handle that, will be included in 2.3.0 whenever that's released.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000