Thank you ?
Do you think would be possible to adapt this code for this version too?
So when you click F1 the first saved account will be loaded, if you click F2 will be loaded the second account, and the same thing for F3 and F4.
Now it's not working because the account are saved like this:
0 : idaccount1 : password
1 : idaccount2 : password
instead of :
idaccount1 : password
Do you know how the first index number could be ignored during the login?
def OnKeyDown(self, key):
# A fast method to login by keyboard shortcuts.
# Create a keyboard range enum as tuple from F1 to F4.
dikAvailableList = range(0x3B, 0x3E + 1)
if not key in dikAvailableList:
return
try:
# Creates a file object, which would be utilized to call other support methods associated with it.
# Change old_open method with open if you get error.
file = old_open('user//credentials', 'r')
try:
# Finds the given element in a list and returns its position.
account_index = dikAvailableList.index(key)
# Reads until EOF using readline() and returns a list containing the lines.
account_data = file.readlines().__getitem__(account_index)
# Returns a list of all the words in the string, using str as the separator.
account_data = account_data.split(':')
# Applies a function to all the items in an input list.
account_data = map(lambda item: item.rstrip(), account_data)
# Decode the password.
account_data[-1] = self.decode(self.__ReadSavedPassword(), next(reversed(account_data)))
# Connect to the server by using list [id, pw].
self.Connect(*account_data)
# Raised when a sequence subscript is out of range.
except IndexError:
pass
# A closed file cannot be read or written any more.
file.close()
# Raised when an I/O operation fails for an I/O-related reason, e.g., “file not found” or “disk full”.
except IOError:
return