1

I looked up on the net for AHK scripts to get ripple effect around my mouse pointer when I clicked. But it stops working sometimes, like it doesn't work on overlay windows or in the start. Though not much of a problem, but I really want to know, is it something to do with the code ? :

#NoEnv
CoordMode Mouse, Screen
Setup()

~LButton::
    if(A_PriorHotkey = "~LButton" && A_TimeSincePriorHotkey < 1000){
        RippleVisible := False
        ShowRipple(0xff0000)
    } else {
        ShowRipple(LeftClickRippleColor)
    }
return
~RButton::ShowRipple(RightClickRippleColor)
~LControl Up::ShowRipple(MouseIdleRippleColor)

Setup()
{
    Global
    RippleWinSize := 50
    RippleStep := 2
    RippleMinSize := 5
    RippleMaxSize := RippleWinSize - 20
    RippleAlphaMax := 0xff
    RippleAlphaStep := RippleAlphaMax // ((RippleMaxSize - RippleMinSize) / (RippleStep*1.0))
    RippleVisible := False
    LeftClickRippleColor := 0xff0000
    RightClickRippleColor := 0x0000ff
    MouseIdleRippleColor := 0x008000

    DllCall("LoadLibrary", Str, "gdiplus.dll")
    VarSetCapacity(buf, 16, 0)
    NumPut(1, buf)
    DllCall("gdiplus\GdiplusStartup", UIntP, pToken, UInt, &buf, UInt, 0)

    Gui Ripple: -Caption +LastFound +AlwaysOnTop +ToolWindow +Owner +E0x80000
    Gui Ripple: Show, NA, RippleWin
    hRippleWin := WinExist("RippleWin")
    hRippleDC := DllCall("GetDC", UInt, 0)
    VarSetCapacity(buf, 40, 0)
    NumPut(40, buf, 0)
    NumPut(RippleWinSize, buf, 4)
    NumPut(RippleWinSize, buf, 8)
    NumPut(1, buf, 12, "ushort")
    NumPut(32, buf, 14, "ushort")
    NumPut(0, buf, 16)
    hRippleBmp := DllCall("CreateDIBSection", UInt, hRippleDC, UInt, &buf, UInt, 0, UIntP, ppvBits, UInt, 0, UInt, 0)
    DllCall("ReleaseDC", UInt, 0, UInt, hRippleDC)
    hRippleDC := DllCall("CreateCompatibleDC", UInt, 0)
    DllCall("SelectObject", UInt, hRippleDC, UInt, hRippleBmp)
    DllCall("gdiplus\GdipCreateFromHDC", UInt, hRippleDC, UIntP, pRippleGraphics)
    DllCall("gdiplus\GdipSetSmoothingMode", UInt, pRippleGraphics, Int, 4)

    MouseGetPos _lastX, _lastY
    SetTimer MouseIdleTimer, 5000
    Return

MouseIdleTimer:
    MouseGetPos _x, _y
    if (_x == _lastX and _y == _lastY)
        ShowRipple(MouseIdleRippleColor, _interval:=40)
    else
        _lastX := _x, _lastY := _y
    Return
}

ShowRipple(_color, _interval:=20)
{
    Global
    if (RippleVisible)
        Return
    RippleColor := _color
    RippleDiameter := RippleMinSize
    RippleAlpha := RippleAlphaMax
    RippleVisible := True

    MouseGetPos _pointerX, _pointerY
    SetTimer RippleTimer, % _interval
    Return

RippleTimer:
    DllCall("gdiplus\GdipGraphicsClear", UInt, pRippleGraphics, Int, 0)
    if ((RippleDiameter += RippleStep) < RippleMaxSize) {
        DllCall("gdiplus\GdipCreatePen1", Int, ((RippleAlpha -= RippleAlphaStep) << 24) | RippleColor, float, 3, Int, 2, UIntP, pRipplePen)
        DllCall("gdiplus\GdipDrawEllipse", UInt, pRippleGraphics, UInt, pRipplePen, float, 1, float, 1, float, RippleDiameter - 1, float, RippleDiameter - 1)
        DllCall("gdiplus\GdipDeletePen", UInt, pRipplePen)
    }
    else {
        RippleVisible := False
        SetTimer RippleTimer, Off
    }

    VarSetCapacity(buf, 8)
    NumPut(_pointerX - RippleDiameter // 2, buf, 0)
    NumPut(_pointerY - RippleDiameter // 2, buf, 4)
    DllCall("UpdateLayeredWindow", UInt, hRippleWin, UInt, 0, UInt, &buf, Int64p, (RippleDiameter + 5) | (RippleDiameter + 5) << 32, UInt, hRippleDC, Int64p, 0, UInt, 0, UIntP, 0x1FF0000, UInt, 2)
    Return
}

Also here's this recoil reducer code :

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

; iloveesl
NRA := 1

; SS
^!p::Suspend

; NR
~LButton::
while GetKeyState("LButton") & NRA
{
DllCall("mouse_event", uint, 1, int, 0, int, 3, uint, 0, int, 0)
Sleep, 15
DllCall("mouse_event", uint, 1, int, 0, int, 4, uint, 0, int, 0)
Sleep, 5
}
return

; Nades
~MButton::
if GetKeyState("LButton")
{
NRA := 0
Sleep, 3000
MouseClick, Left,,,,, U
NRA := 1
}
return

Insert::ExitApp

The above code is not working where its intended to work. Any corrections? Suggestions?

  • 1
    Maybe because of issue with ShellExperienceHost. – user3419297 May 20 at 20:02
  • @user3419297's suggestion looks promising as the correct explanation, but I suggest you also try running the script as Administrator to see if that makes any difference – Joakim May 21 at 7:54
  • @Joakim I tried running the scripts as Administrator and even tried troubleshoot compatibilty, but to no avail. – crrSeeny May 21 at 13:12
  • @user3419297's suggestion looks like its on point. It all means there's nothing I can do with the code. I think its more of a deep system thing instead of something that can be changed by altering the code. So there's NOTHING we can do? – crrSeeny May 21 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.