Jump to content

move a Google Maps map slowly and fluidly with a routine


Go to solution Solved by ioa747,

Recommended Posts

Hi my friend

 

How can I move a Google Maps map slowly and fluidly with a routine similar to the following:

 

While 1
MouseMove(1480, 300, 0)
MouseClickDrag($MOUSE_CLICK_RIGHT, 1480, 300, 1790, 800,10)
wend

 

The idea is that the movement of movement is fluid without interruptions
I want to move the map without seeing sudden changes

 

best regards

Link to comment
Share on other sites

  • Solution
Posted (edited)

Here is my attempt :)

adjust the title  $sTitle = "Μaps Google — Mozilla Firefox"  depending on your language and browser

with the arrows choose a direction

and with the keys from the numeric keypad
0 = Pause
1, 4 = adjust how long is the drag step
2, 5 = adjust the speed of the drag step

 

; https://www.autoitscript.com/forum/topic/211963-move-a-google-maps-map-slowly-and-fluidly-with-a-routine/#comment-1534613
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

#include <AutoItConstants.au3>
#include <Misc.au3>

Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info

Global $sTitle = "Map Google — Mozilla Firefox" ; *** <-- Customize
Global $bInfo = True  ; *** <-- ConsoleWrite info

If WinExists($sTitle) Then
    WinActivate($sTitle)
Else
    ShellExecute("https://www.google.com/maps/")
EndIf

Global $hWnd = WinWaitActive($sTitle, "", 5)
DW("$hWnd=" & $hWnd & @CRLF)

Global $iSpeed = 10
Global $iStep = 10
Global $iDirection = 0
Global $aMPoint[2] = [@DesktopWidth * 0.9, @DesktopHeight * 0.8] ;DragPoint
DW("DragPoint=" & $aMPoint[0] & ", " & $aMPoint[1] & @CRLF)

While WinExists($hWnd)

    If  $sTitle = WinGetTitle("[ACTIVE]") Then ;Register HotKeys
        HotKeySet("{ESC}", "Direction")       ;Exit
        HotKeySet("{NUMPAD0}", "Direction")   ;$iDirection = 0 => Pause
        HotKeySet("{UP}", "Direction")        ;$iDirection = 1
        HotKeySet("{DOWN}", "Direction")      ;$iDirection = 2
        HotKeySet("{RIGHT}", "Direction")     ;$iDirection = 3
        HotKeySet("{LEFT}", "Direction")      ;$iDirection = 4
        HotKeySet("{NUMPAD4}", "Direction")   ;$iStep +
        HotKeySet("{NUMPAD1}", "Direction")   ;$iStep -
        HotKeySet("{NUMPAD5}", "Direction")   ;$iSpeed +
        HotKeySet("{NUMPAD2}", "Direction")   ;$iSpeed -

    Else ;UnRegister HotKeys
        HotKeySet("{ESC}")
        HotKeySet("{NUMPAD0}")
        HotKeySet("{UP}")
        HotKeySet("{DOWN}")
        HotKeySet("{RIGHT}")
        HotKeySet("{LEFT}")
        HotKeySet("{NUMPAD4}")
        HotKeySet("{NUMPAD1}")
        HotKeySet("{NUMPAD5}")
        HotKeySet("{NUMPAD2}")
    EndIf

    ;**********************************
    While $sTitle = WinGetTitle("[ACTIVE]")

        Switch $iDirection

            Case 0 ;Pause
                Sleep(300)

            Case 1 ;UP
                MouseMove($aMPoint[0], $aMPoint[1] - $iStep, 0)
                MouseDown("primary")
                MouseMove($aMPoint[0], $aMPoint[1] + $iStep, $iSpeed)
                MouseUp("primary")

            Case 2 ;DOWN
                MouseMove($aMPoint[0], $aMPoint[1] + $iStep, 0)
                MouseDown("primary")
                MouseMove($aMPoint[0], $aMPoint[1] - $iStep, $iSpeed)
                MouseUp("primary")

            Case 3 ;RIGHT
                MouseMove($aMPoint[0] + $iStep, $aMPoint[1], 0)
                MouseDown("primary")
                MouseMove($aMPoint[0] - $iStep, $aMPoint[1], $iSpeed)
                MouseUp("primary")

            Case 4 ;LEFT
                MouseMove($aMPoint[0] - $iStep, $aMPoint[1], 0)
                MouseDown("primary")
                MouseMove($aMPoint[0] + $iStep, $aMPoint[1], $iSpeed)
                MouseUp("primary")

        EndSwitch
        Sleep(10)
    WEnd
    ;**********************************

    Sleep(500)
