Char's questions

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Char
Newbie
Posts: 7
Joined: Sat Nov 24, 2007 4:59 pm

Char's questions

Post by Char » Sat Nov 24, 2007 5:08 pm

im sure i gonna have many questions, so i made this topic, so the forum wont be filled with bunch of my little topics

my script

Code: Select all

label>start
mousemove>100,100
wait>1
mousemove>200,200
wait>1
goto>start
so after every sec it changes between these locations..

this script works, but i want it to change to 300,300 after every 4 minutes for only once.
how i do it?

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Nov 24, 2007 5:12 pm

Something like this:

Code: Select all

VBSTART
VBEND
VBEval>Timer,startTime

label>start
//how much time has elapsed (seconds)
VBEval>Timer-%startTime%,elapsed
If>elapsed<240
  mousemove>100,100
  wait>1
  mousemove>200,200
  wait>1
Else
  //4 mins elapsed
  MouseMove>300,300
  Wait>1
  //reset timer
  VBEval>Timer,startTime
Endif
goto>start
Last edited by Marcus Tettmar on Sat Nov 24, 2007 6:08 pm, edited 1 time in total.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Char
Newbie
Posts: 7
Joined: Sat Nov 24, 2007 4:59 pm

Post by Char » Sat Nov 24, 2007 5:31 pm

looks nice..i have some questions though

Code: Select all

VBEval>Timer-startTime,elapsed
should there be - or , between time and starttime

and does it mean that i take a timer and starttime? and you define the timer time with the random word "elapsed" ? or elapsed is somekind of function?

and why is this is the 3rd row? does it have to be there? and what it does?

Code: Select all

VBEval>Timer,startTime
and howcome this resents the timer when it says "starttimer"

Code: Select all

  VBEval>Timer,startTime

sorry if too many stupid questions..i want to understand the script too..not only copy/paste the script

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Nov 24, 2007 5:39 pm

The VBScript Timer function returns *seconds since midnight". So the following will return the number of seconds since midnight:

VBEval>Timer,startTime

startTime will be equal to the number of seconds since midnight.

If we wait a few seconds ....
Wait>5

.. then do it again:

VBEval>Timer,startTime

.. startTime will now be about 5 bigger than it was before.

So we can measure elapsed time

VBEval>Timer,startTime
..
..
.. some time later
..
..
VBEval>Timer-%startTime%,elapsedtime

We call Timer again to get the number of seconds since midnight and subtract the original startTime from it. THis will give us elapsed seconds:

VBScript:
VBEval>Timer - %startTime%,elapsedtime

English:
[Seconds since midnight] minus [the seconds since midnight we recorded at starup] must equal [seconds elapsed]

I do hope this makes sense.
Last edited by Marcus Tettmar on Sat Nov 24, 2007 6:12 pm, edited 1 time in total.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Char
Newbie
Posts: 7
Joined: Sat Nov 24, 2007 4:59 pm

Post by Char » Sat Nov 24, 2007 6:02 pm

okay i got it now..
..but it isn't working right..i made this simple script here:

Code: Select all


VBSTART
VBEND

wait>3
VBEval>Timer,startTime
wait>10
VBEval>Timer-startTime,elapsedtime
send>elapsedtime

elapsedtime should be equal to 10 .. but try this script..and check what answer u get..print the elapsedtime to notepad or something


72058.296875
72079.90625


due to this..my old script keeps executing the "elapsedtime>120"

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Nov 24, 2007 6:08 pm

Sorry, my mistake. You need to do:

VBEval>Timer-%startTime%,elapsedTime

I will edit my other posts.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Char
Newbie
Posts: 7
Joined: Sat Nov 24, 2007 4:59 pm

Post by Char » Sat Nov 24, 2007 6:23 pm

ohh thanks..works great now :)

okay now this one...

i have a picture...and i want to move my mouse to a certain colour..
can this be done my MS? or with VB? or smthing?

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Nov 24, 2007 9:47 pm

