Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- #Persistent
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- SetTitleMatchMode, 2
- ; CoordMode, Mouse, Screen
- #Include C:\Users\Donald\Desktop\TQ Bot Folder\Utils.ahk
- pathBase = C:\Users\Donald\Desktop\TQ Bot Folder\Click God Logs\
- path1 = %pathBase%clickFormatted.txt
- path2 = %pathBase%clickRelative.txt
- xpos1 = 0
- ypos1 = 0
- tempPreviousTime = 0
- userInput =
- SetTimer, Button_Pressed, 1
- F3::Reload
- return
- ; Hybrid Functions
- Button_Pressed:
- ;if WinActive("Titan Quest Anniversary Edition")
- ;{
- ; Clear file.
- if GetKeyState("F4", "P")
- {
- global path1
- recordFile := FileOpen(path1, "w")
- recordFile.Close()
- Sleep 1000
- return
- }
- ; Fast Mouse record.
- if GetKeyState("F5", "P")
- {
- Click
- recordMousePosition()
- writeMousePosition()
- Sleep 1000
- return
- }
- /*
- if GetKeyState("F6", "P") {
- MouseGetPos, MouseX, MouseY
- PixelGetColor, color, %MouseX%, %MouseY%, RGB
- MsgBox The color at the current cursor position is %color%.
- }
- ; Reset game window pos.
- if GetKeyState("F8", "P") {
- }
- */
- ; Get pixel posiiton at cursor position.
- if GetKeyState("F6", "P") {
- ; Deselect Titan Quest Game Window
- ;WinActivate, Notepad++
- ; Get pixel color at mouse pos.
- MouseGetPos, MouseX, MouseY
- ; BGR default format. (Each digit is HEX, 00-ff)
- PixelGetColor, color, %MouseX%, %MouseY%
- ; MsgBox The color at the current cursor position is %color%.
- word_array := StrSplit(color, "")
- ; MsgBox % word_array[3] ; 3-9 equals array.
- colorBlue := getDecimalFromHexes(word_array[3], word_array[4])
- colorGreen := getDecimalFromHexes(word_array[5], word_array[6])
- colorRed := getDecimalFromHexes(word_array[7], word_array[8])
- MsgBox % colorRed . " " . colorGreen . " " . colorBlue . " " . color
- }
- if GetKeyState("F7", "P") {
- ; Deselect Titan Quest Game Window
- ;WinActivate, Notepad++
- ; Reset Game Window pos.
- ;WinMove, Titan Quest Anniversary Edition, ,0, 0
- ;Sleep 100
- ; Execute pixel search.
- searchX = 0
- searchY = 0
- maxSearchX = 1024
- maxSearchY = 768
- ; If not finding a pixel, check search increment.
- searchIncrement = 1
- ;maxSearchX = 1024
- ;maxSearchY = 768
- while (searchX < maxSearchX) {
- while (searchY < maxSearchY) {
- PixelGetColor, color, %searchX%, %searchY%
- ; PixelSearch, Px, Py, searchX1, searchY1, searchX2, searchY2, , 3, Fast
- if (color = "0x6AC3E8") {
- MsgBox % "Found pixel at: " . searchX . " " . searchY
- break
- }
- ; 0,0 - 0,1
- ; Maybe in the future skip by 5, instead of 1, or 10.
- searchY+=searchIncrement
- }
- ; if (ErrorLevel == 0)
- ; break
- searchX+=searchIncrement
- searchY = 0
- }
- MsgBox % "Done!"
- }
- ; Add F8 condition, where mouse is moved over screen slowly and any monster health bars that pop up cause their pixel color to be recorded.
- ; TODO NOTE: Maybe do melee solution? do a screen search for a monster, then click it to approach, then attack in melee after 'x' time. (Based on distance, determine 'x' for time?)
- ;}
- return
- ; Returns a decimal value for a 2-digit hex code.
- getDecimalFromHexes(hex1, hex2) {
- return getDecimalFromHex(hex1) * 16 + getDecimalFromHex(hex2)
- }
- ; return decimal value from a hex digit.
- ; hexvalue = string from 0-f
- getDecimalFromHex(hexValue) {
- if (hexValue = "a") {
- return 10
- }
- else if (hexValue = "b") {
- return 11
- }
- else if (hexValue = "c") {
- return 12
- }
- else if (hexValue = "d") {
- return 13
- }
- else if (hexValue = "e") {
- return 14
- }
- else if (hexValue = "f") {
- return 15
- }
- else {
- return hexValue
- }
- }
- ; Base functions.
- /*
- recordComment()
- writeComment(newLine)
- recordCommand()
- writeCommand()
- recordMousePosition()
- writeMousePosition()
- */
- recordComment()
- {
- global userInput
- InputBox, userInput, Input, Enter "Comment" Text:,,,,,,,,
- }
- recordCommand()
- {
- global userInput
- InputBox, userInput, Input, Enter "Send" Text:,,,,,,,,
- }
- recordMousePosition()
- {
- global path1
- global xpos1
- global ypos1
- MouseGetPos, xpos1, ypos1
- }
- writeComment()
- {
- global path1
- global userInput
- text2 := "; "
- fileWrite(path1, text2 . userInput)
- addLineBreak()
- }
- writeCommand()
- {
- global path1
- global userInput
- text2 = send_delay_20("
- text3 = ")
- fileWrite(path1, text2 . userInput . text3)
- addLineBreak()
- }
- writeMousePosition()
- {
- global path1
- global xpos1
- global ypos1
- writeString = delayed_click(%xpos1%, %ypos1%)`r`n
- fileWrite(path1, writeString)
- addLineBreak()
- }
- ; Utility Functions.
- writeSleep(x)
- {
- global path1
- y = Sleep %x%`r`n
- fileWrite(path1, y)
- }
- addLineBreak()
- {
- global path1
- fileWrite(path1, "`r`n")
- }
- fileWrite(path, msg)
- {
- recordFile := FileOpen(path, "a")
- recordFile.Write(msg)
- recordFile.Close()
- }
- /*
- recordFile := FileOpen(path2, "w")
- recordFile.write("#Include C:\Users\abdullad\Desktop\Personal Files\ClickTypeUtils.ahk`r`n`r`nF4::Test()`r`n`r`nTest()`r`n{`r`n MouseGetPos, xpos, ypos`r`n`r`nxposBase := xpos`r`nyposBase := ypos`r`n`r`n; Move to the end -> MouseMove, xpos, ypos <- Make sure to delete the first set of mouse coords.`r`n`r`n")
- recordFile.Close()
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement