Jump to content

Recommended Posts

Posted

Hi there,

My only goal is for the computer to play a clicking sound whenever I tap the screen through my touchscreen. And through searching and combining some solutions I've found in the forums, I've managed to get my script to detect when I tap ("click") on the screen, but for some reason it doesn't work when I'm in Chrome. It does work flawlessly when I'm using my mouse.

Here is one example script:

#include "misc.au3"
$X = MouseGetPos(0)
$Y = MouseGetPos(1)
$BorderLeft = 0
$BorderTop = 0
$BorderRight = @DesktopWidth
$BorderBottom = @DesktopHeight
While 1
    If $X > $BorderLeft And $X < $BorderRight And $Y > $BorderTop And $Y < $BorderBottom And _IsPressed(01) Then _OnSingleClick()
WEnd
Func _OnSingleClick()
    Do
        sleep(1)
    Until not _IsPressed(01)
    ConsoleWrite("pressed" & @CRLF)
    SoundPlay("click.wav")
EndFunc

And here is another:

#include <Misc.au3>

$hDLL = DllOpen("user32.dll")

While 1
    If  _IsPressed("01", $hDLL) Then _OnSingleClick()
    Sleep(1)
WEnd
DLLClose($hDLL)

Func _OnSingleClick()
    Do
        sleep(1)
    Until not _IsPressed("01", $hDLL)

    ConsoleWrite("pressed" & @CRLF)
    SoundPlay("click.wav")
EndFunc

Again, they both work, and I can see "pressed" in the console, and I can audibly hear my click.wav. But it generally only works when click around the base OS. When moving into an application like Chrome or Edge it doesn't detect. Does anybody have any thoughts on how to fix this?

Thanks!

Posted
23 hours ago, Danp2 said:

You may want to review this thread.

Hi @Danp2, thanks for responding. I did see that post, and @Nine's solution, but a) it only works within a pop-up that is made (I'm not smart enough to get it to work globally). And b) it also seems to only work for touching with my mouse. I get an error when touching it on my touch screen.

Local $pic1_pos = _WinAPI_GetWindowRect(GUICtrlGetHandle($pic1))
Local $pic1_pos = ^ ERROR

Any thoughts or help?

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
×
×
  • Create New...