Jump to content
Macro Express Forums

Macro Workshop: Check For Library Books


mebrown1110
 Share

Recommended Posts

Hi all. I've been using Macro Express rather lightly and while this is probably a lightweight macro compared to what others do, it was a really big deal for me that required bits of last weekend to build and that I'm still tweaking.

 

I use the subject line "Macro Workshop" to hopefully indicate that this thread could be a learning lab for newbies. If old hands have suggestions, please do so! I ain't no programmer.

 

SITUATION

I'm at Amazon and would like to see if the book I'm looking at is available at my local library. Now, if my library's catalog was web-based, I could use the bookmarklets described at the LibraryLookup project page.

 

But my library uses a Java-based lookup engine called Webpac. That requires going to the library site, starting Webpac, clicking a link, typing in the title, and blah. After a year of doing this, light dawned on Marblehead: why not write a macro?

 

THE MACROS

I use 3 macros:

"Are Amazon books at Durham library?" -- the main routine. Highlight the book title on the Amazon page (or any other app) and then press the hotkey.

 

{Launch Webpac} -- a subroutine I suppose I don't strictly need but it makes debugging much easier. I don't expect to reuse this routine anywhere else. Its job is to detect when Webpac is fully loaded. This is tricky because the time it takes the Java app to load is variable. Thanks to this forum for the Repeat loop trick.

 

"Put book title into text file" -- I originally had this hanging off the end of the main routine. But could never get the timing right and decided it was better to make it a separate hotkey. It specifies which file to save the book title to: a "wishlist" for bargain books (though Amazon's wishlist would do as well) or "check out from the library" list, which I can print out when I next go to the library. I did this mainly to play with the multiple choice menu command.

 

=====

 

"Are Amazon books at Durham library?"

// With the title text of a book selected on Amazon web page, feed that text

// to the Durham Library Webpac to see if the book is available

// ===============================

// Copy selected text to variable

Macro Run: { Save Clipboard }

Clipboard Empty

Clipboard Copy

Variable Set String %T97% ""

Variable Set String %T97% from Clipboard

// If we have a webpac window already running, switch to it

If Window Title "Dynix WebPAC - Mozilla Firefox" is running

Activate Window: "Dynix WebPAC - Mozilla Firefox"

Wait For Window Title: "Dynix WebPAC - Mozilla Firefox"

Else

Macro Run: {Launch Webpac}

Wait For Window Title: "Dynix WebPAC - Mozilla Firefox"

Delay 5 Seconds

End If

// Click on the Library Catalog link and enter the book title

Activate Window: "Dynix WebPAC - Mozilla Firefox"

Mouse Move Screen 127, 277

Delay 2 Seconds

Mouse Left Button Double Click

Delay 2 Seconds

Text Type: %T97%<ENTER>

 

=====

{Launch Webpac}

// Set variable to the URL

Variable Set String %T2% "http://www.durhamcountylibrary.org/webpacj/"

// Launch a new firefox window

Program Launch: "firefox.exe"

Wait For Window Title: "Mike - Mozilla Firefox"

Delay 2 Seconds

Activate Window: "Mike - Mozilla Firefox"

// Specify URL

Text Type: <F6>%T2%<ENTER>

Delay 2 Seconds

// Wait for page to load

Wait For Window Title: "Dynix WebPAC - Mozilla Firefox"

Activate Window: "Dynix WebPAC - Mozilla Firefox"

Repeat Until %N1% = 0

Get Pixel: Screen Coords: 126,497 into %N1%

Delay 10 Milliseconds

Repeat End

 

=====

"Put book title into text file"

// Put book title into a text list

Variable Set String %T8% "A"

Multiple Choice Menu: Processing Book Title

If Variable %T8% = "A"

Variable Modify String: Append %T97% to Text File <-"bookstogetfromthelibrary.txt"

End If

If Variable %T8% = "B"

Variable Modify String: Append %T97% to Text File <-"bookstobuy.txt"

End If

 

=====

 

Well, that's my little macro. It works for me :)

 

Mike

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...