在网上找了一些资料用LockWorkStation可以锁屏,想问用哪些代码可以支持不锁屏?
因做功能测试自动化,想让电脑一直处于未锁屏的状态。但公司安全策略:10分钟未操作的情况下自动锁屏,注(不能取消此屏保),在网上找了一些资料用LockWorkStation可以锁屏,想问用哪些代码可以支持不锁屏?也用过模拟键盘操作,加个定时器的方式,但是用Alt键好吗?对自动化会不会有影响?
Wshshell.SendKeys "%"
--------------------编程问答-------------------- 调用mouseevent api模拟一个鼠标的移动。 --------------------编程问答-------------------- mouseevent api这个移动能不能控制移动的距离?
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private Declare Function LockWorkStation Lib "user32.dll" () As Long
Private Const WM_SYSCOMMAND As Long = &H112
Private Const SC_SCREENSAVE As Long = &HF140&
Private Sub Command1_Click()
LockWorkStation
SendMessage Form1.hwnd, WM_SYSCOMMAND, SC_SCREENSAVE, ByVal 0&
End Sub
有木有代码,斑竹 --------------------编程问答--------------------
用getcursorpos获得鼠标位置,然后加上一个偏移,即可控制距离。 --------------------编程问答--------------------
收到,谢谢了 --------------------编程问答-------------------- keydb_event 0,0,0,0 --------------------编程问答-------------------- 从度娘那儿抄了个禁止屏保运行的源码:
Option Explicit--------------------编程问答-------------------- 嘎嘎~其实吧...模拟鼠标和键盘都不是太好的办法,包括什么取消屏保.
Private Const SPI_SETSCREENSAVEACTIVE = 17
Private Const SPI_SETSCREENSAVETIMEOUT = 15
Private Const SPIF_SENDWININICHANGE = &H2
Private Const SPIF_UPDATEINIFILE = &H1
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Long, ByVal fuWinIni As Long) As Long
Private Sub Form_Load()
Call SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, 0, SPIF_UPDATEINIFILE + SPIF_SENDWININICHANGE)
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, 0, SPIF_UPDATEINIFILE + SPIF_SENDWININICHANGE)
End Sub
别人就要屏保锁屏,你不能恶意的给别人取消了,模拟鼠标或键盘,如果别人在播放视频或写代码(或打字)怎么办?
别用那些恶心又易做图易做图的方式...易做图哦...
1.要么运行你的程序你取消屏保,退出的时候你再还原屏保设置.
2.要么你就拦截系统消息...
@嗷嗷叫的老马 是不是啊?
补充:VB , API