image move (right-left) + keyboard follow it Topic is solved
-
- Posts: 10
- Joined: 24 Jan 2021, 17:50
image move (right-left) + keyboard follow it
So guys, i'm sorry for my english, i will try to explain my problem slowly.
When the image moves to the left, the keyboard keys will also press left and otherwise. it's like keyboard keys will follow where is the image moves.
Can someone explain me how to make script for it ?
thanks
When the image moves to the left, the keyboard keys will also press left and otherwise. it's like keyboard keys will follow where is the image moves.
Can someone explain me how to make script for it ?
thanks
Re: image move (right-left) + keyboard follow it
ImageSearch. Wait. ImageSearch again. If the x value decreases, Send {Left}; if it increases, Send {Right}.
-
- Posts: 10
- Joined: 24 Jan 2021, 17:50
Re: image move (right-left) + keyboard follow it
so, how to change keyboard keys that i want use to move ?
Re: image move (right-left) + keyboard follow it
Send {Left} will send the left arrow key.
-
- Posts: 10
- Joined: 24 Jan 2021, 17:50
Re: image move (right-left) + keyboard follow it
ImageSearch. Wait. ImageSearch again. If the x value decreases, Send {Left}; if it increases, Send {Right}.
where to put image file ?
where to put image file ?
Re: image move (right-left) + keyboard follow it
You can put the file anywhere. See Example #1 on the hyperlinked page posted above.
-
- Posts: 10
- Joined: 24 Jan 2021, 17:50
Re: image move (right-left) + keyboard follow it
Read documentation for ImageSearch. *n uses a numeric argument for variation. If you do not need it, remove it.
Coordinates will be relative to the active window unless you use CoordMode. If you intend to search the entire screen, you would want to add that command. Click and ImageSearch use different CoordMode target types.
The second line in the block does not use AHK commands.
Coordinates will be relative to the active window unless you use CoordMode. If you intend to search the entire screen, you would want to add that command. Click and ImageSearch use different CoordMode target types.
The second line in the block does not use AHK commands.
-
- Posts: 10
- Joined: 24 Jan 2021, 17:50
Re: image move (right-left) + keyboard follow it
ok thanks, i will try to correction my script, and Hisoka who pm me, im sorry cant reply because i still can't use pm feature.
Re: image move (right-left) + keyboard follow it
when that image moving to left there are any distinct sign for that ?
i mean did image change when moving left or right , or that image it isn't change just moving in some direction ..
i mean did image change when moving left or right , or that image it isn't change just moving in some direction ..
Re: image move (right-left) + keyboard follow it
Upon sequential searches for the image, if x decreases, it means that the new image is left of the previous image.
-
- Posts: 10
- Joined: 24 Jan 2021, 17:50
Re: image move (right-left) + keyboard follow it
the image is just moving in two direction, left and right, it is didnt change anything and same.
So i make this script for game.
And if i do manually, i need to press keyboard to follow that image. Green fish is image moving and i need to press keyboard to move green shape, following green fish image.
- Attachments
-
- IMG_20210126_221425.jpg (14.85 KiB) Viewed 891 times
Re: image move (right-left) + keyboard follow it Topic is solved
@mikeyww yes , but i think he didn't understand you , because he did quotes your first reply Literally then he writed it in second line code.
@rickyang11 this it general idea for what you want to do , just need to some adjust from expert like mikey if u need:
@rickyang11 this it general idea for what you want to do , just need to some adjust from expert like mikey if u need:
Code: Select all
CoordMode Pixel
var:=0
f1::
Loop
{
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, d:\strike.png
if (ErrorLevel = 2)
MsgBox Could not conduct the search.
else if (ErrorLevel = 1)
MsgBox Icon could not be found on the screen.
else
loop
{
if (FoundX > var) ;moved right
{
MsgBox, Image moving right ;replace With Send, {Right} if u need
var:=FoundX
}
if (FoundX < var) ;moved left
{
MsgBox, Image moving left ;replace With Send, {Left} if u need
var:=FoundX
}
break
}
return
}
return
esc::ExitApp
-
- Posts: 10
- Joined: 24 Jan 2021, 17:50
Re: image move (right-left) + keyboard follow it
Thank you very much for yout help. I will test to my game.HiSoKa wrote: ↑26 Jan 2021, 11:04@mikeyww yes , but i think he didn't understand you , because he did quotes your first reply Literally then he writed it in second line code.
@rickyang11 this it general idea for what you want to do , just need to some adjust from expert like mikey if u need:
Code: Select all
CoordMode Pixel var:=0 f1:: Loop { ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, d:\strike.png if (ErrorLevel = 2) MsgBox Could not conduct the search. else if (ErrorLevel = 1) MsgBox Icon could not be found on the screen. else loop { if (FoundX > var) ;moved right { MsgBox, Image moving right ;replace With Send, {Right} if u need var:=FoundX } if (FoundX < var) ;moved left { MsgBox, Image moving left ;replace With Send, {Left} if u need var:=FoundX } break } return } return esc::ExitApp
-
- Posts: 10
- Joined: 24 Jan 2021, 17:50
Re: image move (right-left) + keyboard follow it
i have question, i want to edit the image with photoshop, can ahk recognize it ?
and
i have problem, when i try to use imagesearch for images that vibrate quickly, ahk can't found it, is there a way to solve it?