Jump to content

Get Position From "Position.txt" and Move to X


 Share

Recommended Posts

Hello!
I have a script who "lock" my mouse on a position if i toggle on, moving the mouse every 1ms to the pos. "100, 100"

Global $Paused
Global $delay = 2

HotKeySet("{Pause}", "TogglePause")
HotKeySet("{End}", "Kill")

Sleep(100)

While 1
    If $delay = 2 Then
        MouseMove(100, 100, 0)
        $delay = 1
    EndIf

    If $delay = 1 Then
        Sleep(1)
        $delay = 2
    EndIf
      ToolTip("ON", 1, 1, "SCRIPT", 1)
WEnd

Func TogglePause()
   $Paused = not $Paused
      While $Paused
         ToolTip("OFF", 1, 1, "SCRIPT", 3)
         Sleep(500)
      WEnd
EndFunc


Func Kill()
    ToolTip("Exiting...", 1, 1, "SCRIPT", 3)
    Sleep (1000)
   Exit
EndFunc

But..
I want to save information in a notebook called Position.txt (example), and get the information in that file and use into the script to move the mouse.
Example:

MouseMove ($xPos, $yPos, 0)

I want to get $xPos and $yPos from a notepad saved on same folder as script.
Inside the notepad I want something like:

LPhcEqB.png

Then when i start, script will get the positions from "Position.txt" and "lock" my mouse on x position.
I dont find anything like this on forums, anyone know how to? :(

Link to comment
Share on other sites

  • Moderators

Asuramaru,

An ini file would be just the thing - look at the Ini* functions in the help file.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Asuramaru,

Explain why you want to force the mouse to that position every few milliseconds and, if I approve, I will offer some help with ini files.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Asuramaru,

On reflection, an ini file is not what is wanted here - but this script should show you how to store and read coordinates. Click a few times within the GUI and then press the "Playback" button - the mouse will move to the previously clicked positions:

#include <GUIConstantsEx.au3>
#include <FileConstants.au3>

; Open file in which to write data
$sFileName = "Record.txt"
$hFile = FileOpen($sFileName, $FO_OVERWRITE)

; Create a GUI
$hGUI = GUICreate("Test", 500, 500)

$cPlayback = GUICtrlCreateButton("Playback", 10, 10, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            ; Get mouse position
            $aMousePos = MouseGetPos()
            ; Save coordinates
            FileWriteLine($hFile, $aMousePos[0] & "x" & $aMousePos[1] & @CRLF)

        Case $cPlayback
            ; Close file for writing
            FileClose($hFile)
            ; Open file for reading
            $hFile = FileOpen($sFileName, $FO_READ)
            While 1
                ; Read each line in turn
                $sLine = FileReadLine($hFile)
                ; Stop at EOF
                If @Error Then ExitLoop
                ; Read coordinates from line
                $aCoords = StringSplit($sLine, "x")
                ; Move mouse to that position
                MouseMove($aCoords[1], $aCoords[2])
                ; Wait a moment
                Sleep(500)
            WEnd
    EndSwitch

WEnd

Please ask if you have any questions.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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