Iraj Posted January 7, 2023 Posted January 7, 2023 (edited) Greetings! I am trying to pass parameters using Send () function as below $sFilePath = @ScriptDir & "\config.ini" Local $hFileOpen = FileOpen($sFilePath, $FO_READ) Local $sURLUsername = FileReadLine($hFileOpen, 1) Local $sURLPassword = FileReadLine($hFileOpen, 2) Local $sAutomation = FileReadLine($hFileOpen, 3) Run("chrome facebook.com") Sleep(5000) Send($sAutomation) FileClose($hFileOpen) The config.ini file contains below lines abcd wxyz $sURLUsername{TAB}$sURLPassword{ENTER} While running, I am getting $sURLUsername & $sURLPassword in the username & password field instead of abcd & wxyz as provided. Refer image below: Where am I going wrong? Any suggestions or assistance will be grateful. Edited January 7, 2023 by Iraj other
ioa747 Posted January 7, 2023 Posted January 7, 2023 (edited) try this maybe help $sAutomation = "^aabcd{TAB}wxyz{ENTER}" ShellExecute("https://www.facebook.com/login.php/") WinWait("Log into Facebook — ") Send($sAutomation) in ini file need only one line. The send line like $sAutomation otherwise $sAutomation = "^a" & $sURLUsername & "{TAB}" & $sURLPassword & "{ENTER}" Edited January 7, 2023 by ioa747 I know that I know nothing
Iraj Posted January 7, 2023 Author Posted January 7, 2023 1 hour ago, ioa747 said: try this maybe help $sAutomation = "^aabcd{TAB}wxyz{ENTER}" ShellExecute("https://www.facebook.com/login.php/") WinWait("Log into Facebook — ") Send($sAutomation) in ini file need only one line. The send line like $sAutomation otherwise $sAutomation = "^a" & $sURLUsername & "{TAB}" & $sURLPassword & "{ENTER}" That I tried, the issue is the username & password will be changing often & I require it as mentioned above (in .ini file) & also will be confusing for the people who will use it. I just need to figure it out where I am going wrong. Thanks anyways! If any other way, do lemme know
ioa747 Posted January 7, 2023 Posted January 7, 2023 $sURLUsername & "{TAB}" & $sURLPassword & "{ENTER}" instead of $sURLUsername{TAB}$sURLPassword{ENTER} I know that I know nothing
Moderators Melba23 Posted January 7, 2023 Moderators Posted January 7, 2023 Iraj, Before we go any further, how about explaining why you have the need to read usernames and passwords from a file in order to login. This implies that you will be logging into several accounts rather then just your own. So just what is going on? M23 P.S. And just to be absolutely clear - this is the Mod team determining the legality of the thread, so everyone else please keep out. 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
Iraj Posted January 7, 2023 Author Posted January 7, 2023 13 minutes ago, Melba23 said: Iraj, Before we go any further, how about explaining why you have the need to read usernames and passwords from a file in order to login. This implies that you will be logging into several accounts rather then just your own. So just what is going on? M23 P.S. And just to be absolutely clear - this is the Mod team determining the legality of the thread, so everyone else please keep out. I am currently working on website automation project for an organisation for SSO module which includes url single sign on. Thats the only case, nothing else!
Iraj Posted January 7, 2023 Author Posted January 7, 2023 1 hour ago, ioa747 said: $sURLUsername & "{TAB}" & $sURLPassword & "{ENTER}" instead of $sURLUsername{TAB}$sURLPassword{ENTER} Tab & Enter are happening. Just that the actual username & password are not passing.
SOLVE-SMART Posted January 7, 2023 Posted January 7, 2023 Hi @Melba23, is the legality of the thread proofed or not? How long should we wait until we could post suggestions to the user? No pressure, I just don't know how to handle this 😅 . Best regards Sven ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet, 🔗 autoit-webdriver-boilerplate Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
Moderators Melba23 Posted January 8, 2023 Moderators Posted January 8, 2023 SOLVE-SMART, Quote How long should we wait As long as it takes - some of us do have a life away from the forum! 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
Moderators Melba23 Posted January 8, 2023 Moderators Posted January 8, 2023 Iraj, Happy to accept that explanation. The thread is again open to suggestions. 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
Iraj Posted January 8, 2023 Author Posted January 8, 2023 1 hour ago, Melba23 said: Iraj, Happy to accept that explanation. The thread is again open to suggestions. M23 Thanks 👍🏼
SOLVE-SMART Posted January 8, 2023 Posted January 8, 2023 (edited) 2 hours ago, Melba23 said: [...] As long as it takes - some of us do have a life away from the forum! [...] I didn't want to stress you out @Melba23 😔 , it was really just a question of how to behave, not more. Anyway, understood 👍 . Next time I am aware of how to. Best regards Sven Edited January 8, 2023 by SOLVE-SMART ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet, 🔗 autoit-webdriver-boilerplate Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
Solution SOLVE-SMART Posted January 8, 2023 Solution Posted January 8, 2023 (edited) Hi @Iraj, this code would run properly: Opt('MustDeclareVars', 1) Opt('SendKeyDelay', 40) _Login() Func _Login() Local Const $sFilePath = @ScriptDir & '\config.ini' Local Const $hFileOpen = FileOpen($sFilePath) Local Const $sURLUsername = FileReadLine($hFileOpen, 1) Local Const $sURLPassword = FileReadLine($hFileOpen, 2) Local Const $sAutomation = FileReadLine($hFileOpen, 3) FileClose($hFileOpen) ShellExecute('https://www.facebook.com/login.php/') Sleep(3000) Send(Execute($sAutomation)) EndFunc You missed to Execute() the third read line as this is a string which has to be executed before Send(). Line three in config.ini: $sURLUsername & '{TAB}' & $sURLPassword & '{ENTER}' You also should use the suggested ShellExecute() of @ioa747. The AutoIt option SendKeyDelay is for a bit of robustness. Between each keystroke, a short delay is proceeded before the next keystroke happen. But let's be honest, if you really want to do website automation for a company in such a way, I believe this approach will lead to an quick end. You will struggle after the facebook login without using a more robust approach like WebDriver (au3WebDriver, Selenium, WebdriverIO, Nightwatch.js etc.). What should be the next step @Iraj? Do you want to get more into WebDriver? Let us know, there is a great Wiki and much more which would help a lot, am I sure. Best regards Sven Edited January 8, 2023 by SOLVE-SMART ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet, 🔗 autoit-webdriver-boilerplate Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
Iraj Posted January 9, 2023 Author Posted January 9, 2023 On 1/8/2023 at 7:53 PM, SOLVE-SMART said: Hi @Iraj, this code would run properly: Opt('MustDeclareVars', 1) Opt('SendKeyDelay', 40) _Login() Func _Login() Local Const $sFilePath = @ScriptDir & '\config.ini' Local Const $hFileOpen = FileOpen($sFilePath) Local Const $sURLUsername = FileReadLine($hFileOpen, 1) Local Const $sURLPassword = FileReadLine($hFileOpen, 2) Local Const $sAutomation = FileReadLine($hFileOpen, 3) FileClose($hFileOpen) ShellExecute('https://www.facebook.com/login.php/') Sleep(3000) Send(Execute($sAutomation)) EndFunc You missed to Execute() the third read line as this is a string which has to be executed before Send(). Line three in config.ini: $sURLUsername & '{TAB}' & $sURLPassword & '{ENTER}' You also should use the suggested ShellExecute() of @ioa747. The AutoIt option SendKeyDelay is for a bit of robustness. Between each keystroke, a short delay is proceeded before the next keystroke happen. But let's be honest, if you really want to do website automation for a company in such a way, I believe this approach will lead to an quick end. You will struggle after the facebook login without using a more robust approach like WebDriver (au3WebDriver, Selenium, WebdriverIO, Nightwatch.js etc.). What should be the next step @Iraj? Do you want to get more into WebDriver? Let us know, there is a great Wiki and much more which would help a lot, am I sure. Best regards Sven Its working ... Thanks Regarding Webdriver, I was planning to integrate python for identifying the html elements more precisely & go on forward as I have worked on python before. Any other idea will be appreciated...
SOLVE-SMART Posted January 9, 2023 Posted January 9, 2023 Hi @Iraj, good to read: it works 😀 . Regarding Python and WebDriver => you will be focusing on Selenium then, am I right? But I don't understand why you want to do things with AutoIt, like reading values from a file and do a website login, afterwards you will work with Python to do the rest? Why not stay on Python or AutoIt for both tasks? Depending on your experience with one of the languages, I recommend to stay on one of them for browser automation. In case you plan to do more then browser stuff, it would be interesting what exactly to come to an conclusion which language fits the tasks better. Best regards Sven ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet, 🔗 autoit-webdriver-boilerplate Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
seadoggie01 Posted January 9, 2023 Posted January 9, 2023 Since you're dealing with login information, you might consider using a password manager instead of storing the username/password in plain text in a file. I personally use KeePass with AutoIt and have a UDF that I put together to easily use it. See my signature for a link if you're interested SOLVE-SMART 1 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
Iraj Posted January 10, 2023 Author Posted January 10, 2023 (edited) 13 hours ago, SOLVE-SMART said: Hi @Iraj, good to read: it works 😀 . Regarding Python and WebDriver => you will be focusing on Selenium then, am I right? But I don't understand why you want to do things with AutoIt, like reading values from a file and do a website login, afterwards you will work with Python to do the rest? Why not stay on Python or AutoIt for both tasks? Depending on your experience with one of the languages, I recommend to stay on one of them for browser automation. In case you plan to do more then browser stuff, it would be interesting what exactly to come to an conclusion which language fits the tasks better. Best regards Sven My project head wanted python & one open source scripting lang for this. I’ll anyhow use python predominantly. Lets see. If I come to a better solution I’ll keep you updated Edited January 10, 2023 by Iraj
Iraj Posted January 10, 2023 Author Posted January 10, 2023 10 hours ago, seadoggie01 said: Since you're dealing with login information, you might consider using a password manager instead of storing the username/password in plain text in a file. I personally use KeePass with AutoIt and have a UDF that I put together to easily use it. See my signature for a link if you're interested Well I need to check. The issue is not all our clients use KeePass, and we are in similar domain, so ideally we can’t use it. Still I’ll check with my project head if we can integrate it seadoggie01 1
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