0% found this document useful (0 votes)
7 views7 pages

AutoHotkey Discord Image Monitor Script

This document outlines an AutoHotkey script designed for monitoring images and automating tasks, including sending screenshots to Discord. It includes various hotkeys for starting/stopping the script, checking for specific images, and executing other programs. The script also features functions for taking screenshots and uploading them to a Discord channel when certain conditions are met.

Uploaded by

kraudit79
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views7 pages

AutoHotkey Discord Image Monitor Script

This document outlines an AutoHotkey script designed for monitoring images and automating tasks, including sending screenshots to Discord. It includes various hotkeys for starting/stopping the script, checking for specific images, and executing other programs. The script also features functions for taking screenshots and uploading them to a Discord channel when certain conditions are met.

Uploaded by

kraudit79
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

; macro#1 - AutoHotkey Image Monitor Script dengan Discord Screenshot

; F7 = Start/Stop Script (normal monitoring)


; F8 = Start/Stop Script (run COMPLETE macro sequence immediately)
; F5 = Check Image [Link]
; F6 = Jalankan [Link]
; F9 = Kill/Force Stop [Link]
; Esc = Exit Script

#NoEnv
#SingleInstance Force
#Persistent
SendMode Input
SetWorkingDir %A_ScriptDir%
/Stop Script (normal monitoring)
; F8 = Start/Stop Script (run COMPLETE macro sequence immediately)
; F5 = Check Image [Link]
; F6 = Jalankan [Link]
; F9 = Kill/Force /Stop Script (normal monitoring)
; F8 = Start/Stop Script (run COMPLETE macro sequence immediately)
; F5 = Check Image [Link]
; F6 = Jalankan [Link]
; F9 = Kill/Force
SendMode Input
SetWorkingDir %A_ScriptDir%

; --- Discord Bot Settings ---


botToken := "MTQxOTYwNjY1MDQ4NjI2MzgyOQ.G-XwBa.cxPENemrzAMJqpmp4XS-UdTV-
aV5mflCU49HMQ"
channelID := "1270571630388576421t12t12t
ToolTip, Script STOPPED, 10, 10
SetTimer, RemoveToolTip, 2000
} else {
ScriptRunning := true
LoopCount := 0
ToolTip, Script STARTED, 10, 10
SetTimer, RemoveToolTip, 2000
Gosub, MainScript
}
return

; Hotkey F8 untuk langsung jalankan SELURUH ALUR lengkap


F8::
if (ScriptRunning) {
ScriptRunning := false
LoopCount := 0
ScriptRunning := true
LoopCount := 0
ToolTip, Script STARTED, 10, 10
SetTimer, RemoveToolTip, 2000
Gosub, MainScript
}
return

; Hotkey F8 untuk langsung jalankan SELURUH ALUR lengkap


F8::
if (ScriptRunning) {
ScriptRunning := false
LoopCount := 0
ScriptRunning := true
LoopCount := 0
ToolTip, Script STARTED, 10, 10
SetTimer, RemoveToolTip, 2000
Gosub, MainScript
}
return

ScriptRunning := true
LoopCount := 0
ToolTip, Script STARTED, 10, 10
SetTimer, RemoveToolTip, 2000
Gosub, MainScript
}
return

; Hotkey F8 untuk langsung jalankan SELURUH ALUR lengkap


F8::
if (ScriptRunning) {
ScriptRunning := false
LoopCount := 0
; Hotkey F8 untuk langsung jalankan SELURUH ALUR lengkap
F8::
if (ScriptRunning) {
ScriptRunning := false
LoopCount := 0
ToolTip, Script STOPPED, 10, 10
SetTimer, RemoveToolTip, 2000
} else {
ScriptRunning := true
LoopCount := 0
ToolTip, Script STARTED - Running COMPLETE macro sequence..., 10, 10
SetTimer, RemoveToolTip, 2000

; JALANKAN SELURUH ALUR LENGKAP LANGSUNG:


ToolTip, 🚀 STARTING COMPLETE SEQUENCE, 10, 30
; 1. Jalankan [Link]
ToolTip, ▶️ RUNNING [Link], 10, 30
RunWait, [Link]
; 2. Setelah selesai, mulai monitoring
ToolTip, ✅ COMPLETE SEQUENCE FINISHED - Starting monitoring..., 10, 30
Sleep, 2000
Gosub, MainScript
}
return

; Hotkey F9 untuk kill/force stop [Link]


F9::
Process, Close, [Link]
if (ErrorLevel = 0) {
ToolTip, Macro KILLED successfully!, 10, 70
} else {
ToolTip, Macro not running or failed to kill, 10, 70
}
SetTimer, RemoveToolTip, 3000
return

; Hotkey F5 untuk check image [Link]


F5::
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 [Link]
if (ErrorLevel = 0) {
ToolTip, IMAGE FOUND at X:%FoundX% Y:%FoundY%, 10, 30
} else if (ErrorLevel = 1) {
ToolTip, IMAGE NOT FOUND, 10, 30
} else {
ToolTip, ERROR: [Link] file not found in script directory, 10, 30
}
SetTimer, RemoveToolTip, 3000
return

ScriptRunning := true
LoopCount := 0
ToolTip, Script STARTED, 10, 10
SetTimer, RemoveToolTip, 2000
Gosub, MainScript
}
return

