Jump to content
Macro Express Forums

Repeat keeps entering only the first line over and over


Recommended Posts

Hi guys,

This is my first time Macroing. I'm trying to make a simple macro that clicks part of a website then enters data from a CSV file into the text box that opens, then enter is pressed and the website updates itself. Then it repeats until all records in the csv are inserted. 

My issue is when I test the macro it keeps entering the first line record and doesn't move onto the second one. Does anyone know why? Also is there a way to make it so the macro stops after all the records are entered?  thank you in advance

Names.mex

Link to comment
Share on other sites

 

Hi Jim,

 

It would be easier to help if we had your CSV file and the URL (or simplifed non-confidential examples) , and also a much fuller explanation of the task.

 

Are you copying each record of your CSV file into an identical location of successive different web pages? If so, where are the commands that open subsequent pages? Or, are there just two records in the CSV file, copied to two text fields of the web page? Or two fields in each record?

 

It also looks like you're using integer variable %C% but I don't see where it gets incremented?

 

And is your macro deliberately simplified to a mere two repetitions of the main loop?

 

I don't follow your logic. Could you spell out in full the sequence of events you want to emulate please? Amongst other things perhaps you're not adding an empty line between the two records, so overwriting the first. (Although you say it's the second you're seeing?)

 

Are you trying to use the variable T as an array? If so you have not defined it as such.

 

I'd recommend you tidy up your draft recorded macro by replacing those arbitrary delays, say with

  Delay: 0.1 seconds

 

A simple left click is usually OK after a mouse move. And did you first try navigating to the location(s) with Tabs, a preferable method; pixel locations will differ for each of us if we ever try to run your macro on the specified page. You're also apparently selecting two different targets on the page but only the second becomes one? I assume the vertical resolution of your screen must be larger than my 1200 for that to be a valid location?

 

Note that unless your browser is always maximised (or has a consistent size and position) it's safer to set Mouse Move commands relative to the window, not screen.

 

Terry

Link to comment
Share on other sites

Meanwhile here's a macro using the more accessible Notepad. Study that and try adapting it to your requirement.

Come back if you need further help

 

// Demo for @Jimbojones
// Set a variables for TAB
Variable Set to ASCII Char 9 to %TAB% // Set TAB
// Presumably you want  to place the text cursor in a box on some already open web site.
// In my version I'll activate 'Untitled - Notepad' (already open).
// The macro will use the following CSV file, containing 5 records, each with two fields:
Record #1, Jim
Record #2, John
Record #3, Jack
Record #4, Jill
Record #5, Janet
Window Activate: Untitled - Notepad
Wait for Window Title: Untitled - Notepad
// For each RECORD in the FILE, type the first FIELD into Notepad.
ASCII File Begin Process: "C:\Users\jimrm\Desktop\Names.csv" (Comma Delimited Text (.csv))
  Text Type (Simulate Keystrokes): %T[1]%
  Delay: 0.1 seconds
  // As a crude simulation of navigating to another location on the same web page, TAB before entering the remaining field.
  Text Type (Simulate Keystrokes): %TAB%
  Delay: 0.1 seconds
  // For each RECORD, type the second FIELD into the same line
  Text Type (Simulate Keystrokes): %T[2]%<ENTER>
  Delay: 0.1 seconds
ASCII File End Process
Delay: 0.1 seconds

 

<COMMENT Value="Demo for @Jimbojones"/>
<COMMENT Value="Set a variables for TAB"/>
<VARIABLE SET TO ASCII CHAR Value="9" Destination="%TAB%" _COMMENT="Set TAB"/>
<COMMENT Value="Presumably you want  to place the text cursor in a box on some already open web site."/>
<COMMENT Value="In my version I'll activate 'Untitled - Notepad' (already open)."/>
<COMMENT Value="The macro will use the following CSV file, containing 5 records, each with two fields:\r\nRecord #1, Jim\r\nRecord #2, John\r\nRecord #3, Jack\r\nRecord #4, Jill\r\nRecord #5, Janet"/>
<WINDOW ACTIVATE Title="Untitled - Notepad" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
<WAIT FOR WINDOW TITLE Title="Untitled - Notepad" Partial="TRUE" Wildcards="FALSE" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<COMMENT Value="For each RECORD in the FILE, type the first FIELD into Notepad."/>
<ASCII FILE BEGIN PROCESS Filename="C:\\Users\\jimrm\\Desktop\\Names.csv" Format="CSV" Start_Record="1" Process_All="TRUE" Records="1" Variable="%T%" Start_Index="1" Parse_Blank_Lines="FALSE" Clear_Array="TRUE"/>
<TEXT TYPE Action="0" Text="%T[1]%"/>
<DELAY Flags="\x01" Time="0.1"/>
<COMMENT Value="As a crude simulation of navigating to another location on the same web page, TAB before entering the remaining field."/>
<TEXT TYPE Action="0" Text="%TAB%"/>
<DELAY Flags="\x01" Time="0.1"/>
<COMMENT Value="For each RECORD, type the second FIELD into the same line"/>
<TEXT TYPE Action="0" Text="%T[2]%<ENTER>"/>
<DELAY Flags="\x01" Time="0.1"/>
<ASCII FILE END PROCESS/>
<DELAY Flags="\x01" Time="0.1"/>

 

NOTE typo: The Comment directly before the ASCII File Begin Process command should of course be the first command within it. (Apparently it's hard to edit code boxes here!)

 

SORTB NAMES-MyVersion.mex

Link to comment
Share on other sites

Welcome JimboJones,


Terry has offered a treasure trove of sound advice! Not much I can add. But keep two things in mind:


1. The variable %T% has been flagged as an array, but in your macro, it only has one element. If you need the variable to hold more than one value, you'll need to set the size of %T% to something larger.


2. In general, you do not need to do this in Macro Express:


  Mouse Left Button Down
  Mouse Left Button Up


...because this simpler code usually works:


  Mouse Left Click


But the decision is yours. It's a matter of style. Similarly, some people find this...


    Text Type (Simulate Keystrokes): <CTRLD>s<CTRLU>


...a more reliable way to hold down the Ctrl key and press S than this...


    Text Type (Simulate Keystrokes): <CONTROL>s

 

But I find the second, simpler example works almost always. But there are exceptions!

 

Link to comment
Share on other sites

Hey guys, my apologies for not replying sooner. I'm absolutely slammed and trying to automate some processes in order to be less slammed. So a massive thank you to all replies. I'm planning to sit down and go through them shortly and figure them out. You guys a legends and if anyone is in Sydney Australia I'll happily buy you a beer. 

 

Link to comment
Share on other sites

Apologies for the poor description of what I'm trying to do. Hopefully this will explain things. 

 

I am a photographer, I am shooting close to 100 families per day but only for a little while so a more permanent solution isn't needed yet. I am using Zenfolio and need to create galleries for every family. This is my workflow to create those galleries. I cant find a way in zenfolio to bulk create galleries.  

 

I have a .CSV file with the last name of each family in the first column running down.

 

I have the zenfolio page open and set as the active page, this is a process I can set up and let run for a few hours and don't need it to open or activate any page, unless that is useful in making it more reliable.  

 

1. click arrow for dropdown menu 

 

1.thumb.jpg.70df832fe9abdf10b121f819da09f08e.jpg

2. Click new gallery

2.jpg.dafb06a004155938e0ba1e9510cd5d93.jpgNames.csv

 

3. Text box opens with text window active and ready to type in, I want the macro to insert the name of the person in the first row of the csv file then press <enter>, then wait 3 seconds and the page will refresh itself. Then repeat the process but the next time insert the 2nd name in the list  then the third etc etc

 

I am having difficulty getting the macro to move to the next line in the CSV after each loop.

 

 3.jpg.f3ce60768b0c23c98fd6e1e43d29b0f4.jpg

 

 

Link to comment
Share on other sites

Can you show us your latest code, with comments if each step is not obvious, matching the explanation you gave.

 

Have you successfully written simpler macros before this? It does sound as if you need to study the basic stuff and work through simple examples.

 

Did you try running the demo I wrote for you a week ago? Do you understand what it is doing? I don’t know Zenfolio, and I suspect none of us regulars here do, so as I said it’s best to work with a more accessible application, like Notepad.

 

Meanwhile I assume you’re implying that the obvious step of using the Enter or Arrow Down command to navigate to the next entry does not work?

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...
×
×
  • Create New...