It works, but not like I intend and isnt very reliable.
I created hotkeys to perform all of the functions I would like, as well as a box in the top right to act as an idicator of which mode of operation it is in.
it should ideally work as follows
upon pressing the "AUTO" gui button, it changes the top box to reflect the auto state and then it begins to search for a color, when it finds that color, it peforms a controlmouseclick and a few keystrokes, then begins to check the color location's Y coordinate against the previous coordinate, if theres a difference, it performs mouse and the keystroke again.
I have this working, to a degree, but it seems like whenever the pixel is found around at Y300px in screen, or relative coordmode. it loses control of the active window, like the controlclick is clicking in the wrong coord? and this is usually where it gets weird and i have to restart the script.
something I would like but havent figured out how to do reliably yet, is upon pressing the "MANUAL" gui button, the script ceases the pxsearch loop and performs a keystroke (switching windows within the program) and allows the user to operate the gui manually via the UP/DOWN and ENTER Gui buttons, and reflect this state in the upper right box. Upon pressing either Manual again, or AUTO, it resumes the pixel search.
In the beginning I had it automatically scrolling the window until the pixel was found at a high enough point in the screen, but that proved to just give me a headache so i abandoned it. any pointers towards achieving it effectively would be appreciated.
here's the code:
Code: Select all
#SingleInstance, Force
CoordMode, Pixel, Screen
Gui, 1:+AlwaysOnTop +ToolWindow -Caption +Border +E0x08000000 ;WS_EX_NOACTIVATE E0x08000000
Gui, 1:font, s15, Verdana
Gui, 1:font, w800
Gui, 1:font, cRed
Gui, 1:Add, Edit, vmyEdit w90 h33 -VScroll +Center +Uppercase +Limit6 +ReadOnly
Gui, 1:Show , x1000
Gui, 1:Show , y15
Gui, 1:Show, noactivate,Test
Gui, 2:+AlwaysOnTop +ToolWindow -Caption +Border +E0x08000000 ;WS_EX_NOACTIVATE E0x08000000
Gui, 2:font, s18
Gui, 2:font, wDefault
Gui, 2:Add, Button, gesc w120 h70, EXIT
Gui, 2:Add, Button, g^Up w120 h70 xp120, UP
Gui, 2:Add, Button, g^Down w120 h70 xp120, DOWN
Gui, 2:Add, Button, genter w120 h70 xp120, ENTER
Gui, 2:Add, Button, g!f10 w120 h70 xp120, MANUAL
Gui, 2:Add, Button, g!f11 w220 h70 xp120, AUTO
Gui, 2:Show , x500
Gui, 2:Show , y775
Gui, 2:Show, noactivate,Test
return
^!r::Reload
return
enter::
sleep, 10
Send, ^{Left}
Send, {Enter}
return
!f10::
IfWinNotActive, ENPS
{
WinActivate, ENPS ; activates enps
}
if (clip <> "MAN")
{
send, !{Left}
ClipSave := ClipboardAll ; store the current clipboard content
Clipboard := "MAN" ; clear the clipboard
sleep, 200
clip := Clipboard
GuiControl, 1:, myEdit, %clip%
Clipboard := ClipSave
sleep 5000 ; failsafe
}
if (clip = "MAN")
{
send, !{Left}
ClipSave := ClipboardAll ; store the current clipboard content
Clipboard := "AUTO" ; clear the clipboard
sleep, 200
clip := Clipboard
GuiControl, 1:, myEdit, %clip%
Clipboard := ClipSave
sleep 5000 ; failsafe
}
return
^Down::
IfWinNotActive, ENPS
{
WinActivate, ENPS ; activates enps
}
IfWinActive , ENPS
{
Send, {WheelDown}
sleep, 100
}
return
^Up::
IfWinNotActive, ENPS
{
WinActivate, ENPS
}
IfWinActive, ENPS
{
Send, {Wheelup}
sleep, 100
}
return
!f11::
Auto := "1"
ClipSave := ClipboardAll ; store the current clipboard content
Clipboard := "AUTO" ; clear the clipboard
sleep 200
clip := Clipboard
Main:
GuiControl, 1:, myEdit, %clip%
WinActivate, ENPS
Loop,
{
msgbox, %auto%
WinActivate, ENPS
PixelSearch, Px, Py, 30, 100, 900, 900, 0xFFFF00, 0, FAST, RGB
sleep, 500
sleep, 10
CoordMode, Pixel, Window
ControlClick, x%Px% y%Py%, ENPS ;click ENPS
sleep, 500
send, ^{Left}
send, {enter}
sleep, 10
Vy := Py
msgbox, %vy% is %py%
sleep, 1000
PixelSearch, Px, Py, 30, 100, 900, 900, 0xFFFF00, 0, FAST, RGB
sleep, 500
if (%Vy% <> %Py%)
{
send, ^{Left}
send, {enter}
}
break
}
sleep, 200
msgbox, %vy% is not %py%
goto, Main
return
esc::
ExitApp