Page 2 of 3
Re: Using micromacro with smartphone app via PC?
Posted: Thu Oct 04, 2012 4:00 am
by Atlas123
mouseGetPos() And windowRect(getWin())
I was hoping mousegetpos() would also give me the Width/Height (in the window) for the mouse position (not just X/Y for the screen , hence I was using the print code for windowRect(getWin()). A bit of a Frankenstein I know but I was trying my luckā¦
But I know see I can see the difference between the cords for mouseGetPos() And windowRect(getWin()) which allows me to calculate the Width/Height in the Window.
So I will just put the X/Y cords in Excel to calculate the Window Width/Height coords for the script.
Therefore the final script would be this (it actually works!):
Code: Select all
local windowList = findWindowList("*","TvnWindowClass");
if( #windowList == 0 ) then
print("You need to run Some App first!");
return 0;
end
function getWin()
if( __WIN == nil ) then
__WIN = windowList[1]
end
return __WIN;
end
function getProc()
if( __PROC == nil or not windowValid(__WIN) ) then
if( __PROC ) then closeProcess(__PROC) end;
__PROC = openProcess( findProcessByWindow(getWin()) );
end
return __PROC;
end
--add code after here to do what you want.
local wx, wy, ww, wh = windowRect(getWin());
mouseSet(wx + ww-300, wy+ wh-270);
mouseLClick();
yrest(5000);
mouseSet(wx + ww-297, wy+ wh-458);
mouseLClick();
yrest(5000);
The following question may be a stretch too far...
1/ At some point I need to click and drag the screen, I guees I need to use mouseLhold() but not sure what after that
2/ yrest: As it is a phone game there are loading times, generally fast but sometimes a few seconds, is there a way to , instead of putting a high yrest number, it could recognise the window is not loaded yet and when loaded perform the action? Or maybe that is cheat engine and for another day?
Re: Using micromacro with smartphone app via PC?
Posted: Thu Oct 04, 2012 5:21 am
by lisa
Atlas123 wrote: is there a way to , instead of putting a high yrest number, it could recognise the window is not loaded yet and when loaded perform the action? Or maybe that is cheat engine and for another day?
yep CE is how you will be able to do that, otherwise yeah you will just be doing yrests, you could probably look at doing pixel searches I guess but I haven't bothered with that sort of thing.
You should be able to hold left mouse and then move the mouse to "slide" what you need to and then release the left mouse.
Re: Using micromacro with smartphone app via PC?
Posted: Thu Oct 04, 2012 7:06 am
by Atlas123
And thanks again
Another thing, as mentioned earlier there would be approch 25 actions for each farming event, if i count the overall possible actions that brings it to approx 35 possible actions.
Is it possible for me to have in one place of the script the 35 possible actions, so for example for 2 actions:
Action 1:
Code: Select all
mouseSet(wx + ww-300, wy+ wh-270);
mouseLClick();
yrest(5000);
Action 2:
Code: Select all
mouseSet(wx + ww-297, wy+ wh-458);
mouseLClick();
yrest(5000);
and then in the action script something like:
Do action 1
Do action 2
Do action 1
Do action 2
Bear in mind actions 1 to 25 may happen up to 300 times therefore that would make quite an unfriendly script (even if copy paste is easy). I will probably divide the script in 10 scripts to limit annoyance due to crashes, restarts, etc (and not start from the beginning which is not possible)
Re: Using micromacro with smartphone app via PC?
Posted: Thu Oct 04, 2012 10:19 am
by lisa
ok so you have learnt how to call functions, now you need to learn how to write one =)
A function is kind of like copy pasting the same code everywhere but when you use a function you just write the code once and so only have to edit/update that 1 occurance.
So you could do
Code: Select all
function action1()
mouseSet(wx + ww-300, wy+ wh-270);
mouseLClick();
yrest(5000);
end
function action2()
mouseSet(wx + ww-297, wy+ wh-458);
mouseLClick();
yrest(5000);
end
then when you want the code done that is inside a function you just call it with
action1()
or
action2()
Re: Using micromacro with smartphone app via PC?
Posted: Thu Oct 04, 2012 11:47 am
by Atlas123
How does this work out?
I tried:
Code: Select all
local windowList = findWindowList("*","TvnWindowClass");
if( #windowList == 0 ) then
print("You need to run Some App first!");
return 0;
end
function getWin()
if( __WIN == nil ) then
__WIN = windowList[1]
end
return __WIN;
end
function getProc()
if( __PROC == nil or not windowValid(__WIN) ) then
if( __PROC ) then closeProcess(__PROC) end;
__PROC = openProcess( findProcessByWindow(getWin()) );
end
return __PROC;
end
function action1()
mouseSet(wx + ww-296, wy+ wh-264);
mouseLClick();
yrest(5000);
End
--add code after here to do what you want.
local wx, wy, ww, wh = windowRect(getWin());
action(1)
But I get: '=' expected near 'local'
Re: Using micromacro with smartphone app via PC?
Posted: Thu Oct 04, 2012 7:09 pm
by lisa
Code: Select all
function action1()
mouseSet(wx + ww-296, wy+ wh-264);
mouseLClick();
yrest(5000);
End
you have End and it should be end
Code: Select all
function action1()
mouseSet(wx + ww-296, wy+ wh-264);
mouseLClick();
yrest(5000);
end
you need to be careful with capatilization, it is very important, everything has to be exactly as it should.
That will get rid of the error but I should also mention that the code that defines what is used within a function should go in the function aswell.
Code: Select all
function action1()
local wx, wy, ww, wh = windowRect(getWin());
mouseSet(wx + ww-296, wy+ wh-264);
mouseLClick();
yrest(5000);
end
when you define a value like the wx as an example, it will stay that value until redifined, so by putting that code into the function those values will be redifined when ever the function is called, so the function will always be using up to date values for the position of the window.
Re: Using micromacro with smartphone app via PC?
Posted: Fri Oct 05, 2012 2:20 am
by Atlas123
It works a treat
I am crying of happiness :')
Another thing... I was trying the click and drag and the closest I got was:
Code: Select all
local wx, wy, ww, wh = windowRect(getWin());
mouseSet(wx + ww-260, wy+ wh-42);
mouseLHold ();
yrest (2000);
mouseMove (50,0)
yrest(2000);
mouseLRelease();
It moves from and to the right location but it does not "drag the screen" to move it...
The yrest are not needed maybe but i thought it would help
Re: Using micromacro with smartphone app via PC?
Posted: Fri Oct 05, 2012 2:39 am
by Atlas123
I also tried adding with the missing semicolon
Re: Using micromacro with smartphone app via PC?
Posted: Fri Oct 05, 2012 4:27 am
by lisa
did you have the app window as focus?
Since you are using MM to do mouse clicks and such you need to make sure that the app window has focus or it won't work.
you could do a little count down code
Code: Select all
local count = 10
repeat
print(count)
yrest(1000)
count = count - 1
until count == 0
Do that before you call any functions, so you will see a countdown on MM until it starts to do the code.
Re: Using micromacro with smartphone app via PC?
Posted: Fri Oct 05, 2012 4:44 am
by lisa
So something like this.
Code: Select all
local windowList = findWindowList("*","TvnWindowClass");
if( #windowList == 0 ) then
print("You need to run Some App first!");
return 0;
end
function getWin()
if( __WIN == nil ) then
__WIN = windowList[1]
end
return __WIN;
end
function getProc()
if( __PROC == nil or not windowValid(__WIN) ) then
if( __PROC ) then closeProcess(__PROC) end;
__PROC = openProcess( findProcessByWindow(getWin()) );
end
return __PROC;
end
--add code after here to do what you want.
local count = 10
repeat
print(count)
yrest(1000)
count = count - 1
until count == 0
function action1()
local wx, wy, ww, wh = windowRect(getWin());
mouseSet(wx + ww-296, wy+ wh-264);
mouseLClick();
yrest(5000);
end
function action2()
local wx, wy, ww, wh = windowRect(getWin());
mouseSet(wx + ww-260, wy+ wh-42);
mouseLHold ();
yrest (2000);
mouseMove (50,0)
yrest(2000);
mouseLRelease();
end
action1()
action2()
Re: Using micromacro with smartphone app via PC?
Posted: Fri Oct 05, 2012 12:09 pm
by Atlas123
I saw the countdown on MM but no drag on the screen...
Re: Using micromacro with smartphone app via PC?
Posted: Fri Oct 05, 2012 8:01 pm
by lisa
did you make sure the app was the focus?
Re: Using micromacro with smartphone app via PC?
Posted: Sat Oct 06, 2012 3:32 am
by Atlas123
OHHH!...
I guess putting the window in focus means clicking on the APP window to "focus" on the APP window? ^^|
... Please do not bang your head on the wall...
I have done that and it will still not drag...
Re: Using micromacro with smartphone app via PC?
Posted: Sat Oct 06, 2012 6:12 am
by lisa
lol ohh well, not sure how to do a dragging motion then.
If it was me I would probably use CE to find something but if you haven't used CE before it would be far to much to teach that without banging my head against the wall lmao
There is an attachmouse function but I thought that doing attach included the mouse aswell, not sure. Admin might know
Re: Using micromacro with smartphone app via PC?
Posted: Sat Oct 06, 2012 8:03 am
by lisa
it might sound funny but you might need to detach from the app for the mouse to interact with it.
When you did your testing were the mouse clicks working on it?
I have only ever done mouse clicks on a window once and I did need to detach for it to work, was a while ago when I wrote it.
So try this.
Basically everything exactly the same as I posted last time but instead of
do
Code: Select all
detach()
action1()
attach(getWin())
detach()
action2()
attach(getWin())
And yes make sure the App has the window focus.
Re: Using micromacro with smartphone app via PC?
Posted: Sat Oct 06, 2012 12:45 pm
by Atlas123
Tried it but same results... (mouse moves from location A to location B but no drag)
Just in case here is the code (slightly different action as i do the single action on the relevant screen I need to drag for testing)
Code: Select all
local windowList = findWindowList("*","TvnWindowClass");
if( #windowList == 0 ) then
print("You need to run Some App first!");
return 0;
end
function getWin()
if( __WIN == nil ) then
__WIN = windowList[1]
end
return __WIN;
end
function getProc()
if( __PROC == nil or not windowValid(__WIN) ) then
if( __PROC ) then closeProcess(__PROC) end;
__PROC = openProcess( findProcessByWindow(getWin()) );
end
return __PROC;
end
--add code after here to do what you want.
local count = 10
repeat
print(count)
yrest(1000)
count = count - 1
until count == 0
function action1()
local wx, wy, ww, wh = windowRect(getWin());
mouseSet(wx + ww-260, wy+ wh-42);
mouseLHold ();
yrest (2000);
mouseMove (50,0)
yrest(2000);
mouseLRelease();
end
detach()
action1()
attach(getWin())
Is it possible, if this was to work ok on a window, it may not work on this window? I think Admin mentioned (on a different post for something else) that an action can feel the same but the code behind maybe be different.
Re: Using micromacro with smartphone app via PC?
Posted: Sat Oct 06, 2012 2:18 pm
by Administrator
Try using attachKeyboard() instead of attach(). This means it'll use the physical mouse instead but continue using pseudo keyboard input via posting events.
Re: Using micromacro with smartphone app via PC?
Posted: Sun Oct 07, 2012 1:34 pm
by Atlas123
Sorry tried several things but mostly got nill value errors or wrong parameters...
How should I use attachkeyboard()?
I did look in the forum but not actual examples on how to use it...
Re: Using micromacro with smartphone app via PC?
Posted: Sun Oct 07, 2012 6:45 pm
by lisa
try this.
Code: Select all
local windowList = findWindowList("*","TvnWindowClass");
if( #windowList == 0 ) then
print("You need to run Some App first!");
return 0;
end
function getWin()
if( __WIN == nil ) then
__WIN = windowList[1]
end
return __WIN;
end
function getProc()
if( __PROC == nil or not windowValid(__WIN) ) then
if( __PROC ) then closeProcess(__PROC) end;
__PROC = openProcess( findProcessByWindow(getWin()) );
end
return __PROC;
end
attachKeyboard(getWin())
--add code after here to do what you want.
local count = 10
repeat
print(count)
yrest(1000)
count = count - 1
until count == 0
function action1()
local wx, wy, ww, wh = windowRect(getWin());
mouseSet(wx + ww-260, wy+ wh-42);
mouseLHold ();
yrest (1000);
mouseMove (50,0)
yrest(1000);
mouseLRelease();
end
action1()
Re: Using micromacro with smartphone app via PC?
Posted: Mon Oct 08, 2012 3:23 am
by Atlas123
Hello,
Strange, I had tried something similar, adding where you put the:
But it didnt like the (get(win))...
Your code runs fine, but it will not drag...
Not sure if it makes a difference but the "Drag" area is a section inside the iphone screen (it is not the whole screen that moves just a part)
As I can do the drag with the laptop tactile pad and clicking I thought it should be ok, although I think Admin mentioned on a different post that not all functions work on all games, maybe this is one that would need to much work... ^^