; Hotkey F8 untuk langsung jalankan SELURUH ALUR lengkap


F8::
if (ScriptRunning) {
ScriptRunning := false
LoopCount := 0
ScriptRunning := true
LoopCount := 0
ToolTip, Script STARTED, 10, 10
SetTimer, RemoveToolTip, 2000
Gosub, MainScript
}
return

; Hotkey F8 untuk langsung jalankan SELURUH ALUR lengkap


F8::
if (ScriptRunning) {
ScriptRunning := false
LoopCount := 0
ScriptRunning := true
LoopCount := 0
ToolTip, Script STARTED, 10, 10
SetTimer, RemoveToolTip, 2000
Gosub, MainScript
}
return

; Hotkey F8 untuk langsung jalankan SELURUH ALUR lengkap


F8::
if (ScriptRunning) {
ScriptRunning := false
LoopCount := 0
if (!ScriptRunning)
break

; Check apakah [Link] ada


ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 [Link]
if (ErrorLevel = 0) {
; Jika [Link] ditemukan, jalankan [Link]
ToolTip, Script running - [Link] found! Starting [Link]..., 10, 50
; Jalankan [Link] dan tunggu sampai selesai
RunWait, [Link]
; Setelah [Link] selesai, jalankan [Link]
ToolTip, Script running - Starting [Link]..., 10, 50
RunWait, [Link]
; Setelah [Link] selesai, lanjut loop lagi
ToolTip, Script running - [Link] finished! Back to monitoring..., 10, 50
} else {
; Check apakah [Link] ada
ImageSearch, RetryX, RetryY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50
[Link]
if (ErrorLevel = 0) {
; TAMBAH LOOP COUNT HANYA DI SINI (setelah screenshot diambil)
LoopCount++

; Jika [Link] ditemukan, screenshot dulu dan kirim ke Discord


ToolTip, Script running - [Link] found! Taking screenshot..., 10, 50
SetTimer, RemoveToolTip, 2000

; SCREENSHOT DAN KIRIM KE DISCORD DULU


TakeScreenshotAndSend()

; BARU jalankan [Link] setelah screenshot


ToolTip, Script running - Screenshot sent! Starting [Link]..., 10,
50
RunWait, [Link]

; Setelah [Link] selesai, jalankan [Link]


ToolTip, Script running - Starting [Link]..., 10, 50
RunWait, [Link]

; Setelah [Link] selesai, lanjut loop lagi


ToolTip, Script running - [Link] finished! Back to monitoring...,
10, 50
} else {
; Jika kedua image tidak ditemukan
ToolTip, Script running - Waiting for [Link] or [Link]... Loop:
%LoopCount%, 10, 50
}
}

; Delay untuk mencegah CPU usage tinggi


Sleep, 500
}
return

; --------- SCREENSHOT & DISCORD FUNCTIONS ---------


TakeScreenshotAndSend() {
global screenshotDir, botToken, channelID

; Ambil screenshot window aktif


WinGet, activeWin, ID, A
if (!activeWin) {
; Jika tidak ada window aktif, screenshot seluruh layar
TakeFullScreenshot()
return
}

; Dapatkan posisi window aktif


WinGetPos, rX, rY, rW, rH, ahk_id %activeWin%
; Generate nama file unik
FormatTime, timeStamp, , yyyy-MM-dd_HH-mm-ss
screenshotFile := screenshotDir . "\retry_screenshot_" . timeStamp . ".png"

; Ambil screenshot area window


if (rX != "" and rY != "" and rW != "" and rH != "") {
TakeAreaScreenshot(rX, rY, rW, rH, screenshotFile)
} else {
; Fallback ke fullscreen
TakeFullScreenshot(screenshotFile)
}

; Kirim ke Discord jika file berhasil dibuat


if FileExist(screenshotFile) {
SendToDiscord(screenshotFile)
}
}

