如何在Windows中为鼠标单击添加视觉效果?


Answers:


21

本机Windows选项

鼠标属性>指针选项>显示指针的位置

AutoHotkey结合

~LButton::
Send {Ctrl}
return

~LButton UP::
Send {Ctrl}
return

每次单击鼠标(向下和向上)都会Ctrl短暂触发。

正如Paolo指出的那样,您甚至可以在脚本中更改“鼠标”设置:

DllCall("SystemParametersInfo", UInt, 0x101D, UInt, 0, UInt, 1, UInt, 0) ;SPI_SETMOUSESONAR ON

OnExit, ExitSub
ExitSub:
   DllCall("SystemParametersInfo", UInt, 0x101D, UInt, 0, UInt, 0, UInt, 0) ;SPI_SETMOUSESONAR OFF
   ExitApp

1
我已经在这里修正了建议(并感谢您将我放在AutoHotKey上)。我花了几个小时才找出解决办法。我添加了一个字符(tilde ~),使鼠标的正常操作能够通过。我还修改了示例,以便不仅释放鼠标单击,而且最初的鼠标单击都能产生效果。

1
可以自动更改鼠标设置。请参阅此链接:autohotkey.com/board/topic/...
保罗Fulgoni

我所做的更改是删除〜LButton并仅使用〜LButton Up,因为两者都会产生脱节的声纳效果,但是仅使用up click使其完美工作。
Trialsman

1

这是RJFalconer回答的一种变体,其中包含Paolo Fulgoni所做的更改。我不想总是在按下CTRL按钮时看到鼠标,我希望DllInfo修改能够动态地打开和关闭设置,但是我无法使它起作用(脚本将退出)。毫无疑问,AHK中比较老练的人可以解释我做错了什么,但是我继续创建了自己的版本。

当按下鼠标按钮时,它将动态地将“按下控件时显示鼠标”选项打开,然后再将其关闭。在有限的测试中,它可以正常工作,尽管有时鼠标指针会消失。如果有人知道如何修复或有任何其他改进,请随时加入。

它被(过多地)记录在案,因为我很快就忘记了事情,并且当我需要重新访问时,我希望脚本提供足够的信息,而我不需要搜索就可以找到我最初使用的所有旧引用。

;Visualize mouse clicks by showing radiating concentric circles on mouse click
;Author: traycerb
;Date/Version: 01-31-2018
;
;Source:
;/superuser/106815/how-do-you-add-a-visual-effect-to-a-mouse-click-from-within-windows
;https://autohotkey.com/board/topic/77380-mouse-click-special-effects-for-presentationsdemos/

;Dynamically switch on the Windows accessibility feature to show the mouse when the control key is pressed
;when the script is executed, then switch off afterwards
;Windows settings > Mouse > Pointer Options tab > Visibility group > Show location of pointer when I press CTRL key



;Window's SystemParametersInfo function, retrieves or sets the value of one of the 
;system-wide parameters.  AHK DllCall fxn with SystemParameterInfo parameter is used to access
;this Windows API.
;https://msdn.microsoft.com/en-us/library/windows/desktop/ms724947(v=vs.85).aspx
;BOOL WINAPI SystemParametersInfo(
;  _In_    UINT  uiAction,
;  _In_    UINT  uiParam,
;  _Inout_ PVOID pvParam,
;  _In_    UINT  fWinIni
;);

;uiParam [in]
;Type: UINT
;
;A parameter whose usage and format depends on the system parameter being queried or set. 
;For more information about system-wide parameters, see the uiAction parameter. 
;If not otherwise indicated, you must specify zero for this parameter.

;pvParam [in, out]
;Type: PVOID
;
;A parameter whose usage and format depends on the system parameter being queried or set. 
;For more information about system-wide parameters, see the uiAction parameter. 
;If not otherwise indicated, you must specify NULL for this parameter. 
;For information on the PVOID datatype, see Windows Data Types.

;fWinIni [in]
;Type: UINT
;
;If a system parameter is being set, specifies whether the user profile is to be updated, 
;and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level 
;windows to notify them of the change.

;This parameter can be zero if you do not want to update the user profile 
;or broadcast the WM_SETTINGCHANGE message or it can be set to the following [...]

;Accessibility parameter    
;S0x101D PI_SETMOUSESONAR
;Turns the Sonar accessibility feature on or off. This feature briefly 
;shows several concentric circles around the mouse pointer when the user 
;presses and releases the CTRL key. 
;The pvParam parameter specifies TRUE for on and FALSE for off. 

;Press the control button each time mouse button is pressed, showing location of mouse pointer.
~LButton::
{
  DllCall("user32\SystemParametersInfo", UInt, 0x101D, UInt, 0, UInt, 1, UInt, 0) 
  Send {Ctrl}
  DllCall("user32\SystemParametersInfo", UInt, 0x101D, UInt, 0, UInt, 0, UInt, 0) 
  return
}

~RButton::
{
  DllCall("user32\SystemParametersInfo", UInt, 0x101D, UInt, 0, UInt, 1, UInt, 0) 
  Send {Ctrl}
  DllCall("user32\SystemParametersInfo", UInt, 0x101D, UInt, 0, UInt, 0, UInt, 0) 
  return
}

非常有用,谢谢。我还添加了#SingleInstance force行,以避免在双击过程中出现烦人的弹出消息。
Phil B
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.