Advertisement
Guest User

Untitled

a guest
Dec 10th, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. import { Component, OnInit } from '@angular/core';
  2. import { IpcRenderer } from 'electron';
  3. import { ElectronService } from 'ngx-electron';
  4.  
  5. @Component({
  6. selector: 'app-dashboard',
  7. templateUrl: './dashboard.component.html',
  8. styleUrls: ['./dashboard.component.scss']
  9. })
  10. export class DashboardComponent implements OnInit {
  11. ipc: IpcRenderer | undefined | null;
  12. activeWindowTitle: string | undefined | null;
  13.  
  14. constructor(private electronService: ElectronService) { }
  15.  
  16. ngOnInit(): void {
  17. this.getActiveWindow();
  18. }
  19.  
  20. getActiveWindow() {
  21. if (this.electronService.isElectronApp) {
  22. this.ipc = this.electronService.ipcRenderer;
  23. this.ipc.send('get-active-window');
  24. this.ipc.on('get-active-window-reply', (_event, reply: IActiveWindow) => {
  25. this.activeWindowTitle = reply.windowName;
  26. });
  27. }
  28. }
  29. }
  30.  
  31. export interface IActiveWindow {
  32. os: string;
  33. windowClass: string;
  34. windowName: string;
  35. windowDesktop: string;
  36. windowPid: string;
  37. windowType: string;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement