Untitled
Anonymous
plain_text
02/23/2026 1:12 PM
5.3 KB
9
Indexable
# ================== POSTAVKE (TVOJE TOČKE) ==================
# 3 točke na TAMNOM GUMBU (0C2E43)
$ButtonPoints = @(
@{ X = 706; Y = 462; Hex = "0C2E43" },
@{ X = 788; Y = 449; Hex = "0C2E43" },
@{ X = 895; Y = 469; Hex = "0C2E43" }
)
# 2 točke na SVIJETLOJ POZADINI POPUPA (EFEFEF)
$PopupPoints = @(
@{ X = 796; Y = 391; Hex = "EFEFEF" },
@{ X = 796; Y = 510; Hex = "EFEFEF" }
)
# Gdje klikamo (uzmi sredinu gumba -> tvoja točka X=788 Y=449 je dobra)
$ClickX = 788
$ClickY = 449
# Koliko često provjeravamo (sekunde)
$PollSeconds = 3
# Da ne klikće opet i opet (sekunde)
$CooldownSeconds = 15
# Log
$LogFile = "C:\KioskScripts\cookie.log"
$StateFile = "C:\KioskScripts\cookie.state"
# ============================================================
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Win32Click {
[DllImport("user32.dll")] public static extern bool SetCursorPos(int X, int Y);
[DllImport("user32.dll")] public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
[DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr hWnd);
}
"@
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Win32Pixel {
[DllImport("user32.dll")] public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("user32.dll")] public static extern int ReleaseDC(IntPtr hwnd, IntPtr hdc);
[DllImport("gdi32.dll")] public static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos);
}
"@
function Get-HexColorAt($x, $y) {
$hdc = [Win32Pixel]::GetDC([IntPtr]::Zero)
$px = [Win32Pixel]::GetPixel($hdc, $x, $y)
[void][Win32Pixel]::ReleaseDC([IntPtr]::Zero, $hdc)
$r = ($px -band 0xFF)
$g = (($px -shr 8) -band 0xFF)
$b = (($px -shr 16) -band 0xFF)
return ("{0:X2}{1:X2}{2:X2}" -f $r,$g,$b)
}
function Log($msg) {
$ts = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
Add-Content -Path $LogFile -Value "$ts $msg"
}
function Cooldown-Ok {
if (-not (Test-Path $StateFile)) { return $true }
try {
$last = Get-Content $StateFile -ErrorAction Stop | Select-Object -First 1
$lastTime = [DateTime]::Parse($last)
return (((Get-Date) - $lastTime).TotalSeconds -ge $CooldownSeconds)
} catch { return $true }
}
function Mark-Cooldown {
Set-Content -Path $StateFile -Value (Get-Date).ToString("o")
}
function Signature-Match {
foreach ($p in $ButtonPoints) {
$hex = (Get-HexColorAt $p.X $p.Y).ToUpper()
if ($hex -ne $p.Hex.ToUpper()) { return $false }
}
foreach ($p in $PopupPoints) {
$hex = (Get-HexColorAt $p.X $p.Y).ToUpper()
if ($hex -ne $p.Hex.ToUpper()) { return $false }
}
return $true
}
function Click-Accept {
[Win32Click]::SetCursorPos($ClickX, $ClickY) | Out-Null
Start-Sleep -Milliseconds 60
[Win32Click]::mouse_event(0x02, 0, 0, 0, 0) # left down
Start-Sleep -Milliseconds 60
[Win32Click]::mouse_event(0x04, 0, 0, 0, 0) # left up
}
# ================== GLAVNA PETLJA ==================
Log "Cookie watcher started."
while ($true) {
Start-Sleep -Seconds $PollSeconds
# Ako Edge nije upaljen, nema smisla
$edge = Get-Process msedge -ErrorAction SilentlyContinue | Select-Object -First 1
if (-not $edge) { continue }
# Pokušaj dovesti Edge u fokus (pomaže da klik ode gdje treba)
if ($edge.MainWindowHandle -ne 0) {
[void][Win32Click]::SetForegroundWindow($edge.MainWindowHandle)
Start-Sleep -Milliseconds 120
}
# Ako nije prošao cooldown, preskoči
if (-not (Cooldown-Ok)) { continue }
# Provjeri signature (5 točaka)
if (Signature-Match) {
Log "Popup detected (signature match). Clicking at ($ClickX,$ClickY)."
Mark-Cooldown
Click-Accept
# Bonus: provjeri je li nestalo; ako nije, pokušaj još jednom
Start-Sleep -Milliseconds 700
if (Signature-Match) {
Log "Popup still present after click. Second click attempt."
Click-Accept
}
}
}Editor is loading...
Leave a Comment