Beginner needing help with very first script

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
RDokter
Newbie
Posts: 3
Joined: Mon Jan 25, 2016 6:22 pm

Beginner needing help with very first script

Post by RDokter » Mon Jan 25, 2016 7:56 pm

Hi all,

As the subject suggests i'm a beginner working on my very first script and i'm already struggling :oops:

[snippet=]
\\Providing case number details to the macro
\\

SetFocus>Update cases.txt - Notepad
WaitWindowOpen>Update cases.txt - Notepad

\\Selecting case ID
\\

Press CTRL
Press SHIFT
Press RIGHT
Release CTRL
Release SHIFT
Release RIGHT

Press CTRL
Send>c

\\Entering Case ID into OPT
\\

SetFocus>SR-Dash* |<------- suspect problem is here
WaitWindowOpen>SR-Dash* |<------- and here

Wait>3
Press F12
[/snippet]

The problem is once the Setfocus function pointed out above runs the script stops, the keystrokes in bold don't run, i think its because the window title is not the correct syntax the reason i think this because the title has variables in it.

The window is from a support desks ticketing application and the window title contains the current ticket number, the customer name and then the application name and release version, this is then shown in the following manner(without quotes):

"ID: xxxxxxxxxx / Name: yyyyyyyyyyyyy - SR-Dash z.z.z.zz"

Because of the variables I tried simplifying it by using the "Setfocus>SR-Dash*" but don't think its right as it doesn't go any further...

The window is brought to the front but that's it, no keystrokes are made.

Any help or advice to progress would be appreciated.

Thanks in advance,

EDIT: I found the issue in the above snippet:

[snippet=]Press CTRL
Send>c
|<------- problem is here, i didn't add a "release" function
\\Entering Case ID into OPT
\\

SetFocus>SR-Dash*
WaitWindowOpen>SR-Dash*[/snippet]

I do how ever have a new issue where the script gets stuck in the next steps:

[snippet=]\\Opening chosen case
\\

Let>k=1
Repeat>k
Press Tab
Wait>0.2
Let>k=k+1
Until>k=3

Wait>0.5
Press ENTER[/snippet]

As the \\ note above suggests, the previous F12 opens a small dialogue where the "case ID" is pasted with CTRL V and then TAB is pressed until the correct button is highlighted, at which point ENTER is supposed to be pressed to proceed, but this doesn't seem to work, everything works up until the correct button is highlighted but that is where it ends the ENTER doesn't get activated so the action does not proceed, can any one help ?

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Re: Beginner needing help with very first script

Post by Jerry Thomas » Tue Jan 26, 2016 3:57 pm

Pasting the value into a field isn't picked up by the dialog - this is a common problem.
Typically you need to put the screen cursor in the field and then enter the value.

Try using the "FindObjectsWizard" (look under "Window Objects" in the Code Builders tab) and see if that 'dirties' the dialog and enables the Enter button.

Another way to do it is to put the mouse cursor over the field and Left Click, then Send the value.
This is easy on a dialog where the field is always in the same place within the dialog using "MouseMoveRel".

Also, you should be able to use "PushButton", or "MouseOver" + LClick instead of Tabbing to the button. Both are faster and more reliable.
Thanks,
Jerry

[email protected]

RDokter
Newbie
Posts: 3
Joined: Mon Jan 25, 2016 6:22 pm

Re: Beginner needing help with very first script

Post by RDokter » Wed Jan 27, 2016 7:09 am

Hi Jerry,

Thanks for the suggestions i'll give it a try and see how I get along.
I'm sure to be back here if I get stuck again :mrgreen:

RDokter
Newbie
Posts: 3
Joined: Mon Jan 25, 2016 6:22 pm

Re: Beginner needing help with very first script

Post by RDokter » Wed Jan 27, 2016 12:48 pm

RDokter wrote:Hi Jerry,

Thanks for the suggestions i'll give it a try and see how I get along.
I'm sure to be back here if I get stuck again :mrgreen:
Hi Jerry, It Worked!, Thanks so much for the suggestions I'm wondering if you could help me with the next step, I think however i need to give you more of an explanation of what i want my macro to do.

Basically I need my macro to Select and Copy a 10 digit number form a list of these numbers that will be manually entered into a text file labelled "Update Cases".
Once copied it then needs to enter this into a search dialog which opens the corresponding Ticket (or "case") in a ticket logging application and send text to the relevant text box, Save and then return back to the list in the text file to erase the number that was just handled.

Now the functions explained above have been sorted and are working.

what I need help with is creating the loop that tells the Macro to continue running by selecting the next number in the list until no more numbers are left in the list.

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Re: Beginner needing help with very first script

Post by Jerry Thomas » Wed Jan 27, 2016 3:58 pm

Glad to hear you are making progress!

Reading from a file is much better than than opening the file in Notepad and then selecting and copying.
It's faster and much more reliable!
You just read from the text file until you get an End of File indicator.
Check the Help for "ReadLn"

It has an example of a While Loop that reads until it runs out of data.
The 5th line where the sample just shows the data, is where you would call a subroutine to put the data where you need it, etc.
Thanks,
Jerry

[email protected]

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