Asuramaru

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

8 posts in this topic

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? :(

Share this post


Link to post
Share on other sites



Quote

FileRead:

Read in a number of characters from a previously opened file.

StringSplit:

Splits up a string into substrings depending on the given delimiters.

 

Share this post


Link to post
Share on other sites

Asuramaru,

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

I will try to read the ini function, its because i'm bad with english xD

I try to learn putting some random codes and see what happens, :x

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

I used only as a example, i want to learn this language too, only for knowledge XD

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

I did what i need already xd
I used iniwrite and iniread, thanks for helping me!
If need can close topic

Share this post


Link to post
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