相关文章推荐
谦虚好学的黑框眼镜  ·  pyspark ...·  1 年前    · 
买醉的拖把  ·  DataTable.PrimaryKey ...·  1 年前    · 
乖乖的莲藕  ·  Git多项目管理 - 简书·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have obtained the handle of a window I want to target, with win32gui library in Python

How do I close the window?

I have the following code, the second line did what I intended to do

but the last line seems to be wrong.

handle = win32gui.FindWindow(None, r'Notepad++')
win32gui.SetForegroundWindow(handle)
win32gui.CloseWindow(handle)

I also want to know if I just want to close the window, is the second line necessary?

Besides that, I notice a minor thing, and I am curious about it:

If I try

win32gui.CloseWindow(handle)

in Python shell, I get something like:

2500276L

but if I try

handle = win32gui.CloseWindow(handle)
print handle

then I get

2500276

does the 'L' in the end make any difference?

Thanks for your attention!!

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.