Jump to content

Recommended Posts

Posted (edited)

Help me finish the script.
It works manually, but not with a script.
Maybe I don't have to drive exactly straight so that there is a curved line,or did I pick up the speed incorrectly?
I tried many variants.
 You need to hold down the left button, swipe in the right direction, release it, return the mouse to its original position.
for comfortable  swipe photos in mobile  applications or for swiping talkback gestures on an Android virtual machine.


 

Global $iX = 0, $iY = 0
Global $sKeySwipeLeft = "^{LEFT}"
Global $sKeySwipeRight = "^{RIGHT}"
Global $sKeySwipeUp = "^{UP}"
Global $sKeySwipeDown = "^{DOWN}"

Beep(1000, 300)

HotKeySet($sKeySwipeLeft, "swipe_left")
HotKeySet($sKeySwipeRight, "swipe_right")
HotKeySet($sKeySwipeUp, "swipe_up")
HotKeySet($sKeySwipeDown, "swipe_down")

While 1
    Sleep(1000)
WEnd

Func swipe_left()
    HotKeySet($sKeySwipeLeft)
    Sleep(10)
    ;Beep(900, 100)
    $iX = MouseGetPos(0)
    $iY = MouseGetPos(1)
    MouseDown("left")
    Sleep(10)
    MouseMove($iX - 100, $iY, 10)
    Sleep(10)
    MouseUp("left")
    Sleep(10)
    MouseMove($iX, $iY, 1)
    HotKeySet($sKeySwipeLeft, "swipe_left")
EndFunc

Func swipe_right()
    HotKeySet($sKeySwipeRight)
    Sleep(10)
    ;Beep(900, 100)
    $iX = MouseGetPos(0)
    $iY = MouseGetPos(1)
    MouseDown("left")
    Sleep(10)
    MouseMove($iX + 100, $iY, 10)
    Sleep(10)
    MouseUp("left")
    Sleep(10)
    MouseMove($iX, $iY, 1)
    HotKeySet($sKeySwipeRight, "swipe_right")
EndFunc

Func swipe_up()
    HotKeySet($sKeySwipeUp)
    Sleep(10)
    ;Beep(900, 100)
    $iX = MouseGetPos(0)
    $iY = MouseGetPos(1)
    MouseDown("left")
    Sleep(10)
    MouseMove($iX, $iY + 100, 10)
    Sleep(10)
    MouseUp("left")
    Sleep(10)
    MouseMove($iX, $iY, 1)
    HotKeySet($sKeySwipeUp, "swipe_up")
EndFunc

Func swipe_down()
    HotKeySet($sKeySwipeDown)
    Sleep(10)
    ;Beep(900, 100)
    $iX = MouseGetPos(0)
    $iY = MouseGetPos(1)
    MouseDown("left")
    Sleep(10)
    MouseMove($iX, $iY - 100, 10)
    Sleep(10)
    MouseUp("left")
    Sleep(10)
    MouseMove($iX, $iY, 1)
    HotKeySet($sKeySwipeDown, "swipe_down")
EndFunc


I repeat, this works when executed manually.

Edited by alex33
Posted (edited)

@alex33

this how you swipe with mouse see below:

#include <GUIConstantsEx.au3>
AdlibRegister("_Mouse2", 900)
AdlibRegister("_MouseAc_2", 100)
Global $true, $INUM, $INUM2, $Ret, $mouse, $mouse2, $state_1 = "on", $state_2 = "on"
#Region
$MainGui = GUICreate("Swipe Text By Mouse", 355, 298, -1, -1)
$Edit1 = GUICtrlCreateEdit("", 96, 40, 249, 193)
GUICtrlSetData(-1, "Edit1")
GUISetState(@SW_SHOW)
#EndRegion
WinActivate($MainGui)
Sleep(100)
While 1
    If WinActive($MainGui) Then
        $PX = MouseGetPos()[0]
        $WX = WinGetPos($MainGui)[0]
        $PY = MouseGetPos()[1]
        $WY = WinGetPos($MainGui)[1]
        Local $Wd = WinGetClientSize($MainGui)[0] + $WX + 2
        Local $Wh = WinGetClientSize($MainGui)[1] + $WY + 25
        Local $Wh2 = WinGetClientSize($MainGui)[1] - $Wh
        If $PX >= $WX And $PY >= $WY + 26 And $PY < $Wh And $PY > $Wh2 And $PX <= $Wd Then ; And $WY <$PY Then
            _SwipeByMouse()
        Else
            swipe_off()
        EndIf
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE

            Exit
    EndSwitch
WEnd

Func _SwipeByMouse()
    If _MouseAc() = True Or $mouse <> MouseGetPos(0) Or $mouse2 <> MouseGetPos(1) Then
        $state_2 = "on"
        If $state_1 = "on" Then
            swipe_on()
            $state_1 = "off"
        EndIf
    ElseIf _MouseAc() = False And $mouse = MouseGetPos(0) Or _MouseAc() = False And $mouse2 = MouseGetPos(1) Then
        $state_1 = "on"
        If $state_2 = "on" Then
            swipe_off()
            $state_2 = "off"
        EndIf

    EndIf

EndFunc   ;==>_SwipeByMouse
Func _Mouse2()
    $mouse = MouseGetPos(0)
    $mouse2 = MouseGetPos(1)

EndFunc   ;==>_Mouse2

Func _MouseAc()
    If $mouse = MouseGetPos(0) Or $mouse2 = MouseGetPos(1) Then
        $INUM2 = $INUM2 + 1
    EndIf
    Sleep(10)
    $INUM = $INUM2
    If $Ret = False Then
        Return False
    Else
        Return True
    EndIf
EndFunc   ;==>_MouseAc
Func _MouseAc_2()
    If $INUM <> $INUM2 Then
        $Ret = False
    Else
        $Ret = True
    EndIf
EndFunc   ;==>_MouseAc_2

Func swipe_on()
    MouseDown("left")
EndFunc   ;==>swipe_on

Func swipe_off()
    MouseUp("left")
EndFunc   ;==>swipe_off

 

Edited by ad777

none

Posted

100 is a very small value, have you tried with larger number (500 - 600) ?  Btw, your up/down versions are incorrect, it should be -xxx for up and +xxx for down (currently it is the inverse).

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
  • Recently Browsing   0 members

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