在Gnome或KDE中以编程方式在桌面上移动应用程序窗口 [英] Move application windows on desktop programmatically in Gnome or KDE

查看:121
本文介绍了在Gnome或KDE中以编程方式在桌面上移动应用程序窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用c ++程序在桌面上重新放置应用程序窗口. 我应该如何去做,在两种情况下都需要解决方案.

I want to reposition a application window on the desktop using a c++ program . How should i go about doing that , i need solution for both situations .

  1. 当我拥有要移动的应用程序的源代码时.

  1. When i have the source of the application which want to move .

通过编写外部程序来移动其他应用程序的窗口.

Move windows of other application by Writing an external program.

推荐答案

外部Bash脚本:

xdotool   search --onlyvisible --class dolphin   windowmove 13 37
#                                         ^                 ^   ^
#                                   window class            X & Y coordinates

有关此的更多信息,请使用xdotool searchxdotool windowmoveman xdotool.

For more information about this, use xdotool search, xdotool windowmove and man xdotool.

C ++示例:

#include <cstdlib>
#include <string>
#include <sstream>

using namespace std;

int main()
{
    string cls="dolphin";
    int x=13, y=37;

    stringstream s;
    s<<"xdotool search --onlyvisible --class "<<cls<<" windowmove "<<x<<" "<<y;

    system(s.str().c_str());

    return 0;
}

最低限度的例子:

#include <stdlib.h>

int main()
{
    system("xdotool search --onlyvisible --class dolphin windowmove 13 37");
    return 0;
}

这篇关于在Gnome或KDE中以编程方式在桌面上移动应用程序窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