Moving Mouse to Bitmap On Screen
Moderators: Dorian (MJT support), JRL
Moving Mouse to Bitmap On Screen
I think I may be mentally handicapped but,
how do I find a bitmap image on the screen, and move the mouse to that position? I don't think FindImagePos is what I want, but I could be wrong, because I'm not exactly sure how to use that function.
how do I find a bitmap image on the screen, and move the mouse to that position? I don't think FindImagePos is what I want, but I could be wrong, because I'm not exactly sure how to use that function.
Okay, I just had to take the whole screen to get it working. Now I'm trying to get it loop until there are no more possibilities, and this is what I have, but I think I have messed up something. Can anyone fix my loop? The problem seems to be that it doesn't move to new occasions of the bitmap, but it keeps moving to the original one and double clicks there. So I guess my question would be how to make it move to a new instance?
GetScreenRes>sX,sY
ScreenCapture>0,0,sX,sY,C:\blocks\maingame.bmp
FindImagePos>C:\blocks\ott.bmp,C:\blocks\maingame.bmp,0,0,X,Y,NumFound
If>NumFound>0
Repeat>NumFound
MouseMove>X_0,Y_0
LDblClick
Wait>0.5
Let>NumFound=NumFound-1
Until>NumFound=0
Endif
GetScreenRes>sX,sY
ScreenCapture>0,0,sX,sY,C:\blocks\maingame.bmp
FindImagePos>C:\blocks\ott.bmp,C:\blocks\maingame.bmp,0,0,X,Y,NumFound
If>NumFound>0
Repeat>NumFound
MouseMove>X_0,Y_0
LDblClick
Wait>0.5
Let>NumFound=NumFound-1
Until>NumFound=0
Endif
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
This is all you need:
Code: Select all
FindImagePos>C:\blocks\ott.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
Let>k=0
Repeat>k
Let>k=k+1
MouseMove>X_%k%,Y_%k%
LDblClick
Wait>0.5
Until>k=NumFound
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Thanks, that just about did it. I did get an error from MS, but I resolved it and I have the general loop.
I am doing this for a block game, and any two vertical or horizontal blocks, you double click, and they go away, making the board different, so I had to recode a little bit.
I now made it so it looks after each click for the blocks again (this is only for one color as of right now, and verticle). It works great, but once there aren't any blocks to click, it moves the mouse to the last position there was and clicks infinitely.
What am I doing wrong?
FindImagePos>C:\blocks\ott.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
Let>k=NumFound
Repeat>k
Let>k=k-1
MouseMove>X_0,Y_0
LDblClick
Wait>1.5
FindImagePos>C:\blocks\ott.bmp,SCREEN,0,1,X,Y,NumFound
Until>k=NumFound
Endif
I am doing this for a block game, and any two vertical or horizontal blocks, you double click, and they go away, making the board different, so I had to recode a little bit.
I now made it so it looks after each click for the blocks again (this is only for one color as of right now, and verticle). It works great, but once there aren't any blocks to click, it moves the mouse to the last position there was and clicks infinitely.
What am I doing wrong?
FindImagePos>C:\blocks\ott.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
Let>k=NumFound
Repeat>k
Let>k=k-1
MouseMove>X_0,Y_0
LDblClick
Wait>1.5
FindImagePos>C:\blocks\ott.bmp,SCREEN,0,1,X,Y,NumFound
Until>k=NumFound
Endif
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You have Until>k=NumFound. But let's imagine k is on 5 and NumFound is now 0. K will now never equal 0. So perhaps this will do:
Until>{%k% >= %NumFound%}
So now it will stop if k is LARGER or EQUAL to NumFound. I think that's what you want.
Until>{%k% >= %NumFound%}
So now it will stop if k is LARGER or EQUAL to NumFound. I think that's what you want.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
In that case the second FindImagePos is finding less images than were previously found and k is currently set to a higher number. Which I thought was what you wanted.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Simplest approach:
So, if one is found, click on it, then start again. If none are found, move on.
Code: Select all
Label>SeekOTT
FindImagePos>C:\blocks\ott.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
MouseMove>X_0,Y_0
LDblClick
Goto>SeekOTT
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Alright, I got it going pretty decently I believe.
Is there any way to simplify this?
Is there any way to simplify this?
Label>LevelOne
FindImagePos>C:\blocks\ott.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
GoTo>SeekOTT
FindImagePos>C:\blocks\oww.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
GoTo>SeekOWW
FindImagePos>C:\blocks\bt.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
GoTo>SeekBT
FindImagePos>C:\blocks\bw.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
GoTo>SeekBW
FindImagePos>C:\blocks\special1.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
GoTo>SeekSPECIAL1
Label>SeekOTT
FindImagePos>C:\blocks\ott.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
MouseMove>X_0,Y_0
LDblClick
Goto>SeekOTT
If>Numfound=0
Wait>.05
GoTo>LevelOne
Endif
Endif
Label>SeekOWW
FindImagePos>C:\blocks\oww.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
MouseMove>X_0,Y_0
LDblClick
Goto>SeekOWW
If>Numfound=0
Wait>.05
GoTo>LevelOne
Endif
Endif
Label>SeekBT
FindImagePos>C:\blocks\bt.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
MouseMove>X_0,Y_0
LDblClick
Goto>SeekBT
If>Numfound=0
Wait>.05
GoTo>LevelOne
Endif
Endif
Label>SeekBW
FindImagePos>C:\blocks\bw.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
MouseMove>X_0,Y_0
LDblClick
Goto>SeekBW
If>Numfound=0
Wait>.05
GoTo>LevelOne
Endif
Endif
Label>SeekSPECIAL1
FindImagePos>C:\blocks\special1.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
MouseMove>X_0,Y_0
LDblClick
Goto>SeekSPECIAL1
If>Numfound=0
Wait>.05
GoTo>LevelOne
Endif
Endif
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You are doing the initial FindImagePos twice which will slow it down. You don't need to goto the top each time and you can simplify the If statements. This should be all you need:
Code: Select all
Label>SeekOTT
FindImagePos>C:\blocks\ott.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
MouseMove>X_0,Y_0
LDblClick
Goto>SeekOTT
Endif
Label>SeekOWW
FindImagePos>C:\blocks\oww.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
MouseMove>X_0,Y_0
LDblClick
Goto>SeekOWW
Endif
Label>SeekBT
FindImagePos>C:\blocks\bt.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
MouseMove>X_0,Y_0
LDblClick
Goto>SeekBT
Endif
Label>SeekBW
FindImagePos>C:\blocks\bw.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
MouseMove>X_0,Y_0
LDblClick
Goto>SeekBW
Endif
Label>SeekSPECIAL1
FindImagePos>C:\blocks\special1.bmp,SCREEN,0,1,X,Y,NumFound
If>NumFound>0
MouseMove>X_0,Y_0
LDblClick
Goto>SeekSPECIAL1
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?