标签: systray

如何在 Java 中执行特定于操作系统的通知?

我不是一名职业程序员(我所拥有的任何 Java 知识都来自 Hard Knocks 学院)。请原谅我提出的愚蠢问题,并妥善回答。

我正在开发的一个 Java 应用程序使用了非常有缺陷的与平台无关的通知(例如文件已成功下载时)。我想使用平台感知通​​知。在 Linux 上发出通知的代码非常简单:

import org.gnome.gtk.Gtk;
import org.gnome.notify.Notify;
import org.gnome.notify.Notification;

public class HelloWorld
{
    public static void main(String[] args) {
        Gtk.init(args);
        Notify.init("Hello world");
        Notification Hello = new Notification("Hello world!", "This is an example notification.", "dialog-information");
        Hello.show();
    }
}
Run Code Online (Sandbox Code Playgroud)

在 Mac 上,它有点复杂,但仍然可行:

interface NsUserNotificationsBridge extends Library {
    NsUserNotificationsBridge instance = (NsUserNotificationsBridge)
            Native.loadLibrary("/usr/local/lib/NsUserNotificationsBridge.dylib", NsUserNotificationsBridge.class);

    public int sendNotification(String title, String subtitle, String text, int timeoffset);
}
Run Code Online (Sandbox Code Playgroud)

它需要从这个 github 存储库获取 dylib:https://github.com/petesh/OSxNotificationCenter

Windows方式是这样的:

import java.awt.*;
import java.awt.TrayIcon.MessageType; …
Run Code Online (Sandbox Code Playgroud)

java notifications systray platform-specific

4
推荐指数
1
解决办法
1410
查看次数

如何退出在系统托盘中运行的 powershell 脚本?

我想通过用鼠标左键单击文本“退出”来退出此系统托盘程序。当我悬停时,鼠标会显示一个旋转的蓝色图标,并且单击不会执行任何操作。剧本有什么问题?

# a systray program, that should be exited (but it doesn't)
# 2023-03-18


$iconPath = "H:\Dropbox\400 - Scriptprogrammierung\Powershell\Taskleiste mit Wochentag\icons\ico\Logo.ico" # icon path
Write-Host -ForegroundColor Yellow $iconPath
$tooltip = "This is a text."

# NotifyIcon-object
$notifyIcon = New-Object System.Windows.Forms.NotifyIcon
$notifyIcon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($iconPath)
$notifyIcon.Text = $tooltip

########################
# Here seems to be the problem...
$contextMenu = New-Object System.Windows.Forms.ContextMenuStrip
$menuItemExit = New-Object System.Windows.Forms.ToolStripMenuItem
$menuItemExit.Text = "Quit."
$contextMenu.Items.Add($menuItemExit)
$notifyIcon.ContextMenuStrip = $contextMenu
$menuItemExit.add_Click({ $notifyIcon.Dispose(); exit })
########################

# Show icon in systray
$notifyIcon.Visible …
Run Code Online (Sandbox Code Playgroud)

powershell systray click exit winforms

4
推荐指数
1
解决办法
795
查看次数

最小化任何程序到系统托盘

嘿,我正在尝试制作一个程序,将程序最小化到系统托盘而不是通常最小化它.这可能吗?我一直在寻找谷歌,但无法找到任何东西.

c# system-tray systray

3
推荐指数
1
解决办法
1397
查看次数

Delphi应用程序表单显示而不是在启动时隐藏

我有一个程序,它不会启动最小化,并在dekstop上显示一个非常小的窗口.

图片:http://i.imgur.com/j8xus.jpg

码:

程序:

program Project4;

uses
  Forms,
  Unit4 in 'Unit4.pas' {Form4};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := false;
  Application.ShowMainForm:=false;
  Application.CreateForm(TForm4, Form4);
  Application.Run;
end.
Run Code Online (Sandbox Code Playgroud)

单元:

unit Unit4;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, AppEvnts, ExtCtrls, Menus;

type
  TForm4 = class(TForm)
    TrayIcon1: TTrayIcon;
    ApplicationEvents1: TApplicationEvents;
    PopupMenu1: TPopupMenu;
    Exit1: TMenuItem;
    procedure TrayIcon1DblClick(Sender: TObject);
    procedure ApplicationEvents1Minimize(Sender: TObject);
    procedure ApplicationEvents1Restore(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure Exit1Click(Sender: TObject);
  private
    { Private …
Run Code Online (Sandbox Code Playgroud)

forms delphi systray hide

3
推荐指数
1
解决办法
3448
查看次数

气球没有出现NotifyIcon.ShowBalloonTip

我遇到了一些我认为很容易的问题...我无法让我的NotifyIcon显示气球提示.基本代码是:

public void ShowSystrayBubble(string msg, int ms)
{
  sysTrayIcon.Visible = true;
  sysTrayIcon.ShowBalloonTip(20, "Title", "Text", ToolTipIcon.None);
}
Run Code Online (Sandbox Code Playgroud)

执行此代码时没有任何反应.我读到超时arg可能是几秒或几毫秒,不能说,所以我试过两个都没有用.

我正在使用WinXP,.NET 3.5.

.net c# systray notifyicon

2
推荐指数
1
解决办法
1万
查看次数

QT如何检测系统区域以创建系统弹出窗口

我需要创建/设计QT系统弹出窗口,我正在考虑创建源自QDialog的自定义窗口,所以它看起来比普通的"信息,警告,关键样式"更好
我的问题是如何才能检测到的位置桌面系统,所以如何给弹出窗口提供系统弹出窗口
的外观和感觉

qt systray popupwindow

2
推荐指数
1
解决办法
958
查看次数

Delphi:最小化应用程序到系统托盘

我想最小化一个Delphi应用程序到系统托盘而不是任务栏.

必要的步骤似乎如下:

  1. 创建应该在系统托盘中显示的图标.
  2. 当用户单击[ - ]以最小化应用程序时,请执行以下操作:
    1. 隐藏表单.
    2. 将图标(步骤#1)添加到系统托盘.
    3. 隐藏/删除任务栏中的应用程序条目.
  3. 当用户双击系统托盘中的应用程序图标时,请执行以下操作:
    1. 显示表格.
    2. 再次取消应用程序的最小化并将其置于最前面.
    3. 如果"WindowState"是"WS_Minimized"设置为"WS_Normal".
    4. 隐藏/删除系统托盘中的应用程序图标.
  4. 当用户终止应用程序时,请执行以下操作:
    1. 隐藏/删除系统托盘中的应用程序图标.

而已.对?

如何在Delphi中实现这一点?

我发现了以下代码,但我不知道为什么会这样.它不遵循我上面描述的步骤......

unit uMinimizeToTray;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ShellApi;

const WM_NOTIFYICON = WM_USER+333; 

type
  TMinimizeToTray = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure CMClickIcon(var msg: TMessage); message WM_NOTIFYICON;
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  MinimizeToTray: TMinimizeToTray;

implementation

{$R *.dfm}

procedure TMinimizeToTray.CMClickIcon(var msg: TMessage);
begin
  if msg.lparam = …
Run Code Online (Sandbox Code Playgroud)

windows delphi taskbar systray

2
推荐指数
1
解决办法
1万
查看次数