-
Notifications
You must be signed in to change notification settings - Fork 0
/
vignettes_pc.ps1
74 lines (54 loc) · 1.93 KB
/
vignettes_pc.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#Required modules
Add-Type -AssemblyName System.Windows.Forms
#Function to call a left click
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class Mouse {
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
public static void LeftClick() {
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
}
"@
# Function to click thumbnails
function Click-Thumbnail {
param (
[float]$x_pos = 0,
[float]$y_pos = 0
)
# Move mouse and click on thumbnail
$position = [System.Windows.Forms.Cursor]::Position
[System.Windows.Forms.Cursor]::Position = [System.Drawing.Point]::new($x_pos, $y_pos)
Start-Sleep -Milliseconds 1000
[Mouse]::LeftClick()
Start-Sleep -Seconds 4
[System.Windows.Forms.SendKeys]::SendWait("^w") # Ctrl+w to close tab
}
#get your screen size to know where the thumbnails are
Add-Type -AssemblyName System.Windows.Forms
$screenSize = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Size
$width = $screenSize.Width
$height = $screenSize.Height
# Thumbnails navigation function
function Thumbnail-Task {
Start-Process "https://rewards.microsoft.com/"
Start-Sleep -Seconds 6
Click-Thumbnail (45*$width/100) ($height) # Left thumbnail
Start-Sleep -Seconds 2
Click-Thumbnail (70*$width/100) ($height) # Middle thumbnail
Start-Sleep -Seconds 2
Click-Thumbnail (110*$width/100) ($height) # Right thumbnail
Start-Sleep -Seconds 2
Stop-Process -Name "msedge" -Force
}
# Combine both tasks
function Run-All {
Thumbnail-Task
}
# Run the combined task
Run-All