Jump to content

Read from a txt


Scrippter
 Share

Recommended Posts

I am trying to get the x,y of a robotic arm to move to preplanned points. The mouse has to move to a picture of where the arm will go.

The controlling program only executes exe's.

So i was wondering if its possible to store the x,y cords in a file, and have my program copy the files data and executes it as if it was in the program.

One way i shot down was the Input command, due to large list of points,and it takes too long to do keep typing it in.

Here is what i Got so Far.

*Note* Im using Vista 64.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=..\Downloads\Dragon.ico
#AutoIt3Wrapper_outfile=..\..\Desktop\TaffyMaker64.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("TrayMenuMode", 1)
#Region ### START Koda GUI section ### Form=c:\users\mom\documents\scripts\TaffyMaker.kxf
$Form1 = GUICreate("Venluckey's GUI", 236, 360, 191, 119)
GUISetIcon("C:\Users\Guest2630\Fang.jpg.ico", -1)
GUISetBkColor(0xB9D1EA)
$Button1 = GUICtrlCreateButton("TaffyMaker", 0, 24, 161, 33)
$Harvester = GUICtrlCreatePic("C:\Users\Guest2630\Fang.jpg", 168, 8, 57, 57, $SS_CENTERIMAGE, $WS_EX_CLIENTEDGE)
$Date1 = GUICtrlCreateDate("2010/10/17 23:16:8", 8, 296, 193, 49, -1, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $Paused

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{END}", "Terminate")
HotKeySet("{Home}", "Postion")
HotKeySet("{F1}","Help")
while 1
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            Call ("Commands")
    EndSwitch
WEnd
    
Func Commands()
    while 3
MouseClick("left", 310, 346, 2)
Sleep (3000)
MouseClick("left", 381, 313, 2)
Sleep (3000)
MouseClick("left", 347, 252, 2)
Sleep (3000)
MouseClick("left", 420, 229, 2)
Sleep (3000)
MouseClick("left", 486, 193, 2)
Sleep (3000)
MouseClick("left", 552, 164, 2)
Sleep (9000)
WEnd
EndFunc

;~ End Code here

Func Postion()
    $pos = MouseGetPos()
MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])
EndFunc

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(1000)
    SoundPlay(@WindowsDir & "\sounds\12.wav", 1)
    WEnd

EndFunc   ;==>TogglePause

Func Terminate()
    SoundPlay(@WindowsDir & "\media\chimes.wav", 1)
    Exit 0
EndFunc   ;==>Terminate

Func Help()
    MsgBox(64, "Controls", "Pause Key Pauses program.  End Key Shuts it down. Home Key gives Mouse Postion")
EndFunc
Edited by Scrippter
Link to comment
Share on other sites

You want to replace the MouseClick commands in Func Commands() with data read from a file. Correct?

How many data points are we talking about?

#include <File.au3>
Global $aInputRecords
Func Commands()
    ; Each record looks like: x-coordinate, y-coordinate, number of clicks
    _FileReadToArray("Your file.txt", $aInputRecords)
    For $iIndex = 1 To $aInputRecords[0]
        $aCoords = StringSplit($aInputRecords[$iIndex], ",")
        MouseClick("left", $aCoords[1], $aCoords[2], $aCoords[3])
        Sleep(3000)
    Next
EndFunc ;==>Commands

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

You want to replace the MouseClick commands in Func Commands() with data read from a file. Correct?

How many data points are we talking about?

#include <File.au3>
Global $aInputRecords
Func Commands()
    ; Each record looks like: x-coordinate, y-coordinate, number of clicks
    _FileReadToArray("Your file.txt", $aInputRecords)
    For $iIndex = 1 To $aInputRecords[0]
        $aCoords = StringSplit($aInputRecords[$iIndex], ",")
        MouseClick("left", $aCoords[1], $aCoords[2], $aCoords[3])
        Sleep(3000)
    Next
EndFunc ;==>Commands

I have 28 data points, but due to other using this set i have a change of about 10 of them a day. So inned the mouse to click the points i tell it to. The points represent a picture of the work environment, and each point is a place the arm needs to stop, where my partner is writing the code to work the open and close of the hand. If i have a way to input this in a txt or an excel format, and have the points relayed and moved by the system would be great.

-----------------

data from file | To my code \-------then execute to Robotic Arm-------

---------------------------

I guess maybe the input command is the only way, i have never messed with arrays, not quite confident of them yet.

Yet the input command would be really easy i guess, just lots of work.

i could use the

$answer1 = InputBox("Auto Points Correction", "What points need adjusting?", "", "", _,) but would then need list to see them all.

Func _ChangeAnswer()

$answer1 = InputBox("Auto Points Correction", "What points need adjusting?", "", "", _,)

EndFunc

what you think?

Link to comment
Share on other sites

Why not use an ini? You could have your script ask to set the points you wish to use by entering or mouse clicks and saving to an ini. Then when you go to control the arm, just use ini read to get the points that were stored.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

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