{"id":2224,"date":"2026-08-03T15:18:09","date_gmt":"2026-08-03T07:18:09","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2224"},"modified":"2026-03-28T11:22:14","modified_gmt":"2026-03-28T11:22:14","slug":"how-to-use-applicationwindowsforpens-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationwindowsforpens-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.WindowsForPens in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>Application.WindowsForPens<\/code> property in the Excel object model is a legacy property primarily used to indicate whether the system is configured for pen-based input, such as with a stylus or tablet. In the context of xlwings, a powerful Python library for automating Excel, this property can be accessed to check the pen input settings of the Excel application. While its practical use in modern automation scripts is limited, it can be relevant for applications that need to adapt their interface or behavior based on the input device type.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Functionality:<\/strong><br>This read-only property returns a Boolean value (<code>True<\/code> or <code>False<\/code>). A return value of <code>True<\/code> signifies that the Excel application is running on a system that is set up for pen input (e.g., Windows is configured to use a tablet or touch screen with pen support). A value of <code>False<\/code> indicates the system is not configured for such input. It can be used to conditionally enable or disable certain features in a macro or script that are optimized for pen interaction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax in xlwings:<\/strong><br>In xlwings, you access this property through the <code>app<\/code> object, which represents the Excel Application. The syntax is straightforward:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>app.api.WindowsForPens<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here, <code>app<\/code> is your xlwings <code>App<\/code> instance. The <code>.api<\/code> attribute provides direct access to the underlying Excel object model, allowing you to call the native <code>WindowsForPens<\/code> property. This property does not take any parameters.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Code Example:<\/strong><br>The following xlwings code demonstrates how to check the <code>WindowsForPens<\/code> property and print the result. This example assumes you have an Excel instance running.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Connect to the active Excel application\napp = xw.apps.active\n\n# Access the WindowsForPens property via the .api attribute\nis_pen_enabled = app.api.WindowsForPens\n\n# Output the result\nif is_pen_enabled:\n    print(\"The system is configured for pen input.\")\nelse:\n    print(\"The system is not configured for pen input.\")\n\n# Alternatively, you can directly print the Boolean value\nprint(f\"WindowsForPens value: {is_pen_enabled}\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The `Application.WindowsForPens` property in the Excel object model is a legacy property primarily u&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-2224","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/comments?post=2224"}],"version-history":[{"count":1,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2224\/revisions"}],"predecessor-version":[{"id":3399,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2224\/revisions\/3399"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}