2025年8月6日 星期三

力量殼層 PowerShell - Windows下的滑鼠自動移動程式(免安裝任何程式)

https://slashview.com/archive2024/20240516.html


 

Windows下的滑鼠自動移動程式(免安裝任何程式)

最近有需要上網觀看一些線上學習課程,依據SCORM標準規範必須監控學習過程,上網查了一些資訊,要達成在Windows作業系統下自動移動滑鼠,都需要下載安裝特定的執行檔(這種小程式好像在疫情期間特別興盛,可能是老闆想要遠端監控你有沒有乖乖的在家上班),但我怕有病毒不想下載。順手利用powershell撰寫了一個滑鼠定時自動移動的程式碼,供給有需要的人參考使用。

滑鼠定時自動移動程式碼

  1. 請開啟記事本,將下列程式碼貼上:
param (
	[int]$iSeconds = 10
)

Clear-Host
$host.ui.RawUI.WindowTitle = "@ Mouse Mover @"
$Host.UI.RawUI.BackgroundColor = "Black"
$Host.UI.RawUI.ForegroundColor = "White"
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8


Write-Host "_  _ ____ _  _ ____ ____ _  _ ____ _  _ ____ ____ " -ForegroundColor Magenta
Write-Host "|\/| |  | |  | [__  |___ |\/| |  | |  | |___ |__/ " -ForegroundColor Magenta
Write-Host "|  | |__| |__| ___] |___ |  | |__|  \/  |___ |  \ " -ForegroundColor Magenta
Write-Host ""
Write-Host "This program will continuously move your mouse cursor at an interval of every " -NoNewline
Write-Host "$iSeconds" -ForegroundColor Cyan -NoNewline
Write-Host " seconds."
Write-Host ""
Write-Host "Just " -NoNewline
Write-Host "CLOSE" -ForegroundColor Red -NoNewline
Write-Host " this window to " -NoNewline
Write-Host "STOP" -ForegroundColor Green -NoNewline
Write-Host " mouse auto-moving."
Write-Host ""

[int]$iCounter = 6
while($iCounter -gt 0) {
    [Console]::SetCursorPosition(0, [Console]::CursorTop)
    Write-Host "Starting countdown: $iCounter" -NoNewline
    $iCounter -= 1
    Start-Sleep -Seconds 1
}

function Hide-ConsoleWindow {
  Add-Type -Name Window -Namespace Console -MemberDefinition '
    [DllImport("Kernel32.dll")]
    public static extern IntPtr GetConsoleWindow();
    [DllImport("user32.dll")]
    public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
  '
  $oConsole = [Console.Window]::GetConsoleWindow()
  [Console.Window]::ShowWindow($oConsole, 6)
  return $null
}
$null = Hide-ConsoleWindow

[Console]::SetCursorPosition(0, [Console]::CursorTop)
Write-Host "... ### Running now ### ..." -NoNewline

Add-Type -AssemblyName System.Windows.Forms
$screenWidth = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width
$screenHeight = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height
while(1) {
  $x = Get-Random -Minimum 0 -Maximum $screenWidth
  $y = Get-Random -Minimum 0 -Maximum $screenHeight
  [Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)
  Start-Sleep -Seconds $iSeconds
}
  1. 儲存文字檔,並將檔名設定成MouseMover.ps1放置於桌面。

  2. 針對檔案點選右鍵,選擇用powershell執行即可。

程式碼每間隔10秒鐘會亂數移動一次滑鼠的座標位置,如果不喜歡的話,可以自行修改程式碼的第一行將10這個數字改掉,例如你想要一分鐘執行一次,可以改成60

[int]$iSeconds = 60

如果不想動程式碼的話,可以到桌面的路徑使用powershell帶入參數的方式執行,例如下方指令指定成每分鐘執行一次:

PS C:\Users\Slashview\Desktop> powershell .\MouseMover.ps1 60

Powershell執行權限問題(提升Powershell權限)

如果啟動執行後出現意外,系統彈出下列這樣之類的訊息,代表你的Powershell的執行權限不足,這時候還是得必須使用管理者身分來提升權限。

.\MouseMover.ps1 : 因為這個系統上已停用指令碼執行,所以無法載入 C:\Users\Slashview\Desktop\MouseMover.ps1 檔案。如需詳細資訊
,請參閱 about_Execution_Policies,網址為 https:/go.microsoft.com/fwlink/?LinkID=135170。
位於 線路:1 字元:1
+ .\MouseMover.ps1
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

按下Windows + R,輸入powershell後,同時按住Ctrl + Shift並按下Enter,系統會提示是否使用最高權限執行,點選後在視窗中輸入下列指令提升powershell權限:

Set-ExecutionPolicy Unrestricted

系統會彈出下列詢問字串,選擇A直接允許全部指令碼即可:

執行原則變更
執行原則有助於防範您不信任的指令碼。如果變更執行原則,可能會使您接觸到 about_Execution_Policies 說明主題 (網址為
https:/go.microsoft.com/fwlink/?LinkID=135170) 中所述的安全性風險。您要變更執行原則嗎?
[Y] 是(Y)  [A] 全部皆是(A)  [N] 否(N)  [L] 全部皆否(L)  [S] 暫停(S)  [?] 說明 (預設值為 "N"): A

完成後再去執行MouseMover.ps1應該就可以順利執行了。

Windows Powershell nonInstall nonSetup PureScript Mouse AutoMoving AutoMover eLearn eLearning OnlineVedio OnlineStream LearningDetection

沒有留言:

張貼留言

歡迎討論

HR , NO!Human Resources,NO!

※※ 這樣內容,上手會困難嗎?※※ 我想到什麼?就寫什麼!※※

※對於資訊!我想到什麼?就寫什麼!

如果困難的話?

有需要技術文件 DarkMan 蒐集了不少!
存在FTP共享。想下載?請洽DarkMan信箱取得下載帳號。※



人性的理由

上句:不修一切法,如如是己身。傳其法,授其使,說其名,淪為其用。
下句:你寫得出來其意就傳你【大神威、大魔法,無上魔道。】



【 臺灣 Google 創辦人 】於1987年前,以自身健康付出【 肺結核抗體血清、 炭疽熱病毒血清】來 購買【 美國網際網路發展計畫 】,制定下臺灣實現民生科技、國防科技的實現,他將 Google 權狀 託付給【 交通部 】設【 中華系統整合股份有限公司 、 子公司 電信數據公司 】,在 中國臺北 ( 中國國民黨 ) 的惡意侵占下,他是否將同 王永慶 一般遭 中國臺北 偽造文書 侵占 資產 後 遭加害身亡。

一切都是 中國臺北 與 中國北京 兩岸中國政權 ,意圖侵害 臺灣主權 的事實。

臺灣 需走向 國家主權獨立,永遠廢除 中國國民黨 , 永遠毀滅 中國臺北,才能走向國家獨立道路。


新聞時間 2025/5/30

網路基礎技能 - 相關連結(更新完成)

Dark 不覺得「Linux CD route 計畫」會比「思科路由」差!我認可 CD Route 計畫的實現,藉此....降低網路架設費用!

甚至「Linux CD route 計畫」更能夠實現「網路自由」的架構!


Fdisk 磁碟管理(一)共用「 Linux 與 微軟Windows」
Fdisk 磁碟管理(二)磁碟 boost loader 觀念
Fdisk 磁碟管理(三)清除磁碟分割
磁碟陣列是什麼東西?(RAID)

Linux Network
Linux 網路概要(連結版)
Linux 網路概要(抄過來)
設置網路環境 >> 資訊環境落實

MikroTik RouterOS 專業級路由系統
MikroTik RouterOS(1)
MikroTik RouterOS(2)
MikroTik RouterOS(3)
MikroTik RouterOS(4)

Linux Network Route
(一)接口設備觀念
(二)參照路由原則
(三)檢視路由
(四)Root路由器
(五)防禦對象

MikroTik RouterOS 專業級路由系統
網路卡、路由表、iptab 表、btctl show(一)「loopback 和網路卡*4」
網路卡、路由表、iptab 表、btctl show(二)拿微軟的系統route,來證明一下!
網路卡、路由表、iptab 表、btctl show(三)釋出路由方向
網路卡、路由表、iptab 表、btctl show(四)Root路由器
網路卡、路由表、iptab 表、btctl show(五)防禦對象

CD Route network
Linux CD route 網路設備配置的順序.....
Linux CD route 001 介紹
Linux CD route 002 軟體安裝
Linux CD route 003 外網
Linux CD route 004 內網
Linux CD route 005 安全
Linux CD route 006 防火牆