Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit } from '@angular/core';
- import { IpcRenderer } from 'electron';
- import { ElectronService } from 'ngx-electron';
- @Component({
- selector: 'app-dashboard',
- templateUrl: './dashboard.component.html',
- styleUrls: ['./dashboard.component.scss']
- })
- export class DashboardComponent implements OnInit {
- ipc: IpcRenderer | undefined | null;
- activeWindowTitle: string | undefined | null;
- constructor(private electronService: ElectronService) { }
- ngOnInit(): void {
- this.getActiveWindow();
- }
- getActiveWindow() {
- if (this.electronService.isElectronApp) {
- this.ipc = this.electronService.ipcRenderer;
- this.ipc.send('get-active-window');
- this.ipc.on('get-active-window-reply', (_event, reply: IActiveWindow) => {
- this.activeWindowTitle = reply.windowName;
- });
- }
- }
- }
- export interface IActiveWindow {
- os: string;
- windowClass: string;
- windowName: string;
- windowDesktop: string;
- windowPid: string;
- windowType: string;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement