in short:

i want to intercept suspend/standby messages on my laptop, but my program doesn't receives all relevant messages.

我想在我的筆記本電腦上截取掛起/備用信息,但是我的程序沒有收到所有相關的信息。

background:

there's a bug in ms-excel on windows xp/2k, which prevents system suspend if a file is opened on a network/usb drive.

windows xp/2k上的ms-excel有一個錯誤,如果在網絡/usb驅動器上打開文件,它可以防止系統掛起。

i'm trying to work-around it programmatically (my toolbox include python, vb6, or command line tools).

我正在嘗試以編程的方式工作(我的工具箱包括python、vb6或命令行工具)。

i know nothing about windows instrumentation :-)

我對windows設備一無所知:-)

i have a sysinternals utility that suspends the system anyhow. i want to hook it to the close-lid event!

我有一個sysinternals工具,不管怎么說,它掛起了系統。我想把它和這個封閉的活動聯系起來!

in long:

The notebook lid close (fujitsu u810) initiate the standby procedure [how?]

筆記本蓋關閉(富士通u810)啟動待機程序[如何?]

The system then send everybody WM_POWERBROADCAST: PBT_APMQUERYSUSPEND (i can trace them using SPYXX.EXE)

然后系統發送每個人WM_POWERBROADCAST: PBT_APMQUERYSUSPEND(我可以使用SPYXX.EXE跟蹤它們)

Every program answers "True", until excel answers "false", and the whole process stops.

每個程序都回答“True”,直到excel回答“false”,整個過程停止。

My questions:

1) my python program doesn't catch neither pbm_apmquerysuspend, nor PBT_APMQUERYSTANDBYFAILED, nor PBT_APMQUERYSUSPENDFAILED: ` ...

1)我的python程序既沒有捕獲pbm_apmquerysuspend,也沒有捕獲PBT_APMQUERYSTANDBYFAILED,也沒有捕獲PBT_APMQUERYSUSPENDFAILED: '…

query = "SELECT * FROM Win32_PowerManagementEvent"

power_watcher = wmi.ExecNotificationQuery ( query )

power_event = power_watcher.NextEvent ()

