有什么方法可以将我的自定义应用程序与其他桌面应用程序绑定,即我可以在启动其他应用程序时强制启动应用程序。
示例 - 我可以在打开adobe reader时启动谷歌浏览器,即将它们绑定在一起
每当我打开我的adobe阅读器时,就像adobe阅读器一样,google chrome也应该启动
这可能吗?我已经制作了一个应用程序,应该在我启动我的adobe reader时启动
提前致谢
答案 0 :(得分:0)
@echo off
start "" "C:\Program Files\test\test.exe"
start "" "C:\Program Files\test\test.exe"
此脚本将立即运行这两个应用程序(您可以添加更多)。只需将这些代码复制到.bat文件中并更改路径,然后创建桌面快捷方式。
答案 1 :(得分:0)
使用Python标准库的os.startfile('path/to/reader/shortcut') # start the reader program
os.startfile('path/to/chrome/shortcut') # start the chrome program
模块,使用脚本打开这两个程序只是一件小事:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import java.util.Scanner;
public class GUI_Test{
private JPanel window;
private JPanel settings;
private JFrame main;
private JFrame optionsScreen;
private JLabel headerLabel;
private JLabel optionsLabel;
private JLabel resolution;
private JComboBox resolutonOption;
String[] resolutionOptions = new String[] {
"640x480", "1024x768", "1366x768", "1600x900", "1920x1080"
};
int tempResX, tempResY, res;
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
int resX = gd.getDisplayMode().getWidth();
int resY = gd.getDisplayMode().getHeight();
public GUI_Test(){
prepareGUI();
}
public static void main(String[] args) {
GUI_Test GUI = new GUI_Test();
GUI.showGUIDemo();
}
private void showGUIDemo() {
JButton exit = new JButton("EXIT");
JButton options = new JButton("OPTIONS");
JButton back = new JButton("BACK");
JButton apply = new JButton("APPLY");
JComboBox <String> resolutionOption = new JComboBox<>(resolutionOptions);
exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
options.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
optionsScreen.setVisible(true);
settings.setVisible(true);
window.setVisible(false);
main.setVisible(false);
}
});
back.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
optionsScreen.setVisible(false);
settings.setVisible(false);
window.setVisible(true);
main.setVisible(true);
}
});
resolutionOption.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
res = resolutionOption.getSelectedIndex();
switch (res) {
case 0:
tempResX = 640;
tempResY = 480;
break;
case 1:
tempResX = 1024;
tempResY = 768;
break;
case 2:
tempResX = 1366;
tempResY = 768;
break;
case 3:
tempResX = 1600;
tempResY = 900;
break;
case 4:
tempResX = 1920;
tempResY = 1080;
break;
}
}
});
apply.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
resX = tempResX;
resY = tempResY;
}
});
window.add(exit);
window.add(options);
settings.add(back);
settings.add(resolutionOption);
settings.add(apply);
main.setVisible(true);
}
private void prepareGUI() {
main = new JFrame("Basic GUI");
main.setSize(resX, resY);
main.setLayout(new GridLayout(3,1));
main.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent windowEvent) {
System.exit(0);
}
});
optionsScreen = new JFrame("Options");
optionsScreen.setSize(resX, resY);
optionsScreen.setLayout(new GridLayout(4,1));
optionsScreen.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent windowEvent) {
System.exit(0);
}
});
headerLabel = new JLabel("AGame", JLabel.CENTER);
headerLabel.setSize(100, 50);
optionsLabel = new JLabel("Settings", JLabel.CENTER);
optionsLabel.setSize(100, 50);
resolution = new JLabel("Resolution", JLabel.CENTER);
window = new JPanel();
window.setLayout(new FlowLayout());
settings = new JPanel();
settings.setLayout(new FlowLayout());
main.add(headerLabel);
main.add(window);
main.setVisible(true);
optionsScreen.add(optionsLabel);
optionsScreen.add(settings);
optionsScreen.add(resolution);
optionsScreen.setVisible(false);
settings.setVisible(false);
}
}