Hodahel Posted March 5, 2013 Share Posted March 5, 2013 Hi, I'm new here and just started playing with AutoIt.. By reading some tut, I was able to create a simple script to open a particular website. Now my problem is how to: 1. Open a save txt file with my data in it..like this: Name Family Name Email Address and put it in a textbox/data field of IE? Also how to put may text on datafield by using a known MARKER like blahbla@MYTEXT_HERE @ is the marker.. TIA Link to comment Share on other sites More sharing options...
Relive Posted March 5, 2013 Share Posted March 5, 2013 You would need these functions: FileOpen() FileReadtoArray() (or something similar) Using some string expressions, determine what exp. is for name, etc. and place these values into the right fields Use another string expression for @ Link to comment Share on other sites More sharing options...
water Posted March 5, 2013 Share Posted March 5, 2013 I wouldn't read files line by line (except the very large ones) but use - as has been suggested - _FileReadToArray for performance reasons. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
Hodahel Posted March 5, 2013 Author Share Posted March 5, 2013 I want to read 1 line, then put in an input field of IE., then click OK button.. Link to comment Share on other sites More sharing options...
water Posted March 5, 2013 Share Posted March 5, 2013 For the IE part I suggest to use the IE UDF that comes with AutoIt. What have you coded so far? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
Hodahel Posted March 5, 2013 Author Share Posted March 5, 2013 (edited) For the IE part I suggest to use the IE UDF that comes with AutoIt. What have you coded so far? This is my code to find the input field and fill in the data and press login button.. #include <IE.au3> Call("domain") Func domain() Global $oIE = _IECreate("http://www.mypage.org",0,1,1) ; page to open Local $oUsername = _IEGetObjByName($oIE, "Username") Local $oPassword = _IEGetObjByName($oIE, "Password") Local $oButton = _IEGetObjById($oIE, "btnLogin") _IEFormElementSetValue($oUsername, "user") _IEFormElementSetValue($oPassword, "user") _IEAction($oButton, "click") _IEQuit($oIE) ;close the Internet Explorer EndFunc ;==>login I want to remove this part: _IEFormElementSetValue($oUsername, "user") _IEFormElementSetValue($oPassword, "user") and read it directly from text file named, data.txt BR Edited March 5, 2013 by Hodahel Link to comment Share on other sites More sharing options...
water Posted March 5, 2013 Share Posted March 5, 2013 Use FileReadLine to read a line to a variable and then pass this variable to _IEFormElementSetValue. Hodahel 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
JohnQSmith Posted March 5, 2013 Share Posted March 5, 2013 (edited) Rules violation. Auto-log-in is not allowed. See rules link in bottom right corner of page. #include <IE.au3> Call("domain") Func domain() Global $oIE = _IECreate("http://www.mypage.org",0,1,1) ; page to open Local $oUsername = _IEGetObjByName($oIE, "Username") Local $oPassword = _IEGetObjByName($oIE, "Password") Local $oButton = _IEGetObjById($oIE, "btnLogin") _IEFormElementSetValue($oUsername, "user") _IEFormElementSetValue($oPassword, "user") _IEAction($oButton, "click") _IEQuit($oIE) ;close the Internet Explorer EndFunc ;==>login edit: pointed to rules link Edited March 5, 2013 by JohnQSmith Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2013 Moderators Share Posted March 5, 2013 JohnQSmith,The rules speak of "log-in and security dialogs" - as this deals with a normal page there is no problem. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Hodahel Posted March 10, 2013 Author Share Posted March 10, 2013 Rules violation. Auto-log-in is not allowed. See rules link in bottom right corner of page.edit: pointed to rules linkWith due respect sir..Bypassing of security measures - log-in and security dialogs.....I don't see any "BYPASS of security" if I login with all my credentials? Not unless if you consider NOT TYPING the login name as Bypassing of security.. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 10, 2013 Moderators Share Posted March 10, 2013 Hodahel, See my post above - there is no problem with this question. M23 Hodahel 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Hodahel Posted March 11, 2013 Author Share Posted March 11, 2013 Use FileReadLine to read a line to a variable and then pass this variable to _IEFormElementSetValue.I'll try to work with this..BR Link to comment Share on other sites More sharing options...
Hodahel Posted March 20, 2013 Author Share Posted March 20, 2013 Hi, I already tried this code on AutoIt Example.. Local $file = FileOpen("test.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 Local $line = FileReadLine($file) If @error = -1 Then ExitLoop MsgBox(0,"Line read:", $line) WEnd FileClose($file) And I created a form in Koda #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=c:\users\user\documents\hunt.kxf $Form1_1 = GUICreate("Form1", 300, 241, 407, 256) $Input1 = GUICtrlCreateInput("", 72, 16, 209, 21) $Label1 = GUICtrlCreateLabel("TextBox1", 24, 16, 49, 17) $Button1 = GUICtrlCreateButton("Start", 88, 112, 113, 41) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd All I want is when I click the start button, the first line of the text file will be displayed on the textbox of the form..Can somebody help me to do it? TIA Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 20, 2013 Moderators Share Posted March 20, 2013 Hodahel, I would read the file like this: #include <GUIConstantsEx.au3> #include <File.au3> ; Read the file into an array Global $aLines _FileReadToArray("Test.txt", $aLines) ; Create the GUI $Form1_1 = GUICreate("Form1", 300, 241, 407, 256) $Input1 = GUICtrlCreateInput("", 72, 16, 209, 21) $Label1 = GUICtrlCreateLabel("TextBox1", 24, 16, 49, 17) $Button1 = GUICtrlCreateButton("Start", 88, 112, 113, 41) GUISetState(@SW_SHOW) ; This is the line number we are going to read $iCount = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button1 ; Increase the line number by 1 $iCount += 1 ; Check we are not past the end of the file If $iCount > $aLines[0] Then ; We were GUICtrlSetData($Input1, "End Of File") Else ; Write the next line into the input GUICtrlSetData($Input1, $aLines[$iCount]) EndIf EndSwitch WEnd All clear? M23 Hodahel 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
BrewManNH Posted March 20, 2013 Share Posted March 20, 2013 #include <GUIConstantsEx.au3> GUICreate("Form1", 300, 241, 407, 256) Global $Input1 = GUICtrlCreateInput("", 72, 16, 209, 21) GUICtrlCreateLabel("TextBox1", 24, 16, 49, 17) Global $Button1 = GUICtrlCreateButton("Start", 88, 112, 113, 41) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Local $file = FileOpen("test.txt") If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf GUICtrlSetData($Input1, FileReadLine($file)) ; reads only the first line of the file FileClose($file) EndSwitch WEnd Hodahel 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Hodahel Posted March 20, 2013 Author Share Posted March 20, 2013 (edited) Melba23, BrewManNHThank you so much to both of you! I'll study both examples..Maybe I'm too old for this... Edited March 20, 2013 by Hodahel Link to comment Share on other sites More sharing options...
Hodahel Posted March 30, 2013 Author Share Posted March 30, 2013 (edited) This is my progress now..#include <IE.au3> #Include <Constants.au3> #include <File.au3> Local $file = FileOpen("address.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached ;While 1 Local $line = FileReadLine($file) If @error = -1 Then Exit ;MsgBox(0, "Line read:", $line) ;WEnd Call("address") Func address() Global $oIE =_IECreate("http://"& $line &",0,1,1,1) ; page to open _IEQuit($oIE) ;close the Internet Explorer EndFunc ;==>address FileClose($file)I have a texe file named ADDRESS.TXT which list website address like this:www.yahoo.comwww.google.comwww.msn.comI want it to put it in IE address bar like thisGlobal $oIE =_IECreate("http://"& $line &",0,1,1,1)until all the line is finished..With that code above it only insert the first line of the text file... Edited March 30, 2013 by Hodahel Link to comment Share on other sites More sharing options...
kylomas Posted March 30, 2013 Share Posted March 30, 2013 Hodahel, See comments in code... #include <IE.au3> #include <Constants.au3> #include <array.au3> #include <file.au3> Local $file = FileOpen(@scriptdir & "\address.txt", 0) ; <--------- file is in same dir as script ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read file to array local $aLines _FileReadToArray(@scriptdir & "\address.txt", $aLines) ;Call("address") ; <--------------------- invoke functions directly, not with call address() ; <--------------------- like this Func address() for $1 = 1 to $aLines[0] if $aLines[$1] = '' then continueloop local $oIE = _IECreate($aLines[$1],0,1,1,1) ; page to open if @error <> 0 then ConsoleWrite('Error code = ' & @error & @LF) ;_IEQuit($oIE) ;close the Internet Explorer next EndFunc ;==>address FileClose($file) kylomas Hodahel 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
water Posted March 30, 2013 Share Posted March 30, 2013 Maybe I'm too old for this... Too old to AutoIt, too young to die Hodahel 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
kylomas Posted March 30, 2013 Share Posted March 30, 2013 Too old to AutoIt, too young to die So much code...so little time... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
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