question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to get window title in WSL2

See original GitHub issue

Short summary

X Error of failed request: BadWindow (invalid Window parameter) Major opcode of failed request: 20 (X_GetProperty) Resource id in failed request: 0x1 Serial number of failed request: 8 Current serial number in output stream: 8

Desired execution environment / tested on

  • Virtual machine
  • Docker container
  • Dev/Host system
  • WSL2

Detailed question

I setup WSL2 on Windows 10 with Ubuntu 20.04 I know we need to do some extra setup to be able to access Windows related things from WSL2, so I setup VcXsrv to be able to access the X-Window. And I’m got success to run the sample code on the README to be able to control mouse from WSL2.

Now I’m try to access the window title and get failed. But I don’t have idea how to solve it.

const { getActiveWindow } = require('@nut-tree/nut-js')

getActiveWindow()
  .then(x => {
    console.log(x)
    return x.title
  })

Window {
  nativeActions: NativeAdapter {
    clipboard: default_1 {},
    keyboard: KeyboardAction {},
    mouse: MouseAction {},
    window: WindowAction {}
  },
  windowHandle: 1
}
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  20 (X_GetProperty)
  Resource id in failed request:  0x1
  Serial number of failed request:  8
  Current serial number in output stream:  8

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
s1hofmanncommented, Oct 10, 2021

To be honest, I have no experience with WSL and therefore no knowledge about how things work in detail. Would’ve to spend time to learn more about it first

1reaction
reaz1995commented, Feb 13, 2022

@QimatLuo WSL stands for Windows Subsystem Linux, so every script/program executed via wsl is executed inside linux. You have to set displayer to get a view of Linux Desktop. If you execute script/program inside wsl nothing will hapen on Windows Dektop. 1st solution, set up displayer and execute every scripts via wsl, or 2nd solution leave wsl and do everything on Windows or 3rd bridge between wsl and windows but better chose previous options.

(your pointer was keep clicking because its shared between windows and wsl, but the screen isn’t shared, so postion of mouse will stays same, hope thats helpfull)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Windows Subsystem for Linux | Microsoft Learn
Provides detailed information about common errors and issues people run into while running Linux on the Windows Subsystem for Linux.
Read more >
Opening Firefox in WSL2 without Windows default title bar
In order to remove the standard window title bar, you normally have a 'Title Bar' option in 'Customize Toolbar' settings. But unfortunately, ...
Read more >
Change Title of Bash on Ubuntu on Windows - Super User
If you are using WSL you can edit ~/.bashrc file in your distro. This also works for Windows Terminal at least in version...
Read more >
Running graphical Linux desktop applications from WSL 2 ...
Just tried it with WSL2 and that works. Of course the local firewall has to allow an access from that subnet.
Read more >
Developing in WSL - Visual Studio Code
Install Visual Studio Code on the Windows side (not in WSL). ... If you have not already, install and setup Docker Desktop's WSL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found