call.py 725 B

123456789101112131415161718192021222324252627
  1. import sys
  2. import win32com.client,time
  3. tapi = win32com.client.Dispatch("TAPI.TAPI")
  4. tapi.Initialize()
  5. for item in tapi.Addresses: print(item.AddressName)
  6. modemAll = True
  7. modem = "USB"
  8. if len(sys.argv) > 1:
  9. sNumber = sys.argv[1]
  10. else:
  11. exit("Send a phone number to the program")
  12. found = False
  13. modemList = []
  14. for item in tapi.Addresses:
  15. if modemAll or modem in item.AddressName:
  16. found = True
  17. gobjCall = item.CreateCall(sNumber, 1, 0x8)
  18. gobjCall.Connect (False)
  19. if not modemAll:
  20. break
  21. else:
  22. modemList.append(item.AddressName)
  23. if not found:
  24. modemList = str(modemList).strip('[]').replace(',', '\n')
  25. print(f"No modem matched {modem} in\n{modemList}")