簡體   English   中英

在Gnome或KDE中以編程方式在桌面上移動應用程序窗口

[英]Move application windows on desktop programmatically in Gnome or KDE

我想使用c ++程序在桌面上重新定位應用程序窗口。 我該怎么做呢,我需要解決這兩種情況。

  1. 當我有想要移動的應用程序的源。

  2. 通過編寫外部程序來移動其他應用程序的窗口。

外部Bash腳本:

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

有關此內容的更多信息,請使用xdotool searchxdotool windowmoveman 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;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM