Italian Simulare click da codice

ivanomonti

Expert
Licensed User
Longtime User
no devo simulare un click screen touch, come se fossi stato fatto da un umano con il dito per intenderci.
 

ivanomonti

Expert
Licensed User
Longtime User
Mi spiego meglio, io ho devo simulare un click randomico come se fosse un dito che preme sullo schermo app e sempre la stessa, ma il sistema deve intepretarlo come se fosse un vero click
 

LucaMs

Expert
Licensed User
Longtime User
Allora, hai detto: "il sistema deve interpretarlo come se fosse un vero click"

Se tu scrivi:

Button1_Click

viene eseguito esattamente come se l'utente ci avesse premuto il dito.

Bisogna vedere come vuoi "posizionare" il dito sopra al tasto!

Se usi delle coordinate x e y e nel Tag metti il nome della view, poi puoi provare così:
B4X:
Private Sub Button1_Click
    ToastMessageShow("Button1 clicked", False)
End Sub

Private Sub ExecuteClick(x As Float, y As Float)
    Private vw As View
    For i = 0 To Activity.NumberOfViews - 1
        vw = Activity.GetView(i)
        If PointIsIntoView(vw, x, y) Then
            If vw Is Button Then
                CallSub("main", vw.tag & "_Click")
                Exit
            End If
        End If
    Next
End Sub

Private Sub PointIsIntoView(Vw As View, x As Float, y As Float) As Boolean
    Return x >= Vw.Left AND x <= Vw.Left + Vw.Width AND _
           y >= Vw.Top AND y <= Vw.Top + Vw.Height
End Sub
 
Last edited:

ivanomonti

Expert
Licensed User
Longtime User
Possiamo sentirci via chat fb o skype, non capisco il codice, io devo azionarlo tramite un timer
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Non uso quella roba :D

Io non so come vuoi "manovrare il dito"...

se, in qualche modo, tu ottieni le coordinate x,y del "dito", ti basta chiamare:
ExecuteClick(x,y)
All'interno di quella routine, controlli il Tag delle view sulle quali vuoi clickare.

Se hai Button1, ImageView1... etc dovrai utilizzare:

Button1.Tag = "Button1" (puoi farlo anche nel Designer)
ImageView1.Tag = "ImageView1"

Anzi, più precisamente, dovrai mettere nel Tag lo stesso nome che darai all'Event Name.

Nella routine ho messo:
If vw is button, ma puoi cambiarla così:
B4X:
Private Sub ExecuteClick(x As Float, y As Float)
    Private vw As View
    For i = 0 To Activity.NumberOfViews - 1
        vw = Activity.GetView(i)
        If PointIsIntoView(vw, x, y) Then
           Try
                CallSub("main", vw.tag & "_Click")
                Exit
           Catch
           End Catch
        End If
    Next
End Sub

la PointIsIntoView controlla se le coordinate che gli passi si trovano all'interno della view che gli passi.
 

eleandrot

Member
Licensed User
Longtime User
Hello, I'm making a program that sends MMS but it uses INTENT, I would like to do it click on SEND, you could pass me the code that worked for you?
 

anallie0

Active Member
Licensed User
Longtime User
forse mi sbaglio ma un evento originale del click non credo sia realizzabile per il semplice fatto che è un evento hardware gestito dal controller dello schermo e passato al sistema operativo.
 
Top