` it receives only PBT_APMSUSPEND, if standby finally occurs.

如果最終發生待機,它只接收PBT_APMSUSPEND。

Why not - and how do i intercept it?

為什么不呢?我怎么攔截它呢?

2) Is there another way to intercept the standby process?

2)是否有其他方法來攔截備用進程?

in a prefect world, i would set the lid-close event to run a command i choose. in a perfect world, lid-closure is a documented event.

在一個完美的世界里,我會設置關閉事件來運行我選擇的命令。在一個完美的世界里,閉蓋是一個有記錄的事件。

thank you all :-)

謝謝:-)

1 个解决方案

#1

2

I've found an ugly workaround: I wrote an AutoIt script which detects the Excel's error MessageBox, closes it, and runs a sysinternals' utility which forces the computer to standby.

我發現了一個糟糕的解決方案:我編寫了一個AutoIt腳本,它可以檢測Excel的error MessageBox,關閉它,並運行sysinternals的實用程序,該實用程序強制計算機進行備份。

Opt("WinWaitDelay",400)

; -- exact text match, to save LOTS of cup cycles!

Opt("WinTitleMatchMode",3)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

; Opt("WinSearchChildren",1)

dim $title = "Microsoft Excel"

dim $text = "Windows cannot go on standby because Microsoft Office documents or application components are being accessed from the network. You must close the open documents or exit the applications before you can put the computer on standby."

While True

; wait for excel's error msg

WinWait($title, $text)

Run("psshutdown.exe -c -d -accepteula -m mooshmoosh -t 5")

; the annoying msgbox doesn't close without the 'sleep'

Sleep(1000)

; close the annoying modal msgbox!

WinClose($title)

;1 minute delay, save cpu (?)

Sleep(1*60*1000)

WEnd

(this is an optimized version - the first trials were CPU intensive).

now it sits in the system-tray and just works.

(這是一個優化版本——最初的測試是CPU密集型的)。現在它位於系統托盤中,只是工作而已。

the lost messages question is still open. though i realized it has nothing to do with python in the first place.

丟失消息的問題仍然存在。雖然我首先意識到它與python無關。

python windows 消息通讯_如何使用python與windows中的事件/消息掛鈎相关推荐

  1. python windows 消息通讯_在windows下使用python进行串口通讯的方法

    在windows下使用python进行串口通讯的方法 Windows版本下的python并没有内置串口通讯的pyserial的库,所以需要自己下载.参照了网上的教程,有许多用的pip的安装方式,但是试 ...

  2. python编程与下位机通讯_如何使用Python开发串口通讯上位机(一)

    用Python开发串口通讯型上位机,其实并非最优解,本系列更新只为个人学习与总结.如果有C语言底子,嵌入式层面的上位机开发,C++ Builder,C#才是更加好用的利器.1 什么是上位机 从事过嵌入 ...

  3. 用python计算复利计算器_第一章 Python简介

    全览: Python的大部分基本特性:如变量.表达式.控制流.函数.生成器.类和输入\输出: Python3和Python2.6的区别:大多数与打印和I/O有关: ------------------ ...

  4. python安全编码问题_浅谈Python中的编码问题

    对于Python的初学者来说,编码问题相当令人头疼.本文就根据我在学习过程中遇到的问题简单谈一下Python中的编码.首先简单介绍一下几种常见的编码. 一.几种常见的字符编码 ASCII码 ASCII ...

  5. python模块下载过程_常用的python模块及安装方法

    bsddb3:BerkeleyDB的连接组件 Cheetah-1.0:我比较喜欢这个版本的cheetah cherrypy:一个WEB framework ctypes:用来调用动态链接库 DBUti ...

  6. python使用md5加密_如何使用Python构建加密机器人并将其连接到Facebook Messenger

    python使用md5加密 by Paul Pinard 保罗·皮纳德(Paul Pinard) 认识Sato the Cryptobot,他能够从外部API获取任何加密货币的价格! (Meet Sa ...

  7. python指定返回类型_如何在python中指定方法返回类型列表 - python

    假设我有一个类似下面的方法 def validate(self, item:dict, attrs:dict)-> list: 如果我想更具体一点,告诉我我的返回类型是 验证消息? 我应该如何实 ...

  8. python实现数据可视化_使用Matplotib python实现数据可视化

    python实现数据可视化 I Feel: 我觉得: In today's digital world data has become as important as air. Machines &a ...

  9. python爬虫网络中断_如何解决Python爬虫中的网络掉线问题?

    在学校里的时候,除了上课,还有一大幸福的事情,就是用着学校的网线网络.当然玩的时候很开心,就是没事关键词时刻掉链子.时不时地网络掉线让人非常恼火,什么团战在梦游啊,看剧卡住不动了,相信能引起很多小伙伴 ...

最新文章

  1. 如何运用NLP向个性类型客户介绍产品
  2. 【JavaScript吉光片羽】遭遇IE8
  3. 学习Python编程的19个资源
  4. Boost:宏BOOST_NO_RTTI的使用实例
  5. LeetCode 1851. 包含每个查询的最小区间(排序 + 离线查询 + 优先队列)
  6. 2016年百度面试题
  7. 【javascript】简单原型链、借用构造函数
  8. java环境配置:安装jdk和集成开发环境
  9. 高通工具QXDM、QCAT和QPST关系及功能
  10. Godot实用代码1000例
  11. 八爪鱼数据采集器的使用
  12. 当520遇到MicroPython,单身极客狗也能很开“芯”~
  13. DNS基础知识以及golang实现的简单DNS服务器
  14. 动漫,简史早期的日本动画
  15. 辞职的理由,似乎大家都说不是为了钱
  16. resolver error connecting with ssh timed out
  17. 安装openKylin 开源操作系统 (ubuntukylin-22.04-pro-amd64.isowindows版)
  18. uniapp 多语言版本demo in18
  19. 如何解决win10应用商店打不开——错误码0x80131500
  20. Python机器学习(二):决策树(Decision Tree-DTs)

热门文章

  1. HDU2016 数据的交换输出【入门】
  2. Bailian2796 Bailian3681 数字求和【序列处理】
  3. HDU2526 浪漫手机【模拟】
  4. 欢迎使用CSDN-markdown编辑器【转载】
  5. POJ NOI0113-30 1的个数【进制】
  6. CCF NOI1036 进制转换
  7. python 分段拟合(curve fit)
  8. Python 标准库 —— 邮件(email)与邮件服务器(smtplib)
  9. Python typing —— 类型提示(type hint)
  10. Matlab Tricks(十二)—— 矩阵阈值化的实现