Jump to content

Show location with CTRL Key


Recommended Posts

Control Panel - Mouse - Pointer Options - Show location of the pointer when i press the CTRL Key

I don't want to enable that function with CTRL, i want simulate it with autoit withot using the "autoit internal function" but the real windows "circle effect"

I think is a DLLCall or similar like the window effect-fade but i don't have found any information about that on the web, someone has any idea?

EDIT: I think is releated to SystemParametersInfo

It's called SPI_SETMOUSESONAR ( Sonar? Really? :D ) but it only enable-disable, instead i want to "send" that function without click the CTRL

Thanks

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

Here a workaround:

;coded by UEZ build 2014-04-11
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

_GDIPlus_Startup()

Global Const $iW = 128, $iH = 128, $fCenter = $iW / 2, $iPenSize = 2, $iBGColor = 0xABCDEF
Global Const $hGUI = GUICreate("", $iW, $iH, -1, -1, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED, $WS_EX_APPWINDOW))
GUISetBkColor($iBGColor, $hGUI)
GUISetState(@SW_HIDE, $hGUI)
_WinAPI_SetLayeredWindowAttributes($hGUI, $iBGColor)
Global $tGDIp = DllStructCreate("ptr Graphics;ptr Bitmap;ptr Context;ptr Pen")
$tGDIp.Graphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$tGDIp.Bitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $tGDIp.Graphics)
$tGDIp.Context = _GDIPlus_ImageGetGraphicsContext($tGDIp.Bitmap)
_GDIPlus_GraphicsSetSmoothingMode($tGDIp.Context, 2)
$tGDIp.Pen = _GDIPlus_PenCreate(0xFF000000, $iPenSize)

Global Const $hDll = DllOpen("ntdll.dll"), $iMicroSeconds = 1500
Global $tStruct = DllStructCreate("int64 time;")

HotKeySet("{F9}", "ShowLocation")
HotKeySet("+{Esc}", "_Exit") ;shift + ESC terminates the script

GUISetState(@SW_SHOW, $hGUI)

Do
Until Not Sleep(1000000)

Func _Exit()
    _GDIPlus_GraphicsDispose($tGDIp.Context)
    _GDIPlus_GraphicsDispose($tGDIp.Graphics)
    _GDIPlus_BitmapDispose($tGDIp.Bitmap)
    _GDIPlus_PenDispose($tGDIp.Pen)
    GUIDelete()
    _GDIPlus_Shutdown()
    DllClose($hDll)
    Exit
EndFunc   ;==>_Exit

Func ShowLocation()
    Local $i
    Local Static $bRunning = False
    If Not $bRunning Then
        $bRunning = True
        WinMove($hGUI, "", MouseGetPos(0) - $fCenter, MouseGetPos(1) - $fCenter)
        For $i = 0 To ($iW - $iPenSize) / 2
            _GDIPlus_GraphicsClear($tGDIp.Context, 0xE0000000 + $iBGColor)
            _GDIPlus_GraphicsDrawEllipse($tGDIp.Context, $i, $i, ($iW - $iPenSize) - 2 * $i, ($iW - $iPenSize) - 2 * $i, $tGDIp.Pen)
            _GDIPlus_GraphicsDrawImageRect($tGDIp.Graphics, $tGDIp.Bitmap, 0, 0, $iW, $iH)
            $tStruct.time = -1 * ($iMicroSeconds * 10)
            DllCall($hDll, "dword", "ZwDelayExecution", "int", 0, "struct*", $tStruct)
        Next
        _GDIPlus_GraphicsClear($tGDIp.Graphics, 0xFF000000 + $iBGColor)
        $bRunning = False
    EndIf
EndFunc   ;==>ShowLocation
Press F9 to show cursor position, Shift+Esc to terminate script.

 

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thanks UEZ for the workaround but i can't try it, give me an error:

Variable must be of type "Object"
$tGDIp.Graphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$tGDIp^ ERROR

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

 

Thanks UEZ for the workaround but i can't try it, give me an error:

Variable must be of type "Object"
$tGDIp.Graphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$tGDIp^ ERROR

 

Never seen a "." being used in the declaration of a variable name in autoit. Remove all of them and it should work.

Edited by MotionFlex
Link to comment
Share on other sites

This is a try of a new style of coding. Use latest AutoIt version to get it run properly!


Br,
UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • Developers

Never seen a "." being used in the declaration of a variable name in autoit. Remove all of them and it should work.

The script posted by UEZ works fine for me, so you not having seen it doesn't mean it is wrong. ;)

run this example:

Global $Demo = DllStructCreate("char var1[50];int var2")
$Demo.var1 = "abc"
$Demo.var2 = 123
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Demo.var1 = ' & $Demo.var1 & @CRLF) ;### Debug Console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : DllStructGetData($Demo,"var1") = ' & DllStructGetData($Demo,"var1") & @CRLF) ;### Debug Console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Demo.var2 = ' & $Demo.var2 & @CRLF) ;### Debug Console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : DllStructGetData($Demo,"var2") = ' & DllStructGetData($Demo,"var2") & @CRLF) ;### Debug Console

@Terenz: What version of AutoIt3 are you running with?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...