1XDOTOOL(1) XDOTOOL(1)
2
3
4
6 xdotool - command-line X11 automation tool
7
9 xdotool cmd args...
10
11 Notation: Some documentation uses [window] to denote an optional window
12 argument. This case means that the argument, if not present, will
13 default to "%1". See "WINDOW STACK" for what "%1" means.
14
16 xdotool lets you programatically (or manually) simulate keyboard input
17 and mouse activity, move and resize windows, etc. It does this using
18 X11's XTEST extension and other Xlib functions.
19
20 There is some support for Extended Window Manager Hints (aka EWMH or
21 NetWM). See the "EXTENDED WINDOW MANAGER HINTS" section for more
22 information.
23
25 key [options] keystroke [keystroke ...]
26 Options:
27
28 --window window
29 Send keystrokes to a specific window id. You can use "WINDOW
30 STACK" references like "%1" and "%@" here. If there is a window
31 stack, then "%1" is the default, otherwise the current window
32 is used.
33
34 See also: "SENDEVENT NOTES" and "WINDOW STACK"
35
36 --clearmodifiers
37 Clear modifiers before sending keystrokes. See CLEARMODIFIERS
38 below.
39
40 --delay milliseconds
41 Delay between keystrokes. Default is 12ms.
42
43 Type a given keystroke. Examples being "alt+r", "Control_L+J",
44 "ctrl+alt+n", "BackSpace".
45
46 Generally, any valid X Keysym string will work. Multiple keys are
47 separated by '+'. Aliases exist for "alt", "ctrl", "shift",
48 "super", and "meta" which all map to Foo_L, such as Alt_L and
49 Control_L, etc.
50
51 In cases where your keyboard doesn't actually have the key you want
52 to type, xdotool will automatically find an unused keycode and use
53 that to type the key.
54
55 With respect to "COMMAND CHAINING", this command consumes the
56 remainder of the arguments or until a new xdotool command is seen,
57 because no xdotool commands are valid keystrokes.
58
59 Example: Send the keystroke "F2"
60 xdotool key F2
61
62 Example: Send 'a' with an accent over it (not on english keyboards,
63 but still works with xdotool)
64 xdotool key Aacute
65
66 Example: Send ctrl+l and then BackSpace as separate keystrokes:
67 xdotool key ctrl+l BackSpace
68
69 Example: Send ctrl+c to all windows matching title 'gdb' (See
70 "COMMAND CHAINING")
71 xdotool search --name gdb key ctrl+c
72
73 keydown [options] keystroke
74 Same as above, except only keydown (press) events are sent.
75
76 keyup keystroke
77 Same as above, except only keyup (release) events are sent.
78
79 type [options] something to type
80 Options:
81
82 --window windowid
83 Send keystrokes to a specific window id. See "SENDEVENT NOTES"
84 below. The default, if no window is given, depends on the
85 window stack. If the window stack is empty the current window
86 is typed at using XTEST. Otherwise, the default is "%1" (see
87 "WINDOW STACK").
88
89 --delay milliseconds
90 Delay between keystrokes. Default is 12ms.
91
92 --clearmodifiers
93 Clear modifiers before sending keystrokes. See CLEARMODIFIERS
94 below.
95
96 Types as if you had typed it. Supports newlines and tabs (ASCII
97 newline and tab). Each keystroke is separated by a delay given by
98 the --delay option.
99
100 With respect to "COMMAND CHAINING", this command consumes the
101 remainder of the arguments and types them. That is, no commands can
102 chain after 'type'.
103
104 Example: to type 'Hello world!' you would do:
105 xdotool type 'Hello world!'
106
108 mousemove [options] x y OR 'restore'
109 Move the mouse to the specific X and Y coordinates on the screen.
110
111 You can move the mouse to the previous location if you specify
112 'restore' instead of an X and Y coordinate. Restoring only works if
113 you have moved previously in this same command invocation. Further,
114 it does not work with the --window option.
115
116 For example, to click the top-left corner of the screen and move
117 the mouse to the original position before you moved it, use this:
118 xdotool mousemove 0 0 click 1 mousemove restore
119
120 --window WINDOW
121 Specify a window to move relative to. Coordinates 0,0 are at
122 the top left of the window you choose.
123
124 "WINDOW STACK" references are valid here, such as %1 and %@.
125 Though, using %@ probably doesn't make sense.
126
127 --screen SCREEN
128 Move the mouse to the specified screen to move to. This is only
129 useful if you have multiple screens and ARE NOT using Xinerama.
130
131 The default is the current screen. If you specify --window, the
132 --screen flag is ignored.
133
134 --polar
135 Use polar coordinates. This makes 'x' an angle (in degrees,
136 0-360, etc) and 'y' the distance.
137
138 Rotation starts at 'up' (0 degrees) and rotates clockwise: 90 =
139 right, 180 = down, 270 = left.
140
141 The origin defaults to the center of the current screen. If you
142 specify a --window, then the origin is the center of that
143 window.
144
145 --clearmodifiers
146 See CLEARMODIFIERS
147
148 --sync
149 After sending the mouse move request, wait until the mouse is
150 actually moved. If no movement is necessary, we will not wait.
151 This is useful for scripts that depend on actions being
152 completed before moving on.
153
154 Note: We wait until the mouse moves at all, not necessarily
155 that it actually reaches your intended destination. Some
156 applications lock the mouse cursor to certain regions of the
157 screen, so waiting for any movement is better in the general
158 case than waiting for a specific target.
159
160 mousemove_relative [options] x y
161 Move the mouse x,y pixels relative to the current position of the
162 mouse cursor.
163
164 --polar
165 Use polar coordinates. This makes 'x' an angle (in degrees,
166 0-360, etc) and 'y' the distance.
167
168 Rotation starts at 'up' (0 degrees) and rotates clockwise: 90 =
169 right, 180 = down, 270 = left.
170
171 --sync
172 After sending the mouse move request, wait until the mouse is
173 actually moved. If no movement is necessary, we will not wait.
174 This is useful for scripts that depend on actions being
175 completed before moving on.
176
177 Note that we wait until the mouse moves at all, not necessarily
178 that it actually reaches your intended destination. Some
179 applications lock the mouse cursor to certain regions of the
180 screen, so waiting for any movement is better in the general
181 case than waiting for a specific target.
182
183 --clearmodifiers
184 See CLEARMODIFIERS
185
186 click [options] button
187 Send a click, that is, a mousedown followed by mouseup for the
188 given button with a short delay between the two (currently 12ms).
189
190 Buttons generally map this way: Left mouse is 1, middle is 2, right
191 is 3, wheel up is 4, wheel down is 5.
192
193 --clearmodifiers
194 Clear modifiers before clicking. See CLEARMODIFIERS below.
195
196 --repeat REPEAT
197 Specify how many times to click. Default is 1. For a double-
198 click, use '--repeat 2'
199
200 --delay MILLISECONDS
201 Specify how long, in milliseconds, to delay between clicks.
202 This option is not used if the --repeat flag is set to 1
203 (default).
204
205 --window WINDOW
206 Specify a window to send a click to. See "SENDEVENT NOTES"
207 below for caveats. Uses the current mouse position when
208 generating the event.
209
210 The default, if no window is given, depends on the window
211 stack. If the window stack is empty the current window is typed
212 at using XTEST. Otherwise, the default is "%1" (see "WINDOW
213 STACK").
214
215 mousedown [options] button
216 Same as click, except only a mouse down is sent.
217
218 mouseup [options] button
219 Same as click, except only a mouse up is sent.
220
221 getmouselocation [--shell]
222 Outputs the x, y, screen, and window id of the mouse cursor. Screen
223 numbers will be nonzero if you have multiple monitors and are not
224 using Xinerama.
225
226 --shell
227 This makes getmouselocation output shell data you can eval.
228 Example:
229
230 % xdotool getmouselocation --shell
231 X=880
232 Y=443
233 SCREEN=0
234 WINDOW=16777250
235
236 % eval $(xdotool getmouselocation --shell)
237 % echo $X,$Y
238 714,324
239
240 behave_screen_edge [options] where command ...
241 Bind an action to events when the mouse hits the screen edge or
242 corner.
243
244 Options are:
245
246 --delay MILLISECONDS
247 Delay in milliseconds before running the command. This allows
248 you to require a given edge or corner to be held for a short
249 period before your command will run. If you leave the edge or
250 corner before the delay expires then the time will reset.
251
252 --quiesce MILLISECONDS
253 Delay in milliseconds before the next command will run. This
254 helps prevent accidentally running your command extra times;
255 especially useful if you have a very short --delay (like the
256 default of 0).
257
258 Event timeline
259
260 * Mouse hits an edge or corner.
261 * If delay is nonzero, the mouse must stay in this edge or corner until delay time expires.
262 * If still in the edge/corner, trigger.
263 * If quiesce is nonzero, then there is a cool-down period where the next
264 trigger cannot occur
265
266 Valid 'where' values are:
267
268 left
269 top-left
270 top
271 top-right
272 right
273 bottom-left
274 bottom
275 bottom-right
276
277 Examples:
278 # Activate google-chrome when you move the mouse to the bottom-
279 left corner:
280 xdotool behave_screen_edge bottom-left \
281 search --class google-chrome windowactivate
282
283 # Go to the next workspace (right). Known to work in GNOME (metacity and compiz)
284 xdotool behave_screen_edge --delay 500 bottom-right key XF86Forward
285
286 # Activate firefox and do a web search in a new tab for text in your clipboard
287 xdotool behave_screen_edge --delay 1000 top-left \
288 search --classname Navigator \
289 windowactivate --sync key --delay 250 ctrl+t ctrl+k ctrl+v Return
290
292 search [options] pattern
293 Search for windows with titles, names, or classes with a regular
294 expression pattern. The output is line-delimited list of X window
295 identifiers. If you are using "COMMAND CHAINING", the search
296 command will only write window ids to stdout if it is the last (or
297 only) command in the chain; otherwise, it is silent.
298
299 The result is saved to the window stack for future chained
300 commands. See "WINDOW STACK" and "COMMAND CHAINING" for details.
301
302 The default options are "--name --class --classname" (unless you
303 specify one one or more of --name --class or --classname).
304
305 The options available are:
306
307 --class
308 Match against the window class.
309
310 --classname
311 Match against the window classname.
312
313 --maxdepth N
314 Set recursion/child search depth. Default is -1, meaning
315 infinite. 0 means no depth, only root windows will be searched.
316 If you only want toplevel windows, set maxdepth of 1 (or 2,
317 depending on how your window manager does decorations).
318
319 --name
320 Match against the window name. This is the same string that is
321 displayed in the window titlebar.
322
323 --onlyvisible
324 Show only visible windows in the results. This means ones with
325 map state IsViewable.
326
327 --pid PID
328 Match windows that belong to a specific process id. This may
329 not work for some X applications that do not set this metadata
330 on its windows.
331
332 --screen N
333 Select windows only on a specific screen. Default is to search
334 all screens. Only meaningful if you have multiple displays and
335 are not using Xinerama.
336
337 --desktop N
338 Only match windows on a certain desktop. 'N' is a number. The
339 default is to search all desktops.
340
341 --limit N
342 Stop searching after finding N matching windows. Specifying a
343 limit will help speed up your search if you only want a few
344 results.
345
346 The default is no search limit (which is equivalent to '--limit
347 0')
348
349 --title
350 DEPRECATED. See --name.
351
352 --all
353 Require that all conditions be met. For example:
354
355 xdotool search --all --pid 1424 --name "Hello World"
356
357 This will match only windows that have "Hello World" as a name
358 and are owned by pid 1424.
359
360 --any
361 Match windows that match any condition (logically, 'or'). This
362 is on by default. For example:
363
364 xdotool search --any --pid 1424 --name "Hello World"
365
366 This will match any windows owned by pid 1424 or windows with
367 name "Hello World"
368
369 --sync
370 Block until there are results. This is useful when you are
371 launching an application want want to wait until the
372 application window is visible. For example:
373
374 google-chrome &
375 xdotool search --sync --onlyvisible --class "google-chrome"
376
377 selectwindow
378 Get the window id (for a client) by clicking on it. Useful for
379 having scripts query you humans for what window to act on. For
380 example, killing a window by clicking on it:
381
382 xdotool selectwindow windowkill
383
384 behave window action command ...
385 Bind an action to an event on a window. This lets you run
386 additional xdotool commands whenever a matched event occurs.
387
388 The command run as a result of the behavior is run with %1 being
389 the window that was acted upon. Examples follow after the event
390 list.
391
392 The following are valid events:
393
394 mouse-enter
395 Fires when the mouse enters a window. This is similar to 'mouse
396 over' events in javascript, if that helps.
397
398 mouse-leave
399 Fires when the mouse leaves a window. This is the opposite of
400 'mouse-enter'
401
402 mouse-click
403 Fires when the mouse is clicked. Specifically, when the mouse
404 button is released.
405
406 focus
407 Fires when the window gets input focus.
408
409 blur
410 Fires when the window loses focus.
411
412 Examples:
413
414 # Print the cursor location whenever the mouse enters a currently-visible
415 # window:
416 xdotool search --onlyvisible . behave %@ mouse-enter getmouselocation
417
418 # Print the window title and pid whenever an xterm gets focus
419 xdotool search --class xterm behave %@ focus getwindowname getwindowpid
420
421 # Emulate focus-follows-mouse
422 xdotool search . behave %@ mouse-enter windowfocus
423
424 getwindowpid [window]
425 Output the PID owning a given window. This requires effort from the
426 application owning a window and may not work for all windows. This
427 uses _NET_WM_PID property of the window. See "EXTENDED WINDOW
428 MANAGER HINTS" below for more information.
429
430 If no window is given, the default is '%1'. If no windows are on
431 the stack, then this is an error. See "WINDOW STACK" for more
432 details.
433
434 Example: Find the PID for all xterms:
435 xdotool search --class xterm getwindowpid %@
436
437 getwindowname [window]
438 Output the name of a given window, also known as the title. This is
439 the text displayed in the window's titlebar by your window manager.
440
441 If no window is given, the default is '%1'. If no windows are on
442 the stack, then this is an error. See "WINDOW STACK" for more
443 details.
444
445 getwindowgeometry [options] [window]
446 Output the geometry (location and position) of a window. The values
447 include: x, y, width, height, and screen number.
448
449 --shell
450 Output values suitable for 'eval' in a shell.
451
452 getwindowfocus [-f]
453 Prints the window id of the currently focused window. Saves the
454 result to the window stack. See "WINDOW STACK" for more details.
455
456 If the current window has no WM_CLASS property, we assume it is not
457 a normal top-level window and traverse up the parents until we find
458 a window with a WM_CLASS set and return that window id.
459
460 If you really want the window currently having focus and don't care
461 if it has a WM_CLASS setting, then use 'getwindowfocus -f'
462
463 windowsize [options] [window] width height
464 Set the window size of the given window. If no window is given, %1
465 is the default. See "WINDOW STACK" and "COMMAND CHAINING" for more
466 details.
467
468 Percentages are valid for width and height. They are relative to
469 the geometry of the screen the window is on. For example, to make a
470 window the full width of the screen, but half height:
471
472 xdotool windowsize I<window> 100% 50%
473
474 Percentages are valid with --usehints and still mean pixel-width
475 relative to the screen size.
476
477 The options available are:
478
479 --usehints
480 Use window sizing hints (when available) to set width and
481 height. This is useful on terminals for setting the size based
482 on row/column of text rather than pixels.
483
484 --sync
485 After sending the window size request, wait until the window is
486 actually resized. If no change is necessary, we will not wait.
487 This is useful for scripts that depend on actions being
488 completed before moving on.
489
490 Note: Because many window managers may ignore or alter the
491 original resize request, we will wait until the size changes
492 from its original size, not necessary to the requested size.
493
494 Example: To set a terminal to be 80x24 characters, you would use:
495 xdotool windowsize --usehints some_windowid 80 24
496
497 windowmove [options] [window] x y
498 Move the window to the given position. If no window is given, %1 is
499 the default. See "WINDOW STACK" and "COMMAND CHAINING" for more
500 details.
501
502 If the given x coordinate is literally 'x', then the window's
503 current x position will be unchanged. The same applies for 'y'.
504
505 Examples:
506
507 xdotool getactivewindow windowmove 100 100 # Moves to 100,100
508 xdotool getactivewindow windowmove x 100 # Moves to x,100
509 xdotool getactivewindow windowmove 100 y # Moves to 100,y
510 xdotool getactivewindow windowmove 100 y # Moves to 100,y
511
512 --sync
513 After sending the window move request, wait until the window is
514 actually moved. If no movement is necessary, we will not wait.
515 This is useful for scripts that depend on actions being
516 completed before moving on.
517
518 --relative
519 Make movement relative to the current window position.
520
521 windowfocus [options] [window]
522 Focus a window. If no window is given, %1 is the default. See
523 "WINDOW STACK" and "COMMAND CHAINING" for more details.
524
525 Uses XSetInputFocus which may be ignored by some window managers or
526 programs.
527
528 --sync
529 After sending the window focus request, wait until the window
530 is actually focused. This is useful for scripts that depend on
531 actions being completed before moving on.
532
533 windowmap [options] [window]
534 Map a window. In X11 terminology, mapping a window means making it
535 visible on the screen. If no window is given, %1 is the default.
536 See "WINDOW STACK" and "COMMAND CHAINING" for more details.
537
538 --sync
539 After requesting the window map, wait until the window is
540 actually mapped (visible). This is useful for scripts that
541 depend on actions being completed before moving on.
542
543 windowminimize [options] [window]
544 Minimize a window. In X11 terminology, this is called 'iconify.'
545 If no window is given, %1 is the default. See "WINDOW STACK" and
546 "COMMAND CHAINING" for more details.
547
548 --sync
549 After requesting the window minimize, wait until the window is
550 actually minimized. This is useful for scripts that depend on
551 actions being completed before moving on.
552
553 windowraise [window_id=%1]
554 Raise the window to the top of the stack. This may not work on all
555 window managers. If no window is given, %1 is the default. See
556 "WINDOW STACK" and "COMMAND CHAINING" for more details.
557
558 windowreparent [source_window] destination_window
559 Reparent a window. This moves the source_window to be a child
560 window of destination_window. If no source is given, %1 is the
561 default. "WINDOW STACK" window references (like %1) are valid for
562 both source_window and destination_window See "WINDOW STACK" and
563 "COMMAND CHAINING" for more details.
564
565 windowkill [window]
566 Kill a window. This action will destroy the window and kill the
567 client controlling it. If no window is given, %1 is the default.
568 See WINDOW STACK and "COMMAND CHAINING" for more details.
569
570 windowunmap [options] [window_id=%1]
571 Unmap a window, making it no longer appear on your screen. If no
572 window is given, %1 is the default. See "WINDOW STACK" and "COMMAND
573 CHAINING" for more details.
574
575 --sync
576 After requesting the window unmap, wait until the window is
577 actually unmapped (hidden). This is useful for scripts that
578 depend on actions being completed before moving on.
579
580 set_window [options] [windowid=%1]
581 Set properties about a window. If no window is given, %1 is the
582 default. See "WINDOW STACK" and "COMMAND CHAINING" for more
583 details.
584
585 Options:
586
587 --name newname
588 Set window WM_NAME (the window title, usually)
589
590 --icon-name newiconname
591 Set window WM_ICON_NAME (the window title when minimized,
592 usually)
593
594 --role newrole
595 Set window WM_WINDOW_ROLE
596
597 --classname newclassname
598 Set window class name (not to be confused with window class)
599
600 --class newclass
601 Set window class (not to be confused with window class name)
602
603 --overrideredirect value
604 Set window's override_redirect value. This value is a hint to
605 the window manager for whether or not it should be managed. If
606 the redirect value is 0, then the window manager will draw
607 borders and treat this window normally. If the value is 1, the
608 window manager will ignore this window.
609
610 If you change this value, your window manager may not notice
611 the change until the window is mapped again, so you may want to
612 issue 'windowunmap' and 'windowmap' to make the window manager
613 take note.
614
616 These commands follow the EWMH standard. See the section "EXTENDED
617 WINDOW MANAGER HINTS" for more information.
618
619 windowactivate [options] [window]
620 Activate the window. This command is different from windowfocus: if
621 the window is on another desktop, we will switch to that desktop.
622 It also uses a different method for bringing the window up. I
623 recommend trying this command before using windowfocus, as it will
624 work on more window managers.
625
626 If no window is given, %1 is the default. See "WINDOW STACK" and
627 "COMMAND CHAINING" for more details.
628
629 --sync
630 After sending the window activation, wait until the window is
631 actually activated. This is useful for scripts that depend on
632 actions being completed before moving on.
633
634 getactivewindow
635 Output the current active window. This command is often more
636 reliable than getwindowfocus. The result is saved to the window
637 stack. See "WINDOW STACK" for more details.
638
639 set_num_desktops number
640 Changes the number of desktops or workspaces.
641
642 get_num_desktops
643 Output the current number of desktops.
644
645 get_desktop_viewport [--shell]
646 Report the current viewport's position. If --shell is given, the
647 output is friendly to shell eval.
648
649 Viewports are sometimes used instead of 'virtual desktops' on some
650 window managers. A viewport is simply a view on a very large
651 desktop area.
652
653 set_desktop_viewport x y
654 Move the viewport to the given position. Not all requests will be
655 obeyed - some windowmangers only obey requests that align to
656 workspace boundaries, such as the screen size.
657
658 For example, if your screen is 1280x800, you can move to the 2nd
659 workspace by doing:
660 xdotool set_desktop_viewport 1280 0
661
662 set_desktop [options] desktop_number
663 Change the current view to the specified desktop.
664
665 --relative
666 Use relative movements instead of absolute. This lets you move
667 relative to the current desktop.
668
669 get_desktop
670 Output the current desktop in view.
671
672 set_desktop_for_window [window] desktop_number
673 Move a window to a different desktop. If no window is given, %1 is
674 the default. See "WINDOW STACK" and "COMMAND CHAINING" for more
675 details.
676
677 get_desktop_for_window [window]
678 Output the desktop currently containing the given window. Move a
679 window to a different desktop. If no window is given, %1 is the
680 default. See WINDOW STACK and "COMMAND CHAINING" for more details.
681
683 exec [options] command [...]
684 Execute a program. This is often useful when combined with
685 behave_screen_edge to do things like locking your screen.
686
687 Options:
688
689 --sync
690 Block until the child process exits. The child process exit
691 status is then passed to the parent process (xdotool) which
692 copies it.
693
694 Examples:
695 # Lock the screen when the mouse sits in the top-right corner
696 xdotool behave_screen_edge --delay 1000 top-right \
697 exec gnome-screensaver-command --lock
698 # Substitute 'xscreensaver-command -lock' if you use that program.
699
700 # The following will fail to move the mouse because we use '--sync' and
701 # /bin/false exits nonzero:
702 xdotool exec --sync /bin/false mousemove 0 0
703
704 # This succeeds, though, since we do not use --sync on the exec command.
705 xdotool exec /bin/false mousemove 0 0
706
707 sleep seconds
708 Sleep for a specified period. Fractions of seconds (like 1.3, or
709 0.4) are valid, here.
710
712 xdotool can read a list of commands via stdin or a file if you want. A
713 script will fail when any command fails.
714
715 Truthfully, 'script' mode isn't fully fleshed out and may fall below
716 your expectations. If you have suggestions, please email the list or
717 file a bug (See CONTACT).
718
719 Scripts can use positional arguments (Represented by $1, $2, ...) and
720 environment variables (like $HOME or $WINDOWID). Quoting arguments
721 should work as expected.
722
723 Scripts are processed for parameter and environment variable expansion
724 and then run as if you had invoked xdotool with the entire script on
725 one line (using COMMAND CHAINING).
726
727 · Read commands from a file:
728
729 xdotool filename
730
731 · Read commands from stdin:
732
733 xdotool -
734
735 · Read commands from a redirected file
736
737 xdotool - < myfile
738
739 You can also write scripts that only execute xdotool. Example:
740
741 #!/usr/local/bin/xdotool
742 search --onlyvisible --classname $1
743
744 windowsize %@ $2 $3
745 windowraise %@
746
747 windowmove %1 0 0
748 windowmove %2 $2 0
749 windowmove %3 0 $3
750 windowmove %4 $2 $3
751
752 This script will take all windows matched by the classname query given
753 by arg1 ($1) and sizes/moves them into a 2x2 grid with windows sized by
754 the 2nd and 3rd parameters.
755
756 Here's an example usage:
757
758 % ./myscript xterm 600 400
759
760 Running it like this will take 4 visible xterms, raise them, and move
761 them into a 2x2 tile grid with each window 600x400 pixels in size.
762
764 Any command taking the --clearmodifiers flag will attempt to clear any
765 active input modifiers during the command and restore them afterwards.
766
767 For example, if you were to run this command:
768 xdotool key a
769
770 The result would be 'a' or 'A' depending on whether or not you were
771 holding the shift key on your keyboard. Often it is undesirable to have
772 any modifiers active, so you can tell xdotool to clear any active
773 modifiers.
774
775 The order of operations if you hold shift while running 'xdotool key
776 --clearmodifiers a' is this:
777
778 1. Query for all active modifiers (finds shift, in this case)
779 2. Try to clear shift by sending 'key up' for the shift key
780 3. Runs normal 'xdotool key a'
781 4. Restore shift key by sending 'key down' for shift
782
783 The --clearmodifiers flag can currently clear of the following:
784
785 · any key in your active keymap that has a modifier associated with
786 it. (See xmodmap(1)'s 'xmodmap -pm' output)
787
788 · mouse buttons (1, 2, 3, 4, and 5)
789
790 · caps lock
791
793 If you are trying to send key input to a specific window, and it does
794 not appear to be working, then it's likely your application is ignoring
795 the events xdotool is generating. This is fairly common.
796
797 Sending keystrokes to a specific window uses a different API than
798 simply typing to the active window. If you specify 'xdotool type
799 --window 12345 hello' xdotool will generate key events and send them
800 directly to window 12345. However, X11 servers will set a special flag
801 on all events generated in this way (see XEvent.xany.send_event in
802 X11's manual). Many programs observe this flag and reject these events.
803
804 It is important to note that for key and mouse events, we only use
805 XSendEvent when a specific window is targeted. Otherwise, we use XTEST.
806
807 Some programs can be configured to accept events even if they are
808 generated by xdotool. Seek the documentation of your application for
809 help.
810
811 Specific application notes (from the author's testing): * Firefox 3
812 seems to ignore all input when it does not have focus. * xterm can be
813 configured while running with ctrl+leftclick, 'Allow SendEvents' *
814 gnome-terminal appears to accept generated input by default.
815
817 Certain commands (search, getactivewindow, getwindowfocus) will find
818 windows for you. These results generally printed to stdout, but they
819 are also saved to memory for future use during the lifetime of the
820 xdotool process. See "COMMAND CHAINING" for more information.
821
822 The only modifications support for the window stack are to replace it.
823 That is, two of two sequential searches, only the last one's results
824 will be the window stack.
825
827 xdotool supports running multiple commands on a single invocation.
828 Generally, you'll start with a search command (see "WINDOW STACK") and
829 then perform a set of actions on those results.
830
831 To query the window stack, you can use special notation "%N" where N is
832 a number or the '@' symbol. If %N is given, the Nth window will be
833 selected from the window stack. Generally you will only want the first
834 window or all windows. Note that the order of windows in the window
835 stack corresponds to the window stacking order, i.e. the bottom-most
836 window will be reported first (see XQueryTree(3)). Thus the order of
837 the windows in the window stack may not be consistent across
838 invocations.
839
840 The notation described above is used as the "window" argument for any
841 given command.
842
843 For example, to resize all xterms to 80x24:
844
845 xdotool search --class xterm -- windowsize --usehints %@ 80 24
846
847 Resize move the current window:
848
849 xdotool getactivewindow windowmove 0 0
850
851 In all cases, the default window argument, if omitted, will default to
852 "%1". It is obviously an error if you omit the window argument and the
853 window stack is empty. If you try to use the window stack and it is
854 empty, it is also an error.
855
856 To activate the first firefox window found:
857
858 xdotool search --class firefox windowactivate
859
860 These would error:
861
862 xdotool windowactivate
863 xdotool windowactivate %1
864 xdotool windowactivate %@
865
866 When xdotool exits, the current window stack is lost.
867
868 Additinally, commands that modify the "WINDOW STACK" will not print the
869 results if they are not the last command. For example:
870
871 # Output the active window:
872 % xdotool getactivewindow
873 20971533
874
875 # Output the pid of the active window, but not the active window id:
876 % xdotool getactivewindow getwindowpid
877 4686
878
880 The following pieces of the EWMH standard are supported:
881
882 _NET_SUPPORTED
883 Asks the window manager what is supported
884
885 _NET_CURRENT_DESKTOP
886 Query and set the current desktop. Support for this enables these
887 commands: "set_desktop", "get_desktop".
888
889 _NET_WM_DESKTOP
890 Query and set what desktop a window is living in. Support for this
891 enables these commands: "set_desktop_for_window",
892 "get_desktop_for_window".
893
894 _NET_ACTIVE_WINDOW
895 Allows you to query and set the active window by asking the window
896 manager to bring it forward. Support for this enables these
897 commands: "windowactivate", "getactivewindow".
898
899 _NET_WM_PID
900 This feature is application dependent, not window-manager
901 dependent. Query the PID owning a given window. Support for this
902 enables these commands: "getwindowpid".
903
905 xdotool (and libxdo) will try to function under all circumstances.
906 However, there may be some cases where functionality is not provided by
907 your X server or by your window manager. In these cases, xdotool will
908 try to detect and tell you if an action requires a feature not
909 currently supported by your system.
910
911 For window-manager specific features, see "EXTENDED WINDOW MANAGER
912 HINTS".
913
914 XTEST
915 If your X server does not support XTEST, then some typing and mouse
916 movement features may not work. Specifically, typing and mouse
917 actions that act on the "current window" (window 0 in libxdo) are
918 unlikely to work.
919
920 In most cases, XTEST is a feature you can enable on your X server
921 if it is not enabled by default.
922
923 You can see the list of supported X extensions by typing 'xdpyinfo'
924 and looking the text 'number of extensions: ...'
925
927 Typing unusual symbols under non-us keybindings is known to
928 occasionally send the wrong character.
929
931 xprop(1), xwininfo(1),
932
933 Project site: <http://www.semicomplete.com/projects/xdotool>
934
935 Source code and Issues: <https://github.com/jordansissel/xdotool>
936
937 EWMH specification:
938 <http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html>
939
941 Please send questions to xdotool-users@googlegroups.com. File bugs and
942 feature requests at the following URL:
943
944 <https://github.com/jordansissel/xdotool/issues>
945
946 Alternately, if you prefer email, feel free to file bugs by emailing
947 the list. What works for you :)
948
950 xdotool was written by Jordan Sissel.
951
952 This manual page was written originally by Daniel Kahn Gillmor
953 <dkg@fifthhorseman.net> for the Debian project (but may be used by
954 others). It is maintained by Jordan Sissel.
955
956 Patches, ideas, and other contributions by many, nice folks. See the
957 CHANGELIST file for who provided what.
958
959
960
961 2019-07-27 XDOTOOL(1)