web-dev-qa-db-ja.com

ウィンドウ内からのマウスクリックに視覚効果をどのように追加しますか?

マウスクリックを監視する小さなユーティリティが欲しいので、スクリーンキャストで見られるような、視覚的なバブル効果(またはそれに類似したもの)が発生したときに発生します。

22
Jon Erickson

ネイティブWindowsオプション

Mouse Properties > Pointer Options > Show Location of Pointer

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
22
RJFalconer

これは、Paolo Fulgoniからの変更を組み込んだRJFalconerの回答の変形です。 CTRLボタンが押されたときに常にマウスが表示されるようにしたくなかったので、DllInfoの変更によって設定が動的にオンとオフに切り替わることを望みましたが、それを機能させることができませんでした(スクリプトは終了するだけです)。間違いなく、AHKのより洗練された誰かが私が間違っていたことを説明できるかもしれませんが、私は先に進んで独自のバージョンを作成しました。

マウスボタンが押されると、[コントロールが押されたときにマウスを表示する]オプションを動的にオンに切り替え、その後オフに切り替えます。限られたテストでは問題なく動作しますが、マウスポインターが離れて消えることもあります。誰かがそれを修正する方法を知っている場合、または他の改善がある場合は、気軽に参加してください。

それは(過度に)文書化されています。私はすぐに物事を忘れてしまったので、再訪する必要があるときは、最初に使用したすべての古い参照を見つけるために検索する必要がない十分な情報をスクリプトに提供したいのです。

;Visualize mouse clicks by showing radiating concentric circles on mouse click
;Author: traycerb
;Date/Version: 01-31-2018
;
;Source:
;https://superuser.com/questions/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
}
1
traycerb