写一个定时弹窗提醒工作的bat脚本
时间: 2023-10-19 13:07:32 浏览: 217
当然可以!下面是一个简单的批处理脚本,它可以在指定的时间弹出一个提醒窗口:
```bat
@echo off
echo 提醒脚本已启动,请输入提醒时间(格式:HH:MM):
set /p reminder_time=
echo 提醒将在 %reminder_time% 弹出,请勿关闭此窗口。
:loop
for /f "tokens=1 delims=:" %%i in ("%time%") do set current_time=%%i
if "%current_time%"=="%reminder_time%" goto show_reminder
timeout /t 10 >nul
goto loop
:show_reminder
msg * "请注意,工作时间到了!"
```
使用方法:
1. 将以上代码保存为一个后缀为 `.bat` 的文件,如 `reminder.bat`。
2. 双击运行该批处理文件。
3. 根据提示,输入提醒的时间,格式为 `HH:MM`(例如 09:00 表示早上9点)。
4. 脚本会持续运行,直到当前时间与设定的提醒时间一致。
5. 当提醒时间到达时,会弹出一个提醒窗口。
请注意,这只是一个简单的示例脚本,可能不适用于所有的操作系统版本和语言环境。如果有需要,你可以根据自己的需求进行修改和扩展。
相关问题
写一个定时点击鼠标的bat脚本
好的,以下是一个简单的定时点击鼠标的bat脚本示例:
```
@echo off
echo 正在定时点击鼠标...
:loop
rem 设置等待时间,单位为毫秒,此处设置为5秒
ping -n 1 -w 5000 127.0.0.1 >nul
rem 模拟鼠标点击
powershell -command "& {[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point((Get-Random -Minimum 1 -Maximum ($([System.Windows.Forms.SystemInformation]::VirtualScreenWidth))), (Get-Random -Minimum 1 -Maximum ($([System.Windows.Forms.SystemInformation]::VirtualScreenHeight)))); Start-Sleep -Milliseconds 20; [System.Windows.Forms.SendKeys]::SendWait('{LEFT}'); }"
goto loop
```
请注意,此脚本使用Ping命令和PowerShell脚本语言实现。如果您没有安装PowerShell,则需要手动安装之后才能运行此脚本。此外,此脚本可能会对您的计算机造成重复性操作,因此请谨慎使用。
写一个每天提醒工作的弹窗的bat代码
当然可以!下面是一个简单的批处理脚本,用于创建一个每天提醒工作的弹窗:
```bat
@echo off
setlocal
:: 设置提醒的时间(24小时制,例如9:00 AM为09:00,6:30 PM为18:30)
set reminder_time=09:00
:: 设置提醒的消息内容
set reminder_message=记得完成今天的工作任务!
:: 获取当前系统时间
for /f "tokens=1-2 delims=:" %%a in ("%time%") do (
set current_hour=%%a
set current_minute=%%b
)
:: 循环等待到提醒时间
:wait_loop
if "%current_hour%:%current_minute%" geq "%reminder_time%" (
goto show_reminder
) else (
timeout /t 60 >nul
for /f "tokens=1-2 delims=:" %%a in ("%time%") do (
set current_hour=%%a
set current_minute=%%b
)
goto wait_loop
)
:show_reminder
:: 弹出提醒窗口
echo %reminder_message%
msg * %reminder_message%
endlocal
```
将上述代码保存为一个扩展名为 `.bat` 的文件(例如 `reminder.bat`),然后将其添加到您的计划任务中,以便每天在指定时间运行该脚本。
请确保将 `reminder_time` 变量设置为您希望收到提醒的时间,并将 `reminder_message` 变量设置为您希望显示的提醒消息内容。