Jump to content

_IsPressed and Tap on Touch Screen


Recommended Posts

Hi,

I would like to know if it's possible to detect a "Tap" on a touch screen with _IsPressed

I need to detect when a Tap is done outside my application.

With "If _IsPressed(01, $hDLL) Then" it's working well with a mouse click. On a touch screen I must double Tap in order to have this condition true.

It will be great if someon have a solution :)

Thank you very much !

Link to comment
Share on other sites

  • 4 weeks later...

Does anyone have any examples on how to "AutoIT" this?

I have an adlib that monitors for clicks in one part of the screen, it works perfectly with a mouse click. But this machine is going to be touch only when deployed.


Func DetectClick()
   $X = MouseGetPos(0)
   $Y = MouseGetPos(1)
   If $X > 1447 AND $X < 1611 AND $Y > 14 AND $Y < 32 AND _IsPressed(01) Then RunTabTip()
EndFunc

Edited by ken82m

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

I'm not sure if this helps your issue, but you could try the MouseOnEvent UDF to detect if the mouse was clicked. You can customize it to do x action if your cursor is inside  specific coordinates with WinGetPos()

I understand you need the condition to be true only on double click. In this case, see my example below.

#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)
    Local $timer = TimerInit()
    Do
        If $X > $BorderLeft And $X < $BorderRight And $Y > $BorderTop And $Y < $BorderBottom And _IsPressed(01) Then _OnDoubleClick()
    Until TimerDiff($timer) > 500 ;Delay in milliseconds to wait for a second click before assuming the event was single click.
EndFunc   ;==>_OnSingleClick
Func _OnDoubleClick()
    MsgBox(0, "All good Bossun.", "Double Click Detected! Exiting...")
    Exit
EndFunc   ;==>_OnDoubleClick

 

Edited by BetaLeaf

 

 

Link to comment
Share on other sites

That code you wrote works perfectly with both the mouse and touchscreen. Thanks a lot Beta!   -Kenny

I'm checking out the UDF too, I know I used it long ago but it used to interfere with some apps here and there. But I'm sure they worked out the kinks.

I'm not sure if this helps your issue, but you could try the MouseOnEvent UDF to detect if the mouse was clicked. You can customize it to do x action if your cursor is inside  specific coordinates with WinGetPos()

I understand you need the condition to be true only on double click. In this case, see my example below.

#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)
    Local $timer = TimerInit()
    Do
        If $X > $BorderLeft And $X < $BorderRight And $Y > $BorderTop And $Y < $BorderBottom And _IsPressed(01) Then _OnDoubleClick()
    Until TimerDiff($timer) > 500 ;Delay in milliseconds to wait for a second click before assuming the event was single click.
EndFunc   ;==>_OnSingleClick
Func _OnDoubleClick()
    MsgBox(0, "All good Bossun.", "Double Click Detected! Exiting...")
    Exit
EndFunc   ;==>_OnDoubleClick

 

 

Edited by ken82m

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

  • 1 year later...
On 7/29/2015 at 6:26 AM, Manioums said:

Trying to figure this out.  But goes above my understanding.    I have a script that I am having students use while taking a test, But some of the computers the school has provided are touch screen.  How can I change whatever is needed so only one tap on the answer is needed instead of a double tap?  

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...