¿Cómo se agrega un efecto visual a un clic del mouse desde Windows?


22

Solo quiero una pequeña utilidad que monitoree los clics del mouse para que cuando ocurra un efecto de burbuja visual (o algo similar), similar a algo que pueda ver en un screencast.

Respuestas:


21

Opción nativa de Windows

Propiedades del mouse> Opciones de puntero> Mostrar ubicación del puntero

Combinado con AutoHotkey

~LButton::
Send {Ctrl}
return

~LButton UP::
Send {Ctrl}
return

Cada clic del mouse (arriba y abajo) se dispara Ctrlbrevemente.

Como señaló Paolo, incluso puede cambiar la configuración del mouse como parte del script:

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
He arreglado la sugerencia aquí (y gracias por ponerme en AutoHotKey). Me llevó horas descubrir la solución. Agregué un solo carácter (la tilde ~) que permitía el funcionamiento normal del mouse. También modifiqué el ejemplo para que no solo se libere el clic del mouse, sino que el clic inicial del mouse genere el efecto.

1
Es posible cambiar automáticamente la configuración del mouse. Ver este enlace: autohotkey.com/board/topic/…
Paolo Fulgoni

El cambio que hice fue eliminar ~ LButton y usar solo ~ LButton Up, porque tener ambos crea un efecto de sonda desarticulado, pero usar solo el clic hacia arriba lo hace perfecto.
Juicio

1

Esta es una variante de la respuesta de RJFalconer, que incorpora cambios de Paolo Fulgoni. No quería ver siempre mi mouse cuando se presionaba el botón CTRL, y esperaba que la DllInfomodificación activara y desactivara dinámicamente la configuración, pero no pude hacer que funcionara (el script simplemente saldría). Sin duda, alguien más sofisticado en AHK podría explicar lo que estaba haciendo mal, pero seguí adelante y creé mi propia versión.

Cambia dinámicamente la opción "Mostrar mouse cuando se presiona el control" ON cuando se presiona el botón del mouse, y luego se apaga después. Funciona bien en pruebas limitadas, aunque a veces el puntero del mouse desaparece posteriormente. Si alguien sabe cómo solucionarlo, o tiene otras mejoras, siéntase libre de participar.

Está (excesivamente) documentado, porque rápidamente olvido las cosas, y cuando necesito volver a visitar, me gusta que mis scripts brinden suficiente información que no necesito buscar para encontrar todas las referencias antiguas que usé en primer lugar.

;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
}

Fue útil gracias. También agregué una #SingleInstance forcelínea para evitar molestos mensajes emergentes durante los clics dobles.
Phil B
Al usar nuestro sitio, usted reconoce que ha leído y comprende nuestra Política de Cookies y Política de Privacidad.
Licensed under cc by-sa 3.0 with attribution required.