An autoclicker I wrote to claim twitch channel points isn't working properly, I'd like to understand why - autohotkey

I've used AutoHotKey to write out a program that in theory, should claim the little channel point chests on twitch automatically. However, in practice it just does nothing. I'm a bit of a coding noob so cut me some slack. Below is the code:
o:: ; this is a killswitch in case anything goes wrong
{
exitapp
}
p::
while (true)
{
PixelGetColor, color, 1680, 1060 ; finds the color of a pixel that the chest appears on
if (color = 8FFFD2) ; if the color of that pixel is the color of the chest when it is highlighted
{
Click, 1700, 1060 ; click on where the chest appears
}
}
I tried running this while a chest was there and the code did nothing, I made sure that my mouse was highlighting it too. I also understand that BTTV can claim chests automatically, this is just a little project I'm doing for fun.

All you need to do is have a line of code to move the mouse to the co-ordinates, and then another line to click.
Try this, it should work:
o:: ; this is a killswitch in case anything goes wrong
{
exitapp
}
p::
while (true)
{
PixelGetColor, color, 1680, 1060 ; finds the color of a pixel that the chest appears on
if (color = 8FFFD2) ; if the color of that pixel is the color of the chest when it is highlighted
{
Mousemove, 1700, 1060
click ; click on where the chest appears
}
}

Related

How to drag window using right click down with AutoHotKey?

I would like to drag window using right click with title bar just like left click. Is it possible do that with AutoHotkey?
Background : I use Dell Display Manager which lets me arrange my windows in pre-defined grid. I can do this directly dragging or Shift+ Drag. Both options are sub optimal. Direct dragging just forces unwanted resize. Shift and Drag requires a key and mouse. I am wondering if I can drag using right click. I use application called RBTray to minimize to tray using right click. So, I know we can definitely add something like. I am looking something in AutoHotkey as that's much easier to code than C++.
This is probably what you're looking for: https://www.autohotkey.com/docs/scripts/index.htm#EasyWindowDrag
Below is code adapted to right click:
~RButton::
CoordMode, Mouse ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin%
if EWD_WinState = 0 ; Only if the window isn't maximized
SetTimer, EWD_WatchMouse, 0 ; Track the mouse as the user drags it.
return
EWD_WatchMouse:
GetKeyState, EWD_LButtonState, RButton, P
if EWD_LButtonState = U ; Button has been released, so drag is complete.
{
SetTimer, EWD_WatchMouse, Off
return
}
GetKeyState, EWD_EscapeState, Escape, P
if EWD_EscapeState = D ; Escape has been pressed, so drag is cancelled.
{
SetTimer, EWD_WatchMouse, Off
WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY%
return
}
; Otherwise, reposition the window to match the change in mouse coordinates
; caused by the user having dragged the mouse:
CoordMode, Mouse
MouseGetPos, EWD_MouseX, EWD_MouseY
WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin%
SetWinDelay, -1 ; Makes the below move faster/smoother.
WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY
EWD_MouseStartX := EWD_MouseX ; Update for the next timer-call to this subroutine.
EWD_MouseStartY := EWD_MouseY
return

Multiple MouseGetPos coordinates

I am trying to figure out how to have an AutoHotKey script save different coordinates through MouseGetPos on different hotkeys at the same time, without one overwriting the other.
I want to make a loop performing some sequence of events. Say at one point I want it to execute the first coordinate that I saved before or during the loop (but before the action), and then I want the script to execute the other coordinate at a later point in the loop.
I want the coordinates to be able to be preset (instead of pressing Hotkey1 before the action of hotkey1 and consequently hotkey2 after hotkey1 to ensure one is not overwritten).
An example of this would be:
If one hotkey saves one coordinate:
hotkey1::
MouseGetPos, posx, posy,
// If inserted into a loop, it would be:
MouseMove, %posx%, %posy%,
One hotkey saves another coordinate:
hotkey2::
MouseGetPos, posx1, posy1,
// In loop:
MouseMove, %posx1%, %posy1%,
If inputted into a random loop
#SingleInstance Force
SendMode Input
#MaxThreadsPerHotkey, 2
#NoEnv
#Persistent
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 3
SetMouseDelay, -1
Process, Priority, , H
SetKeyDelay, -1, -1
SetDefaultMouseSpeed, 0
SetKeyDelay, 0, 10, Play
SetMouseDelay, 10, Play
CoordMode, Mouse, Screen
hotkey1::
MouseGetPos, posx, posy,
return
hotkey2::
MouseGetPos, posx1, posy1,
return
Toggle=0
f::
Toggle := !Toggle
Loop
{
If Toggle
{
Send {a}
sleep 100
MouseMove, %posx%, %posy%, // Say I want it to move to bottom left corner
Send {LButton}
sleep 100
If !Toggle
Break
MouseMove, %posx1%, %posy1%, // Say this coordinate would be top-right corner
Send {LButton}
sleep 100
Send {c}
}
}
return
q::ExitApp
If I trigger hotkey1 and hotkey2 in that order, hotkey1 would get saved then overwritten by hotkey2, making hotkey1 the same coordinate as hotkey2. I would want 2 separately saved coordinates.
Do I do that by having one script trigger another script or can this be done in a single script?

ImageSearch from AutoHotKey never works in my PC

I'm trying with the code below but without success.
Here is how the code shoud works:
1-Download the image
2-Show the image
3-Do the search with ImageSearch method.
I tried following the procedure from this post but without success too:
https://autohotkey.com/board/topic/78242-imagesearch-not-working/
My AHK version is: 1.1.30.01 64-bit
We can get it from the command: MsgBox % A_AhkVersion " " (A_PtrSize=8 ? "64-bit" : "32-bit")
URLDownloadToFile,https://www.autohotkey.com/assets/images/ahk-logo-no-text241x78-180.png,ahk-logo-no-text241x78-180.png
Gui,Add,Picture,,ahk-logo-no-text241x78-180.png
Gui,Show
^e:: ;(Ctrl+e)
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, ahk-logo-no-text241x78-180.png
if (ErrorLevel == 0)
{
MsgBox, Found!
}
else
{
MsgBox, ErrorLevel:%ErrorLevel%
}
return
That logo is a PNG with transparency. If you use an image without transparency it will probably work. (Small enough to fit the screen and without shrinking or enlarging.)
There are details in the documentation about a transparency setting, but it's not likely to work with PNG so easily anyway. Because behind PNG's opacity channel there can be any color hidden.

scenekit SCNShadable u_diffuseColor reads as white

I'm trying to set a breakpoint via:
gl_FragColor = u_diffuseColor;
return;
or
gl_FragColor = _surface.diffuse
return;
in SCNShaderModifierEntryPointSurface but i always get white, regardless of what i've set in the scn editor.
Let's say i set the diffuse as red in the editor:
//hub.geometry?.materials = [material]; //diffuse is red
hub.geometry?.materials = [material]; //diffuse is white
Why is this uniform not being affected by the gui, or being overwritten, or whatever is going on? I'd like to be able to set the 'diffuse' through the gui, get a preview in the editor, and read it in GLSL from either u_diffuseColor or _surface.diffuse

AutoHotkey push a button to move curser to the left

I am struggling to make an AutoHotkey script, if anyone would help I would appreciate it.
the script im trying to make is: if I pressed F my mouse would move to the left as long as im pushing the F button from the current location I had my mouse on. This is what I have right now and it's not working.
Loop {
Sleep 10
MouseGetPos,x
if (MouseMove, -1000, 0, 100, R)
send {C down}
else if {C up}
break
}
return
Esc::ExitApp
Try this:
f::MouseMove -5, 0, 50, R
50 is the speed, and the R letter means that the offset is relative to the current cursor position. You don't need the loop, as the pressed key will generate subsequent events on its own.