WEnd

DW("- Exit Script" & @CRLF)

;--------------------------------------------------------------------------------------------------------------------------------
Func Direction()
    DW("- @HotKeyPressed=" & @HotKeyPressed & @CRLF)

    Switch @HotKeyPressed

        Case "{ESC}"
            DW("Exit" & @CRLF)
            Exit

        Case "{NUMPAD0}"
            $iDirection = 0
            DW("$iDirection=" & $iDirection & @CRLF)

        Case "{UP}"
            $iDirection = 1
            DW("$iDirection=" & $iDirection & @CRLF)

        Case "{DOWN}"
            $iDirection = 2
            DW("$iDirection=" & $iDirection & @CRLF)

        Case "{RIGHT}"
            $iDirection = 3
            DW("$iDirection=" & $iDirection & @CRLF)

        Case "{LEFT}"
            $iDirection = 4
            DW("$iDirection=" & $iDirection & @CRLF)

        Case "{NUMPAD4}"
            $iStep += 1
            $iStep = ($iStep < 3) ? 3 : (($iStep > 30) ? 30 : $iStep)
            DW("$iStep=" & $iStep & @CRLF)

        Case "{NUMPAD1}"
            $iStep -= 1
            $iStep = ($iStep < 3) ? 3 : (($iStep > 30) ? 30 : $iStep)
            DW("$iStep=" & $iStep & @CRLF)

        Case "{NUMPAD5}"
            $iSpeed -= 1
            $iSpeed = ($iSpeed < 2) ? 2 : (($iSpeed > 100) ? 100 : $iSpeed)
            DW("$iSpeed=" & $iSpeed & @CRLF)

        Case "{NUMPAD2}"
            $iSpeed += 1
            $iSpeed = ($iSpeed < 2) ? 2 : (($iSpeed > 100) ? 100 : $iSpeed)
            DW("$iSpeed=" & $iSpeed & @CRLF)

    EndSwitch
EndFunc   ;==>Direction
;--------------------------------------------------------------------------------------------------------------------------------
Func DW($sText)
    If Not $bInfo Then Return
    ConsoleWrite($sText)
EndFunc

 

Edited by ioa747
UpDate

I know that I know nothing

Link to comment
Share on other sites

53 minutes ago, ioa747 said:

Here is my attempt :)

adjust the title  $sTitle = "Μaps Google — Mozilla Firefox"  depending on your language and browser

with the arrows choose a direction

and with the keys from the numeric keypad
0 = Pause
1, 4 = adjust how long is the drag step
2, 5 = adjust the speed of the drag step

 

; https://www.autoitscript.com/forum/topic/211963-move-a-google-maps-map-slowly-and-fluidly-with-a-routine/#comment-1534613
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

#include <AutoItConstants.au3>
#include <Misc.au3>

Global $sTitle = "Μaps Google — Mozilla Firefox" ; *** <-- Customize
Global $bInfo = True  ; *** <-- ConsoleWrite info

If WinExists($sTitle) Then
    WinActivate($sTitle)
Else
    ShellExecute("https://www.google.com/maps/")
EndIf

Global $hWnd = WinWaitActive($sTitle, "", 5)
DW("$hWnd=" & $hWnd & @CRLF)

Global $iSpeed = 5
Global $iStep = 10
Global $iDirection = 0
Global $aMPoint[2] = [@DesktopWidth * 0.9, @DesktopHeight * 0.8]
DW("DragPoint=" & $aMPoint[0] & ", " & $aMPoint[1] & @CRLF)

While WinExists($hWnd)

    If WinActive($hWnd) Then ;Register HotKeys
        HotKeySet("{ESC}", "Direction")       ;Exit
        HotKeySet("{NUMPAD0}", "Direction")   ;$iDirection = 0 => Pause
        HotKeySet("{UP}", "Direction")        ;$iDirection = 1
        HotKeySet("{DOWN}", "Direction")      ;$iDirection = 2
        HotKeySet("{RIGHT}", "Direction")     ;$iDirection = 3
        HotKeySet("{LEFT}", "Direction")      ;$iDirection = 4
        HotKeySet("{NUMPAD4}", "Direction")   ;$iStep +
        HotKeySet("{NUMPAD1}", "Direction")   ;$iStep -
        HotKeySet("{NUMPAD5}", "Direction")   ;$iSpeed +
        HotKeySet("{NUMPAD2}", "Direction")   ;$iSpeed -
        
    Else ;UnRegister HotKeys
        HotKeySet("{ESC}")
        HotKeySet("{NUMPAD0}")
        HotKeySet("{UP}")
        HotKeySet("{DOWN}")
        HotKeySet("{RIGHT}")
        HotKeySet("{LEFT}")
        HotKeySet("{NUMPAD4}")
        HotKeySet("{NUMPAD1}")
        HotKeySet("{NUMPAD5}")
        HotKeySet("{NUMPAD2}")
    EndIf

    ;**********************************
    While WinActive($hWnd)

        Switch $iDirection

            Case 0 ;Pause
                Sleep(300)

            Case 1 ;UP
                MouseMove($aMPoint[0], $aMPoint[1] - $iStep, 0)
                MouseDown("primary")
                MouseMove($aMPoint[0], $aMPoint[1] + $iStep, $iSpeed)
                MouseUp("primary")

            Case 2 ;DOWN
                MouseMove($aMPoint[0], $aMPoint[1] + $iStep, 0)
                MouseDown("primary")
                MouseMove($aMPoint[0], $aMPoint[1] - $iStep, $iSpeed)
                MouseUp("primary")

            Case 3 ;RIGHT
                MouseMove($aMPoint[0] + $iStep, $aMPoint[1], 0)
                MouseDown("primary")
                MouseMove($aMPoint[0] - $iStep, $aMPoint[1], $iSpeed)
                MouseUp("primary")

            Case 4 ;LEFT
                MouseMove($aMPoint[0] - $iStep, $aMPoint[1], 0)
                MouseDown("primary")
                MouseMove($aMPoint[0] + $iStep, $aMPoint[1], $iSpeed)
                MouseUp("primary")

        EndSwitch
        Sleep(10)
    WEnd
    ;**********************************

    Sleep(500)
WEnd

DW("- Exit Script" & @CRLF)

;--------------------------------------------------------------------------------------------------------------------------------
Func Direction()
    DW("- @HotKeyPressed=" & @HotKeyPressed & @CRLF)

    Switch @HotKeyPressed

        Case "{ESC}"
            DW("Exit" & @CRLF)
            Exit

        Case "{NUMPAD0}"
            $iDirection = 0
            DW("$iDirection=" & $iDirection & @CRLF)

        Case "{UP}"
            $iDirection = 1
            DW("$iDirection=" & $iDirection & @CRLF)

        Case "{DOWN}"
            $iDirection = 2
            DW("$iDirection=" & $iDirection & @CRLF)

        Case "{RIGHT}"
            $iDirection = 3
            DW("$iDirection=" & $iDirection & @CRLF)

        Case "{LEFT}"
            $iDirection = 4
            DW("$iDirection=" & $iDirection & @CRLF)

        Case "{NUMPAD4}"
            $iStep += 1
            $iStep = ($iStep < 3) ? 3 : (($iStep > 30) ? 30 : $iStep)
            DW("$iStep=" & $iStep & @CRLF)

        Case "{NUMPAD1}"
            $iStep -= 1
            $iStep = ($iStep < 3) ? 3 : (($iStep > 30) ? 30 : $iStep)
            DW("$iStep=" & $iStep & @CRLF)

        Case "{NUMPAD5}"
            $iSpeed -= 1
            $iSpeed = ($iSpeed < 2) ? 2 : (($iSpeed > 100) ? 100 : $iSpeed)
            DW("$iSpeed=" & $iSpeed & @CRLF)

        Case "{NUMPAD2}"
            $iSpeed += 1
            $iSpeed = ($iSpeed < 2) ? 2 : (($iSpeed > 100) ? 100 : $iSpeed)
            DW("$iSpeed=" & $iSpeed & @CRLF)

    EndSwitch
EndFunc   ;==>Direction
;--------------------------------------------------------------------------------------------------------------------------------
Func DW($sText)
    If Not $bInfo Then Return
    ConsoleWrite($sText)
EndFunc

 

Thank you very much dear the application works Perfect

Sincerely

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