Author Topic: TeamViewer ID and Pass Manager  (Read 959 times)

0 Members and 1 Guest are viewing this topic.

Offline Pyromaniac

  • /dev/null
  • *
  • Posts: 19
  • Cookies: 3
    • View Profile
TeamViewer ID and Pass Manager
« on: October 15, 2015, 09:40:46 pm »
Thought I share something from my projects. So this is just a simple program launch teamviewer from subprocess call. Since my free teamviewer account keeps getting error message "Commercial use suspected" just nuked the whole thing and started using this :)

Code: (python) [Select]
#!/usr/bin/python

import wx
import wx.xrc
import subprocess
import platform
import os

class Py_Frame ( wx.Frame ):
   
    # Initialize the Frame
    def __init__( self, parent ):
        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"TeamViewer ID Manager", pos = wx.DefaultPosition, size = wx.Size( 303,72 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )

        self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )

        bSizer1 = wx.BoxSizer( wx.VERTICAL )

        bSizer2 = wx.BoxSizer( wx.HORIZONTAL )
       
        # Read the Config file which contain connection informations.
        ph_file = open("Py_Config.ini")
        ph_content = ph_file.read().strip()
        ph_file.close()

        # Initialize the connection names into a list.
        ph_nodes = ph_content.split("\n")
        ph_array = [ x.split(" ") for x in ph_nodes ]
        ph_name = [ x[0] for x in ph_array ]


        self.ph_arr = ph_array

        self.m_comboBox2 = wx.ComboBox( self, wx.ID_ANY, u"Desktop Names", wx.DefaultPosition, wx.DefaultSize, ph_name, 0 )
        bSizer2.Add( self.m_comboBox2, 1, wx.ALL, 5 )

        self.m_button1 = wx.Button( self, wx.ID_ANY, u"Launch", wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer2.Add( self.m_button1, 0, wx.ALL, 5 )


        bSizer1.Add( bSizer2, 1, wx.EXPAND, 5 )


        self.SetSizer( bSizer1 )
        self.Layout()

        self.Centre( wx.BOTH )

        # Connect Events
        self.m_button1.Bind( wx.EVT_BUTTON, self.Py_LaunchClick )

    def __del__( self ):
        pass

    # Button click event handler.
    def Py_LaunchClick( self, event ):
        ph_selected = self.m_comboBox2.GetSelection()
        if (ph_selected == -1):
            dlg = wx.MessageDialog( None, "You Didn't select the PC.", "No Selection", wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
            dlg.Destroy()
        else:
            if platform.platform().startswith("Win"):
                prog_32 = os.environ["ProgramW6432"].replace("\\","/")
                prog_64 = os.environ["ProgramFiles(x86)"].replace("\\","/")
                tv_path = "/TeamViewer/TeamViewer.exe"
                if os.path.exists(prog_32 + tv_path):
                    subprocess.call(prog_32 + tv_path +" -i " + self.ph_arr[ph_selected][1] + " --Password " + self.ph_arr[ph_selected][2])
                elif os.path.exists(prog_64 + tv_path):
                    subprocess.call(prog_64 + tv_path +" -i " + self.ph_arr[ph_selected][1] + " --Password " + self.ph_arr[ph_selected][2])
                else:
                    dlg = wx.MessageDialog( None, "Couldn't detect TeamViewer'.", "Path Error", wx.OK | wx.ICON_INFORMATION)
                    dlg.ShowModal()
                    dlg.Destroy()
            else:
                subprocess.call("teamviewer -i " + self.ph_arr[ph_selected][1] + " --Password " + self.ph_arr[ph_selected][2])




if __name__ == "__main__":
    app = wx.App()
    frame = Py_Frame(None)
    frame.Show()
    app.MainLoop()



Py_Config.ini looks like this. Connection name, ID and Password
Code: [Select]
JoePC 111111111 password
BobPC 222222222 password

Hope this help some people out as well.
« Last Edit: October 16, 2015, 08:49:05 pm by Pyromaniac »

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: TeamViewer ID and Pass Manager
« Reply #1 on: October 15, 2015, 10:33:00 pm »
Oh this is cool! do you have it on github or somewhere with all dependencies?

Offline Pyromaniac

  • /dev/null
  • *
  • Posts: 19
  • Cookies: 3
    • View Profile
Re: TeamViewer ID and Pass Manager
« Reply #2 on: October 15, 2015, 10:58:18 pm »
Oh this is cool! do you have it on github or somewhere with all dependencies?
Thanks for the edit! Didn't know about that. I dont have it on github becuase it was only a few line of code. The only thing that this depend on is wxpython3 for gui and teamviewer program installed on the system. Sorry forgot to mention that above. Tested on both window and linux. (Should work on mac too but I don't own one so can't test lol). If people are interested then I can put it on github and extend features.

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: TeamViewer ID and Pass Manager
« Reply #3 on: October 16, 2015, 07:38:08 am »
One thing tho:
subprocess.call("C:/Program Files (x86)/TeamViewer/TeamViewer.exe -i "
Don't EVER hardcode system paths, use environmental variables instead. Also the path you coded only exists on x64 windows, on x86 there's only "Program Files". You might wanna fix it :)

Offline Pyromaniac

  • /dev/null
  • *
  • Posts: 19
  • Cookies: 3
    • View Profile
Re: TeamViewer ID and Pass Manager
« Reply #4 on: October 16, 2015, 08:48:34 pm »
One thing tho:
subprocess.call("C:/Program Files (x86)/TeamViewer/TeamViewer.exe -i "
Don't EVER hardcode system paths, use environmental variables instead. Also the path you coded only exists on x64 windows, on x86 there's only "Program Files". You might wanna fix it :)
You are right  :'( I forgot to handle that properly and updated the code. I updated the code.