if less than 54 how to write it?

Hints, tips and tricks for newbies

Moderators: JRL, Dorian (MJT support)

Post Reply
dopegek
Newbie
Posts: 2
Joined: Wed Nov 04, 2009 6:14 pm

if less than 54 how to write it?

Post by dopegek » Thu Nov 05, 2009 9:56 pm

hello i have a script with some problems
first one i want to do is selecting a value on an html page then copy it and do an action that reads the clipboard and if the value in the clipboard is less than 54 i want to click at an y coordinate thats in the same y coordinate as the copied value
what gets followed by the results what affect my next action
which you can see when i run a macro
and if its higher i want to set the y coordinates 59 lower
and check again for an value lower then 54
, this is my first script and english isnt my home language so if im looking like a noob you know why:P

this is it so far:

Code: Select all

MouseMove>462,211
LDown
MouseMove>499,211
LUp
Press CTRL
Send>c
Release CTRL
GetClipBoard>data
If>data=<54>
mousemove>755,211
LClick
Macro>C:\Users\kenny's mod\Pictures\macro mafia echt\between base.scp
WaitScreenImage>C:\Users\kenny's mod\Pictures\macro mafia echt\wonwhacked.bmp,10
mousemove>282,972
LCLICK
mousemove>755,211
GetCursorPos>,YY
let>YY=YY+59
MouseMove>462,YY
LDown
MouseMove>499,YY
LUp
GetCursorPos>,YY
let>YY=YY+59
MouseMove>462,YY
LDown
MouseMove>499,YY
LUp
GetCursorPos>,YY
let>YY=YY+59
MouseMove>462,YY
LDown
MouseMove>499,YY
LUp
GetCursorPos>,YY
let>YY=YY+59
thanx so far :)

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

Post by Marcus Tettmar » Mon Nov 09, 2009 6:52 am

Hi,

If I have understood you correctly you want to do something like this:

Code: Select all

GetClipBoard>y_pos
If>y_pos>54
 Let>y_pos=y_pos-59
Endif
MouseMove>755,y_pos
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

dopegek
Newbie
Posts: 2
Joined: Wed Nov 04, 2009 6:14 pm

Post by dopegek » Mon Nov 09, 2009 9:04 am

mtettmar wrote:Hi,

If I have understood you correctly you want to do something like this:

Code: Select all

GetClipBoard>y_pos
If>y_pos>54
 Let>y_pos=y_pos-59
Endif
MouseMove>755,y_pos
no sorry i have explained it on a wrong way
but thanks though
i actually meaned:

getclipboard>data
if Data= less than 54
mousemove>.......
else
if data= higher than 54
mousemove>.............

the red sentences are the sentences that need to get fixed i dont know how to write them
thanks so far :mrgreen:

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

Post by Marcus Tettmar » Mon Nov 09, 2009 3:43 pm

You are almost there:

Code: Select all

GetClipBoard>data
If>data<54
  MouseMove>...
Endif
If>data>54
  MouseMove>...
Endif
But what if data is EQUAL to 54. What would you like to do then? At present the above does nothing if data=54.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

What about non-numeric data.

Post by gdyvig » Mon Nov 09, 2009 4:47 pm

It also does nothing if no data is captured or if the data is non-numeric. Then there is the gray area where the data is alphanumeric, for example "The winning number is G64".

What should happen in these cases?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Nov 09, 2009 6:29 pm

Using the IF function like this: If>data<54 implies that data is a numberic value. This will only work properly with a number.

If data is a string like "The winning number is G64" then you will need to parse out the "64" from the string. This could be done with MidStr or RegEx tools.

Examples: This with MidStr:

Code: Select all

Let>string=The winning number is G64
MidStr>%string%,24,2,data
MessageModal>The data value is %data%
Or this with RegEx:

Code: Select all

Let>string=The winning number is G64
Let>vNeedle=^.*[A-Z]([0-9]{1,})
RegEx>%vNeedle%,%string%,0,vMatch,vMatchCount,1,$1,data
MessageModule>The data value is %data%.
Now use this data value in your IF command.

These two examples are based on the sample string you provided: "The winning number is G64".
If the format of your string changes, then you will need to modify the MidStr or RegEx commands to support those changes.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Nov 09, 2009 8:51 pm

Here is some code to test for numbers/strings

Code: Select all

//Change the value of data on this line to test for different data values.
Let>data=The winning number is G64

// Test for null/missing data
If>data=
    MessageModal>Data is missing
    // Insert code for how to respond
    Goto>Done
EndIf

//Test for number.  Only a number will result = 1
Let>vNumberTest=%data%/%data%
If>%vNumberTest%=1
    GoTo>Test
EndIf

//Data must be a string
MessageModal>Data is a string
MessageModal>Use MidStr or RegEx to parse out the value
// Insert code for how to respond
Goto>Done

Label>Test
If>data=54
    MessageModal>Data equals 54
    // Insert code for how to respond
    Goto>Done
EndIf

If>data<54
    MessageModal>Data is less than 54
   // Insert code for how to respond 
   Goto>Done
EndIf

If>data>54
    MessageModal>Data is greater than 54
    // Insert code for how to respond   
     Goto>Done
EndIf

Label>Done
MessageModal>Done testing
Exit>0
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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