Jump to content

Passing parameters using Send() from File


Go to solution Solved by SOLVE-SMART,

Recommended Posts

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:

image.thumb.png.db254a33072bd0a597c8a5457c097458.png

 

Where am I going wrong? Any suggestions or assistance will be grateful. 

Edited by Iraj
other
Link to post
Share on other sites
  • Iraj changed the title to Passing parameters using Send() from File

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 by ioa747
Link to post
Share on other sites
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

Link to post
Share on other sites
  • Moderators

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.

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to post
Share on other sites
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! :)

Link to post
Share on other sites
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.

Link to post
Share on other sites

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

Stay innovative!

Spoiler

🌍 Au3Forums

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔍 Forum search

🔮 Me on GitHub

💬 Opinion about new forum sub category

 📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to post
Share on other sites
  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to post
Share on other sites
  • Moderators

Iraj,

Happy to accept that explanation. The thread is again open to suggestions.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to post
Share on other sites
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 by SOLVE-SMART

Stay innovative!

Spoiler

🌍 Au3Forums

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔍 Forum search

🔮 Me on GitHub

💬 Opinion about new forum sub category

 📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to post
Share on other sites
  • Solution
Posted (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 by SOLVE-SMART

Stay innovative!

Spoiler

🌍 Au3Forums

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔍 Forum search

🔮 Me on GitHub

💬 Opinion about new forum sub category

 📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to post
Share on other sites
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...

Link to post
Share on other sites

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

Stay innovative!

Spoiler

🌍 Au3Forums

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔍 Forum search

🔮 Me on GitHub

💬 Opinion about new forum sub category

 📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to post
Share on other sites

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 :)

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 functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager

Link to post
Share on other sites
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 by Iraj
Link to post
Share on other sites
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

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By abberration
      Software Installer
      Version: 2.0
      It's been been a long year, but I finally got some time to rework this project. I re-wrote everything from scratch because the old version was getting too complicated with so many options and sub-menus. This new version is much easier to use and I have been testing for a few days and it seems very stable.
      For those who are new to this software, it helps you install software silently/unattended. This new version tries to determine the silent switch automatically. You can also re-organize the order in which the software installs by dragging & dropping them in the listview. It now supports creating profiles and checks for missing software (and automatically unchecks them, so it does not attempt to install non-existent software). One feature I included was because I have seen several people on Youtube talk about disliking bright screens at night. So, now you can choose from a few color theme (half of them are dark). I dabbled a bit more into GDI+ to draw a few things and show my logo with a transparent background (hint: I'm not good at GDI+).
      Under the Help menu, you will find a User Guide, which goes through most of it's features. I included a new icon if you want to use when you compile the script (in the Assets > Misc folder).
      If you have questions, comments or suggestions, all are welcome. Hope you enjoy!
      Here it is in action:

       
      Software_Installer_2.0.zip
    • By rcmaehl
      A UDF to connect and control Five9 on the Local Network via it's provided HTTP API
       
      THIS UDF IS STILL IN TESTING
       
      Current Features:
      Agent Ready
      * Contains most functions needed to control Agent Status  
      PLANNED Features:
      Heavyweight
      * Control most Five9 API functions
      * Full Control over own Status as well as Supervisor functionality
        Helpful Premade Examples Files
      * Examples for almost every function
      * Premade CUI and GUI clients
        Ready for all users, beginner and up
      * Detailed Error Reporting to help pin-point problems
      * Thorough parameter checking to prevent accidental script crashes  
      Support:
      Support for this UDF can be obtained in my Discord Server
    • By rcmaehl
      A UDF to connect and control Cisco Finesse on the Local Network via it's provided HTTP API
       
      Current Features:
      Heavyweight
      * Large feature set, containing most Finesse Desktop API functions  
      PLANNED Features:
      Heavyweight
      * Control over own Status as well as Supervisor functionality
        Helpful Premade Examples Files
      * Examples for almost every function
      * Premade CUI and GUI clients 
        Ready for all users, beginner and up
      * Detailed Error Reporting to help pin-point problems
      * Thorough parameter checking to prevent accidental script crashes  
      Support:
      Support for this UDF can be obtained in my Discord Server
    • By WindIt
      Hi, 
      I have a set of excel docs 1& 2
      1) In Excel 1 i have a fixed column called dimensionId that contains list of dimensionid's with in between empty cells.
      Here, For each dimesionId, i need to check corresponding columns of L,M,N ,O(senior, mid, junior, student) & check If they contain letter Y (Open excel 2) and if empty ignore,check next.
      I need to loop through the entire column of dimensionId one by one, please help me proceed with the logic.
      2) If letter Y exists, open excel 2 and check if same dimesionId exists in column A.
      New to autoit excel automation, Help me with logic to execute this.
      #include <Excel.au3>
      Global $oExcel = _Excel_Open()
      Global $oWorkbook = _Excel_BookOpen($oExcel, "D:\yta\Trial concept dimensions list.xlsx")
      Local $read1 = _Excel_RangeRead ($oWorkbook,Default,"C3")
      MsgBox(0,"",$read1)
      Attached exce 1 doc.
       
       
      exl1.xlsx exl2.xlsx
×
×
  • Create New...