Member Avatar for Member #531174

Hey guys,

I want to make a Python program which I will use to automate certain tasks like opening TweetDeck and Skype everytime I boot up my laptop.

The problem is, I know how to open the programs(using subprocess.call), but I don't know how to pass the user ID and password. Can anybody help me?

Thanks a lot!

Dani AI

Generated

Short summary and practical plan that builds on replies already posted:

Many desktop clients do not accept username/password on the command line, so trying to pass credentials directly to subprocess.call usually fails. The safest, most reliable choices are: let the app remember credentials (as suggested), use an official API/token-based login where available (preferred), or—only if neither is possible—automate the GUI to type credentials after launch. Copying a shortcut into the Startup folder (as showed) works, but for more control use Task Scheduler and set the task to run "At logon" with "Run only when user is logged on" so the UI can be interacted with. Windows services (see ) are not suitable for interactive GUI logins because services run in a non-interactive session.

Secure storage + small examples:
Use the OS credential store (Python keyring) rather than embedding plaintext credentials. Example pattern:

import keyring

# store once from a secure prompt
keyring.set_password("tweetdeck", "myuser", "s3cret")

# retrieve when needed
pw = keyring.get_password("tweetdeck", "myuser")

GUI automation fallback:
When an API/token is not available, launch the app then automate typing. This is fragile—add waits, image checks, and retry logic.

import subprocess, time, keyring, pyautogui

subprocess.Popen(["C:\\Path\\To\\Client.exe"])
time.sleep(6)           # wait for login window
pyautogui.write("myuser")
pyautogui.press("tab")
pyautogui.write(keyring.get_password("tweetdeck","myuser"))
pyautogui.press("enter")

Troubleshooting and cautions:

  • Prefer APIs/OAuth tokens; many web services disallow automated credential entry.
  • Never keep plaintext passwords in source control; use keyring or Windows Credential Manager.
  • Increase delays, use pyautogui.locateOnScreen or pywinauto for more accurate targeting.
  • Break work into small experiments (as advised) and test each step locally before automating startup (as urged about showing effort).

This gives a secure, testable path: check for an API or "remember me" first, use OS credential storage, and only simulate the UI when no other programmatic option exists.

Recommended Answers

All 9 Replies

A simple thing to do would be to have skype remember your login information and connect every time it starts up. You could then launch it from whereever you chose - startup (msconfig) or using ur own script.

If you dont want to do that but want to know how to actually pass the username and password i suggest you try exploring the command line options for skype. As far as i recall, there aren't any options to pass login info. Try looking up a book (try flazx.com) called "skype hacks"

Another approach could be the use of win32com libraries in python. These libraries provide a way for programs to interact with GUI widgets in other programs that are running (eg. you could actually write a program to click the ok button of some dialog box on the screen). I don't know how these libraries will work with the widgets skype uses.

I have just one question.. why would u wanna go through all that trouble for a simple task like this

Member Avatar for Member #531174

I just thought I would start off with the basics, and then implement some where else, like in make programs for my friends which starts Thunderbird on boot up, or TweetDeck on boot up, or heck, both!

And thanks for the link and mentioning Win32 module, I will surely look into it.

Member Avatar for Member #531174

Also, how can I make a program to open on startup(any other way than dragging and dropping the program in the Startup group in the Start menu?)

Member Avatar for Member #531174

Anybody? Please reply! Please please! :|

Try looking into MS Windows' services. You could set your program as a service and then have it run automatically on start-up. You may need to look into running Python scripts as services; here's an example.

Member Avatar for Member #531174

Don't keep bumping on your thread.
No one is free enough to help you if you don't show effort.
I have see many thread started by you stating "How do I do this" without any efforts.

Learn to ask question the smart way : Read this page http://www.catb.org/~esr/faqs/smart-questions.html

Also, read the guidelines mentioned on this thread http://www.daniweb.com/forums/thread202628.html

Since you are a very experienced poster, I am showing some respect.

And, if you don't have a solution to my question, please don't clutter my thread by posting unnecessary replies!

import platform, shutil

a = platform.release() #  retrieves Windows release version

def vistamove():
    src = "your.file" # The name and directory of your file
    dst = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup" # Where you want it to go
    shutil.move(src, dst) # Perform the moving action

def xpmove():
    src = "your.file"
    dst = "C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup"
    shutil.move(src, dst)

if a == "Vista":
    vistamove() 
elif a == "XP":
    xpmove()

This code checks the Windows release (XP or Vista only), and then copies the file to the All Users startup. If you want it for only specific users, just change it as necessary. Hope this helped.

This is done because the startup folder is placed in different areas on each OS.

Dude, you're asking a complicated question. (Also saw that you mentioned threading in another thread)

Not to discourage you, but taking on large projects that you don't fully understand usually end badly, because the code you spend so much time on turns out to be badly written and impossible to maintain or make changes. My advice: Plot out the bigger project, figure out the concepts you have to learn and write separate projects around those concepts. Then you can apply what you've learned towards the larger project.

Also: Begging for replies and asking people not to post is a bit contradictory, no? ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.