123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- # import re
- # from threading import Thread
- from time import sleep
- from threading import Event
- import keyboard as kb
- import pywinctl as gw
- from win32api import GetKeyState
- from win32con import VK_CAPITAL
- # from win32gui import GetWindowText, GetForegroundWindow, GetParent
- # import pyautogui as gui
- # for i in pygui.getWindows():
- # print(i)
- # def windowEnumerationHandler(hwnd, top_windows):
- # top_windows.append((hwnd, GetWindowText(hwnd)))
- # print(EnumWindows(windowEnumerationHandler, None))
- # mentor_ciel_active = Event()
- mentor_user = 'Utilizator: '
- mentor_date = 'DATE'
- CIEL = 'NextUp ERP'
- def main(event):
- '''winmnt_C_LOCK'''
- MENTOR_WINDOWS = {
- 'EditObligatii',
- 'Tranzactii BANCA curente',
- 'Tranzactii BANCA in curs',
- 'Tranzactii CASSA',
- 'Parteneri',
- 'Alege partener',
- 'Intrari',
- 'Intrari din import',
- 'Iesiri',
- ' Articole ',
- ' Nomenclator Articole ',
- ' Pentru Gestiunea ',
- 'Fisa partener',
- 'Localitati',
- 'Justificare avans decont',
- 'Personal',
- ' Nomenclator Gestiuni',
- 'Compensari ',
- 'Conturi bancare',
- 'Alege firma curenta:',
- 'Compensari ',
- 'Alege!'}
- CIEL_WINDOWS = {
- 'Lista societati',
- 'Date societate',
- 'Adaugare - Factura de cumparare',
- 'Adaugare - Factura de cumparare UE',
- 'Adaugare - Factura externa - DVI',
- 'Adaugare - Transfer intre depozite',
- 'Adaugare - Bon de consum',
- 'Adaugare - Registru casa',
- 'Adaugare - Decont trezorerie',
- 'Adaugare - Extras banca',
- 'Adaugare - Intrare in stoc',
- 'Adaugare - Ordin de productie',
- 'Adaugare - Factura de cumparare cu imobilizari',
- 'Modificare - Decont trezorerie',
- 'Filtreaza - Parteneri',
- 'Introducere numere seriale',
- 'Date de identificare reprezentant fiscal/legal/imputernicit',
- 'Adaugare - Factura de vanzare',
- 'vanzare',
- 'Filtreaza'}
- while not event.is_set():
- try:
- # mentor_ciel_active.clear()
- in_activ_win = [mentor_user in gw.getActiveWindowTitle(),
- mentor_date in gw.getActiveWindowTitle(),
- gw.getActiveWindowTitle() in MENTOR_WINDOWS,
- CIEL in gw.getActiveWindowTitle(),
- gw.getActiveWindowTitle() in CIEL_WINDOWS]
- if any(in_activ_win):
- if GetKeyState(VK_CAPITAL) == 0:
- kb.press_and_release('caps lock')
- # mentor_ciel_active.set()
- else:
- if GetKeyState(VK_CAPITAL) == 1:
- kb.press_and_release('caps lock')
- # mentor_ciel_active.clear()
- sleep(0.5)
- # break
- # mentor_ciel_active.wait(timeout=0.5)
- except Exception as exc_: # this was only TypeError
- print(str(exc_))
- pass
- if __name__ == '__main__':
- try:
- event = Event()
- main(event=event)
- except KeyboardInterrupt:
- event.set()
|