TakeAreaScreenshot(x, y, w, h, filePath) {
; Screenshot area menggunakan PowerShell
psCmd := "Add-Type -AssemblyName [Link],[Link]; "
psCmd .= "$bounds = New-Object [Link](" . x . "," . y . "," .
w . "," . h . "); "
psCmd .= "$bmp = New-Object [Link](" . w . "," . h . "); "
psCmd .= "$graphics = [[Link]]::FromImage($bmp); "
psCmd .= "$[Link]($[Link],
[[Link]]::Empty, $[Link]); "
psCmd .= "$[Link]('" . filePath . "',
[[Link]]::Png); "
psCmd .= "$[Link](); $[Link]();"

RunWait, [Link] -Command "%psCmd%", , Hide


}

TakeFullScreenshot(filePath := "") {
global screenshotDir

if (filePath = "") {
FormatTime, timeStamp, , yyyy-MM-dd_HH-mm-ss
filePath := screenshotDir . "\retry_fullscreen_" . timeStamp . ".png"
}

; Screenshot seluruh layar


psCmd := "Add-Type -AssemblyName [Link],[Link]; "
psCmd .= "$bounds = [[Link]]::[Link]; "
psCmd .= "$bmp = New-Object [Link]($[Link],
$[Link]); "
psCmd .= "$graphics = [[Link]]::FromImage($bmp); "
psCmd .= "$[Link]($[Link],
[[Link]]::Empty, $[Link]); "
psCmd .= "$[Link]('" . filePath . "',
[[Link]]::Png); "
psCmd .= "$[Link](); $[Link]();"

RunWait, [Link] -Command "%psCmd%", , Hide

; Kirim ke Discord
if FileExist(filePath) {
SendToDiscord(filePath)
}
}

SendToDiscord(filePath) {
global botToken, channelID

if (botToken = "YOUR_BOT_TOKEN_HERE") {
return
}

; Baca ukuran file


FileGetSize, fileSize, %filePath%
if (fileSize > 8388608) { ; 8MB limit Discord
return
}

; Buat curl command untuk upload ke Discord


curlCmd := "curl -X POST """ . "[Link] .
channelID . "/messages"" "
curlCmd .= "-H ""Authorization: Bot " . botToken . """ "
curlCmd .= "-F ""file=@" . filePath . """ "
curlCmd .= "-F ""content=🔄 RETRY DETECTED - Screenshot sent from AutoHotkey
Bot"""

; Jalankan curl command


RunWait, %curlCmd%, , Hide

; Hapus file setelah upload


Sleep, 1000
FileDelete, %filePath%
}

; Function untuk menghilangkan tooltip


RemoveToolTip:
ToolTip
return

; Hotkey Esc untuk keluar dari script


Esc::
ScriptRunning := false
ToolTip, Script EXITED, 10, 10
SetTimer, RemoveToolTip, 2000
Sleep, 2000
ExitApp
return

; Info script saat startup


^j:: ; Ctrl+J untuk help
MsgBox, 64, AutoHotkey Image Checker + Discord Screenshot Help,
(
Hotkeys:
F7 = Start/Stop Script (normal monitoring)
F8 = Start/Stop Script (run COMPLETE macro sequence immediately)
F5 = Check [Link] image
F6 = Jalankan [Link]
F9 = Kill/Force Stop [Link]
Esc = Exit script completely
Ctrl+J = Show this help
Features:
- Auto screenshot when [Link] detected
- Send screenshot to Discord before running [Link]
- Loop counter hanya bertambah saat screenshot diambil
- Normal monitoring for [Link]
- Manual run [Link] with F6
- F8 runs COMPLETE sequence immediately ([Link])

Setup:
1. Replace YOUR_BOT_TOKEN_HERE with your Discord bot token
2. Place [Link] and [Link] in script folder
3. Ensure curl is installed for Discord upload
4. Ensure [Link] dan [Link] are in script folder

Note: Screenshots saved to screenshots/ folder


)
return

You might also like