winmnt_C_LOCK.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # import re
  2. # from threading import Thread
  3. from time import sleep
  4. from threading import Event
  5. import keyboard as kb
  6. import pywinctl as gw
  7. from win32api import GetKeyState
  8. from win32con import VK_CAPITAL
  9. # from win32gui import GetWindowText, GetForegroundWindow, GetParent
  10. # import pyautogui as gui
  11. # for i in pygui.getWindows():
  12. # print(i)
  13. # def windowEnumerationHandler(hwnd, top_windows):
  14. # top_windows.append((hwnd, GetWindowText(hwnd)))
  15. # print(EnumWindows(windowEnumerationHandler, None))
  16. # mentor_ciel_active = Event()
  17. mentor_user = 'Utilizator: '
  18. mentor_date = 'DATE'
  19. CIEL = 'NextUp ERP'
  20. def main(event):
  21. '''winmnt_C_LOCK'''
  22. MENTOR_WINDOWS = {
  23. 'EditObligatii',
  24. 'Tranzactii BANCA curente',
  25. 'Tranzactii BANCA in curs',
  26. 'Tranzactii CASSA',
  27. 'Parteneri',
  28. 'Alege partener',
  29. 'Intrari',
  30. 'Intrari din import',
  31. 'Iesiri',
  32. ' Articole ',
  33. ' Nomenclator Articole ',
  34. ' Pentru Gestiunea ',
  35. 'Fisa partener',
  36. 'Localitati',
  37. 'Justificare avans decont',
  38. 'Personal',
  39. ' Nomenclator Gestiuni',
  40. 'Compensari ',
  41. 'Conturi bancare',
  42. 'Alege firma curenta:',
  43. 'Compensari ',
  44. 'Alege!'}
  45. CIEL_WINDOWS = {
  46. 'Lista societati',
  47. 'Date societate',
  48. 'Adaugare - Factura de cumparare',
  49. 'Adaugare - Factura de cumparare UE',
  50. 'Adaugare - Factura externa - DVI',
  51. 'Adaugare - Transfer intre depozite',
  52. 'Adaugare - Bon de consum',
  53. 'Adaugare - Registru casa',
  54. 'Adaugare - Decont trezorerie',
  55. 'Adaugare - Extras banca',
  56. 'Adaugare - Intrare in stoc',
  57. 'Adaugare - Ordin de productie',
  58. 'Adaugare - Factura de cumparare cu imobilizari',
  59. 'Modificare - Decont trezorerie',
  60. 'Filtreaza - Parteneri',
  61. 'Introducere numere seriale',
  62. 'Date de identificare reprezentant fiscal/legal/imputernicit',
  63. 'Adaugare - Factura de vanzare',
  64. 'vanzare',
  65. 'Filtreaza'}
  66. while not event.is_set():
  67. try:
  68. # mentor_ciel_active.clear()
  69. in_activ_win = [mentor_user in gw.getActiveWindowTitle(),
  70. mentor_date in gw.getActiveWindowTitle(),
  71. gw.getActiveWindowTitle() in MENTOR_WINDOWS,
  72. CIEL in gw.getActiveWindowTitle(),
  73. gw.getActiveWindowTitle() in CIEL_WINDOWS]
  74. if any(in_activ_win):
  75. if GetKeyState(VK_CAPITAL) == 0:
  76. kb.press_and_release('caps lock')
  77. # mentor_ciel_active.set()
  78. else:
  79. if GetKeyState(VK_CAPITAL) == 1:
  80. kb.press_and_release('caps lock')
  81. # mentor_ciel_active.clear()
  82. sleep(0.5)
  83. # break
  84. # mentor_ciel_active.wait(timeout=0.5)
  85. except Exception as exc_: # this was only TypeError
  86. print(str(exc_))
  87. pass
  88. if __name__ == '__main__':
  89. try:
  90. event = Event()
  91. main(event=event)
  92. except KeyboardInterrupt:
  93. event.set()