Notepad Not Responding

Anything Really. Just keep it clean!

Moderators: JRL, Dorian (MJT support)

Post Reply
claremc
Newbie
Posts: 4
Joined: Thu Jan 23, 2020 8:55 pm

Notepad Not Responding

Post by claremc » Wed Feb 12, 2020 5:03 pm

I am currently trying to rename files based on two different pieces of information in a PDF. One being a business number and the other is a date that the file was submitted. I am able to find both in the file and copy them, but because they are found in very different parts of the file I can't copy them at the same time.

My solution to this problem is to open Notepad to basically just dump the business number first add an underscore and then paste the date after that in the same file to be able to copy them both at the same time and rename the file.

The issue I'm having is with switching windows to paste the business number - haven't been able to get past this part.

Basic logic of what I'm trying to do is as follows:
- open PDF
- find Business Number and copy it
- open Notepad
- paste Business Number
- go back to PDF find the date and copy it
- go back to Notepad and paste the date following the Business Number
- copy the Business Number and date from Notepad
- go back to the PDF and paste as file name

The file name should be as follows:
BusinessNumber_Date.PDF

Here is the portion of my code that isn't working:

//highlight the Business Number (BN)
Wait>0.5
Press Shift
Press Right * 10
Release Shift

//copy the BN
Press CTRL
SendText>c
Release CTRL
Wait>0.5

//open notepad
ChangeDirectory>C:\Windows
RunProgram>C:\Windows\Notepad.exe
WaitWindowOpen>*Untitled - Notepad
Wait>0.5

SetFocus>*Untitled - Notepad
WaitWindowFocused>*Untitled - Notepad
Wait>1

//click onto notepad window
// This was added after it didn't work without clicking onto the window so I believe it has no impact on how
my code is running at the moment
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_18.bmp,WINDOW:*Untitled - Notepad,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LDblClick
Endif

Wait>0.5
Press CTRL
SendText>v
Release CTRL

Wait>0.5
SendText>_

//change focus back to PDF window
//same issue with this and the code that follows commented out
SetFocus>Doc.It PDF Editor 4.5
WaitWindowFocused>Doc.It PDF Editor 4.5


This code opens Notepad but once it gets to that point it freezes. I know that the business number is being copied because when I stop running my script and press CTRL + V it pastes the business number.

This is the first time I am trying to use the same script to manipulate more than one window so any suggestions on what to change/add would be greatly appreciated!
Clare

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 583
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Notepad Not Responding

Post by Dorian (MJT support) » Thu Feb 13, 2020 2:27 pm

Once you have the Business Number in your clipboard, you don't need to paste it and copy it again. Assign it as a variable instead, with GetClipboard

Once it's in the clipboard, use :

Code: Select all

GetClipBoard>BusinessNumber
..now continue to copy the date, and do the same

Code: Select all

GetClipBoard>TheDate
Now join it together. No Notepad required :

Code: Select all

Let>MyFileName=%BusinessNumber%_%TheDate%.pdf
Yes, we have a Custom Scripting Service. Message me or go here

claremc
Newbie
Posts: 4
Joined: Thu Jan 23, 2020 8:55 pm

Re: Notepad Not Responding

Post by claremc » Fri Feb 14, 2020 1:29 pm

Thank you!
Clare

Post Reply