i have a picture...and i want to move my mouse to a certain colour..
can this be done my MS? or with VB? or smthing?
See:
http://www.mjtnet.com/forum/viewtopic.php?t=2470[/quote]
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Char
Newbie
Posts: 7
Joined: Sat Nov 24, 2007 4:59 pm

Post by Char » Sun Nov 25, 2007 7:18 am

i looked a little bit your code..but it was rather hard..couldn't really understand everything

but here i wrote my own..does this one work?

weird..i couldnt copy my code here... so i uploaded


http://char.planet.ee/code.txt

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Nov 25, 2007 9:15 am

Here's an adaptation of the code I pointed to. This will seek through an area on the screen, defined by the XStart, XStop, YStart and YStop variables. When it finds a pixel who's colour is MY_COLOR, it will move the mouse to that position and then stop.

Code: Select all

Let>XStart=10
Let>XStop=30
Let>YStart=10
Let>YStop=30
Let>MY_COLOR=12632256

Let>x=XStart
Repeat>x
Let>y=YStart
  Repeat>y
    GetPixelColor>x,y,color
    If>color=MY_COLOR
      MouseMove>x,y
      Goto>end
    Endif
    Let>y=y+1
  Until>y>YStop
  Let>x=x+1
Until>x>XStop
Label>end
Define the first 5 variables for the dimensions and colour you want it to stop at.

If you want it to go to all occurrences of that colour then remove the Goto>end line (and replace with whatever other processing is required).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Char
Newbie
Posts: 7
Joined: Sat Nov 24, 2007 4:59 pm

Post by Char » Sun Nov 25, 2007 11:43 am

what does that repeat function do?
how it works?

but atm it scans the screen diagonally..atleast it seems to me like that


Let>y=y+1
Let>x=x+1

u do these both .. so the both coordinates increase...

Code: Select all

XY1 X2 X3 X4 X5 X6 X7 X8 X9 
Y2
Y3
Y4
Y5
Y6
Y7
Y8
Y9
the scanner moves like this ... X1-Y1 X2-Y2 X3-Y3 X4-Y4 X5-Y5 etc
but it doesnt check X1-Y2 or Y2-X7
or im wrong?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sun Nov 25, 2007 1:46 pm

You're wrong. Look where the pairs of repeat/until statements are in the sequence. The y loop from repeat>y to until>y is inside the x loop, so the program will set the x value and run through all the y values before incrementing the x value again.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sun Nov 25, 2007 1:57 pm

You can always use MessageModal> (MDL>) to display values when testing. e.g.

Code: Select all

Let>XStart=10
Let>XStop=15
Let>YStart=10
Let>YStop=15

Let>x=XStart
Repeat>x
Let>y=YStart
  Repeat>y
MDL>x value = %x% y value = %y%
    Let>y=y+1
  Until>y>YStop
  Let>x=x+1
Until>x>XStop
Label>end

Char
Newbie
Posts: 7
Joined: Sat Nov 24, 2007 4:59 pm

Post by Char » Sun Nov 25, 2007 2:08 pm

but how long does the scanning take for ..umm for example

1024*768 screen

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sun Nov 25, 2007 4:16 pm

Char wrote:but how long does the scanning take for ..umm for example

1024*768 screen
It took 73 seconds on mine but it depends on your system.

This script will tell you how long it took to scan a 1024x768 area.

Code: Select all

Let>XStart=0
Let>XStop=1024
Let>YStart=0
Let>YStop=768

Let>x=XStart
VBSTART
VBEND
VBEval>Timer,timerStarted
Repeat>x
Let>y=YStart
  Repeat>y
    Let>y=y+1
  Until>y>YStop
  Let>x=x+1
Until>x>XStop
Label>end
VBEval>Timer-%timerStarted%,timeElapsed
mdl>Scan took %timeElapsed% seconds

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts