Hok Posted April 14, 2009 Posted April 14, 2009 Hey, I'm trying to make a program that reads lines in a program to make a macro. So for example - a text file would contain... [RandomWait] [5] [10] [MouseClick] [Right] [30] [60] The program would output; a random wait from 5 to ten seconds, then a mouseclick. However, I didn't finish and i think I am approaching it wrong... here is my source. #Include <File.au3> $FileName = InputBox("File Name", "Input the file name of the script:", "Input Script Name") FileOpen($FileName, 0) $NumberLines = _FileCountLines($FileName) $NumberLines = $NumberLines+1 While $NumberLines>0 FileReadLine($FileName, $NumberLines = $Numberlines-1) WEnd - Hok
Valuater Posted April 14, 2009 Posted April 14, 2009 Extended version of what you want...http://www.autoitscript.com/forum/index.ph...ost&p=889618)
Hok Posted April 14, 2009 Author Posted April 14, 2009 Thanks... but I kinda wanted to develop it myself... - Hok
KaFu Posted April 14, 2009 Posted April 14, 2009 With some commented error-checking... expandcollapse popup;#include<array.au3> $message = "Open file containing commands" $var = FileOpenDialog($message, @ScriptDir, "Command List files (*.lst)", 1) If Not @error Then $file = FileOpen($var, 0) ConsoleWrite($var & @tab & $file & @crlf) If $file <> -1 Then While 1 $line = FileReadLine($file) If @error Then ExitLoop ;ConsoleWrite($line & @crlf) $line = StringReplace($line,"] [","|") $line = StringReplace($line,"]","") $line = StringReplace($line,"[","") $aLine = StringSplit($line,"|") ;_ArrayDisplay($aLine) if not @error then Switch $aLine[1] Case "RandomWait" ConsoleWrite($aLine[2] & @tab & $aLine[3] & @crlf) Sleep(Random($aLine[2],$aLine[3]) * 1000) Case "MouseClick" ConsoleWrite($aLine[2] & @tab & $aLine[3] & @tab & $aLine[4] & @crlf) MouseClick($aLine[2],$aLine[3],$aLine[4]) EndSwitch endif Wend EndIf FileClose($file) EndIf #cs Filename "command.lst" contains [RandomWait] [5] [10] [MouseClick] [Right] [30] [60] #ce OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now