Using micromacro with smartphone app via PC?

Ask questions about cheating in any games you would like. Does not need to pertain to MicroMacro.
Message
Author
Atlas123
Posts: 37
Joined: Wed Jul 13, 2011 8:31 pm

Re: Using micromacro with smartphone app via PC?

#21 Post by Atlas123 » Thu Oct 04, 2012 4:00 am

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?

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Using micromacro with smartphone app via PC?

#22 Post by lisa » Thu Oct 04, 2012 5:21 am

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.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Atlas123
Posts: 37
Joined: Wed Jul 13, 2011 8:31 pm

Re: Using micromacro with smartphone app via PC?

#23 Post by Atlas123 » Thu Oct 04, 2012 7:06 am

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)

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Using micromacro with smartphone app via PC?

#24 Post by lisa » Thu Oct 04, 2012 10:19 am

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()
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Atlas123
Posts: 37
Joined: Wed Jul 13, 2011 8:31 pm

Re: Using micromacro with smartphone app via PC?

#25 Post by Atlas123 » Thu Oct 04, 2012 11:47 am

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'

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Using micromacro with smartphone app via PC?

#26 Post by lisa » Thu Oct 04, 2012 7:09 pm

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.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Atlas123
Posts: 37
Joined: Wed Jul 13, 2011 8:31 pm

Re: Using micromacro with smartphone app via PC?

#27 Post by Atlas123 » Fri Oct 05, 2012 2:20 am

It works a treat 8-) 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

Atlas123
Posts: 37
Joined: Wed Jul 13, 2011 8:31 pm

Re: Using micromacro with smartphone app via PC?

#28 Post by Atlas123 » Fri Oct 05, 2012 2:39 am

I also tried adding with the missing semicolon

Code: Select all

mouseMove (50,0);

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Using micromacro with smartphone app via PC?

#29 Post by lisa » Fri Oct 05, 2012 4:27 am

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.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Using micromacro with smartphone app via PC?

#30 Post by lisa » Fri Oct 05, 2012 4:44 am

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()

Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Atlas123
Posts: 37
Joined: Wed Jul 13, 2011 8:31 pm

Re: Using micromacro with smartphone app via PC?

#31 Post by Atlas123 » Fri Oct 05, 2012 12:09 pm

I saw the countdown on MM but no drag on the screen...

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Using micromacro with smartphone app via PC?

#32 Post by lisa » Fri Oct 05, 2012 8:01 pm

did you make sure the app was the focus?
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Atlas123
Posts: 37
Joined: Wed Jul 13, 2011 8:31 pm

Re: Using micromacro with smartphone app via PC?

#33 Post by Atlas123 » Sat Oct 06, 2012 3:32 am

OHHH!... :o 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... :roll:

I have done that and it will still not drag...

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Using micromacro with smartphone app via PC?

#34 Post by lisa » Sat Oct 06, 2012 6:12 am

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
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Using micromacro with smartphone app via PC?

#35 Post by lisa » Sat Oct 06, 2012 8:03 am

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

Code: Select all

action1()  
action2()
do

Code: Select all

detach()
action1()  
attach(getWin())
detach()
action2()
attach(getWin())
And yes make sure the App has the window focus.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Atlas123
Posts: 37
Joined: Wed Jul 13, 2011 8:31 pm

Re: Using micromacro with smartphone app via PC?

#36 Post by Atlas123 » Sat Oct 06, 2012 12:45 pm

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.

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Using micromacro with smartphone app via PC?

#37 Post by Administrator » Sat Oct 06, 2012 2:18 pm

Try using attachKeyboard() instead of attach(). This means it'll use the physical mouse instead but continue using pseudo keyboard input via posting events.

Atlas123
Posts: 37
Joined: Wed Jul 13, 2011 8:31 pm

Re: Using micromacro with smartphone app via PC?

#38 Post by Atlas123 » Sun Oct 07, 2012 1:34 pm

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...

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Using micromacro with smartphone app via PC?

#39 Post by lisa » Sun Oct 07, 2012 6:45 pm

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() 

Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Atlas123
Posts: 37
Joined: Wed Jul 13, 2011 8:31 pm

Re: Using micromacro with smartphone app via PC?

#40 Post by Atlas123 » Mon Oct 08, 2012 3:23 am

Hello,

Strange, I had tried something similar, adding where you put the:

Code: Select all

 attachKeyboard(getWin())
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... ^^

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests