Jump to content
Macro Express Forums

macro does not execute like manual typing


Recommended Posts

<COMMENT Value="CTRL Down  SHIFT Down B CTRL Up Shift Up to select Bookmarks Bar"/>
<TEXT TYPE Action="0" Text="<CTRLD><SHIFTD>B<CTRLU><SHIFTU>"/>
<DELAY Flags="\x01" Time="0.1"/>
<COMMENT Value="Down to select Bookmarks Manager"/>
<TEXT TYPE Action="0" Text="<ARROW DOWN>"/>
 

I want a macro to automate the export of Chrome Bookmarks. I've run into two difficulties - for the first I managed to create a work-around  as shown above - but I would like to reduce that to one line of code. The second issue I will post IN THIS THREAD but separately, because I fear confusion between the two issues if posted here.  

Link to comment
Share on other sites

You could also access the file directly.

"C:\Users\[userprofile]\AppData\Local\Google\Chrome\User Data\Default\Bookmarks" (no file extension)

It's a JSON file so copy it wherever you want. You might be able to just drop it into the destination folder to overwrite it. Or you could use TextFile Process on it to get the bits you want. 

 

BTW, this is a cool online JSON viewer.

Link to comment
Share on other sites

Starting with your second suggestion :  I did that and found that the file formats are not the ones required for import; that is why I went for Export.

 

Your first suggestion I do not understand - I was expecting code and it looks like code, but I have no idea how to apply it. However you wrote 'go to', and it does not look like a URL either.

Link to comment
Share on other sites

Since you didn't specify, I assumed you were going to be importing it into a separate instance of Chrome. What format is expected?

 

It is MEP code. Open MEP macro editor. Paste  that in. et voila, a command is born. 

 

That command will navigate you directly to the chrome web page that is your bookmarks manager. Why use buttons when you can simply load it like any web page. 

Link to comment
Share on other sites

Once in the Bookmarks page, I see the key sequence as tab, enter, down arrow, down arrow, Enter. From then on it's a normal File Save As dialog. I recommend you use Windows Controls commands in MEP from there if you want to change anything. Remember you don't need to navigate to a folder, you can simply put the whole path in the File Name field. 

Link to comment
Share on other sites

If your program supports Tab or CSV import, I'd process the file with Text File Process. Each line that begins with something I want, like the URI and title, I'd just write those all out to the Tab/CSV file. But I'm unsure what formats your destination program will accept.

BTW, most browsers will automatically import bookmarks from other browsers on your machine. You might want to look at the import features of your destination app if it's a browser. 

Link to comment
Share on other sites

Firstly to explain my motivation - I have had to uninstall and re-install Chrome (or thought I had to anyway). That is when I realised much effort could have been spared if I had saved the Chrome bookmarks - as I do routinely for Firefox. So I researched the location for Chrome bookmarks and saved them. I thought I better test HOW to restore the bookmarks when needed and the word IMPORT came to mind - if there are other methods for Chrome, I do not know them. The import mechanism does not 'see' the bookmarks I had saved. That is when I thought the obvious thing to import is an Export.

 

'Why use buttons ?' - well I did not know any better way. I will try your suggestion. However - it seems to imply that my bookmarks are in the ether/cloud/out-there, and I doubt if that is the case. If it IS the case, it is so against my wishes.

 

'Would you like me to make you a screen recording off how to paste commands in MEP Script Editor? ' Thank you for the offer, but I see merit in struggling with it FIRST before being shown solutions to problems I am not aware of.

 

My difficulties start AFTER the Bookmarks page - in the Bookmarks Manager page, where a manual TAB opens its menu (with the export option), but the macro's TAB does NOT open the menu.

 

'You might want to look at the import features of your destination app if it's a browser. '

The destination is Chrome and at first it seemed to accept only Firefox bookmarks - but I got over that hurdle.

 

'If your program supports Tab or CSV import' - My program is Chrome.

Link to comment
Share on other sites

You don't understand. Open your bookmark manager. Look at the address. All Chrome settings and such ARE a web page with the protocol "chome://". It's not going out ot the web, it's just pointing to its own internal web server. Why can you just try it?

Look here. Go to the bookmarks manager and look at the address. Look below. See how the URL is chrome://. If you use "settings" instead of "bookmarks" you get to the Chrome settings. Try it. You're navigating to a web page.

image.png.de00f330322353e20b74f8b3c8a463b1.png

I love how people spend so much time writing about how they don't understand and are not willing to try my suggestion instead of taking 30 seconds to do as I say. 🙂 Trust me. Open MEP and create a test macro. Copy that text. Paste it in the editor. Click the debug run button. Chrome should pop up at the bookmarks page. 

Link to comment
Share on other sites

This seems like a lot of effort and time to export the bookmarks. Why write a macro to automate something you're going to do once?

 

Also when you log back into Google after reinstalling, all your bookmarks will still be there if you have sync on.

image.png.5d40925f0411ea574f2ea62b4cdf7bcb.png

 

image.png

Link to comment
Share on other sites

I don't have or like SYNC.

I hope I do not have to utilise the export I am trying to make, but my experience of losing my bookmarks, makes me think this is a worthwhile effort. I might import rarely, but I want to export routinely to have the latest version available when needed. It is NOT the bookmarks page I am trying to reach - my macro has already achieved that. I am trying to open the menu of the Bookmarks Manager to access its EXPORT option.

 

" Why can you just try it?" I have tried it and you are right, the URL is 'chrome:  bookmarks' as you claim.

 

Link to comment
Share on other sites

<VARIABLE SET INTEGER Option="\x00" Destination="%Delay%" Value="300"/>
<DELAY Flags="\x02" Time="%delay%"/>
<TEXT TYPE Action="0" Text="<TAB>"/>
<DELAY Flags="\x02" Time="%delay%"/>
<TEXT TYPE Action="0" Text="<ENTER>"/>
<REPEAT START Start="1" Step="1" Count="5" Save="FALSE"/>
<TEXT TYPE Action="0" Text="<ARROW DOWN>"/>
<DELAY Flags="\x02" Time="%delay%"/>
<END REPEAT/>
<TEXT TYPE Action="0" Text="<ENTER>"/>
Variable Set Integer %Delay% to 300
Delay: %delay% milliseconds
Text Type (Simulate Keystrokes): <TAB>
Delay: %delay% milliseconds
Text Type (Simulate Keystrokes): <ENTER>
Repeat Start (Repeat 5 times)
  Text Type (Simulate Keystrokes): <ARROW DOWN>
  Delay: %delay% milliseconds
End Repeat
Text Type (Simulate Keystrokes): <ENTER>

THis is both in code and the command text. Once at the Bookmarks page, this works perfectly for me. Can you try this?

Link to comment
Share on other sites

So now you're nearly set. Do what I did in my first post then do the part above. All that's left is saving the file.

Oh, in the code above you can reduce the delay amount in the first line. Also you could eliminate the delays and use Keystroke Speed instead. I wanted to be able to mess with them individually for testing. Also then you could consolidate all the text type commands into one command then. 

Link to comment
Share on other sites

Sad to say - more obstacles

 

1. the code looks unfamiliar to me

2. when I pasted it in where my code for TAB had been, it showed a single entry that appeared to be a repeat of all YOUR code above that point

3. When I tried to run it, there was an objection to the NAME :  ExportChromeBookmarks - I chose to not change it

4. It told me that delays were unspecified, and when I offered to set values, opened a dialog that I'm unfamiliar with.

     It offered to set them automatically - I accepted.

5. When I ran the macro, it stopped where my own efforts had also stopped - NO PROGRESS.

 

 

 

 

Link to comment
Share on other sites

The next thing I would do is create a "Get Control" for the file name text field control. Then wait for control to exist, then set the control text to the file you want. Duun. Beware that the SaveAs box might go so fast you won't see it. 

Make sure to use these options:

image.png.6dabb40d32069151a8da86d77fd69761.png

I haven't tested it, but it should look something like this:

Get Control: (CHROME.EXE) Using z-order -> %FileNameField%
Get Control: (CHROME.EXE) Using z-order -> %SaveButton%
Wait for Control until %FileNameField% "Exists"
Text Type (Send Text Directly to Control %FileNameField%): c:\MyFileName.html
Mouse Click on Control %SaveButton%
<GET CONTROL Flags="1" Program_Name="CHROME.EXE" Class="#32770" Title="Save As" Control="\"DUIViewWndClassName\",\"1\",\"DirectUIHWND\",\"1\",\"FloatNotifySink\",\"1\",\"ComboBox\",\"1\",\"Edit\",\"1\"" Variable="%FileNameField%" Caption="Save As" Partial="FALSE" Wildcards="FALSE"/>
<GET CONTROL Flags="1" Program_Name="CHROME.EXE" Class="#32770" Title="Save As" Control="\"Button\",\"22\"" Variable="%SaveButton%" Caption="Save As" Partial="FALSE" Wildcards="FALSE"/>
<WAIT FOR CONTROL Control="%FileNameField%" Option="\x00" Indefinite="TRUE" Hours="0" Minutes="0" Seconds="0"/>
<TEXT TYPE Action="2" Control="%FileNameField%" Text="c:\\MyFileName.html"/>
<MOUSE CLICK ON CONTROL Clicks="\x01" Control="%SaveButton%" Button="\x00" Center="TRUE"/>

 

Link to comment
Share on other sites

Don't try to put my code in your macro. Just example it and make your own commands. Or take all of the code I've send and put it in one new macro file. You will need to do a 'save" command where it will prompt you to create all the variables. 

If at that point you don't understand a command, then ask me which. 

Oh! after the command to navigate to the web page, you need a delay. 

Now you know there's the display text called "command text" and the actual commands, right? I gave you both. Line for line they correspond. I just added the command text for ease of reading here. If you don't realize that the command text isn't the real commands, then in the Script Editor click the view menu and check the box for Direct Editor. Those are the actual command text strings. Not many people edit them directly. But when you copy and paste commands, the code in the direct editor is what's being copied and pasted unless you choose to right click a command and select "Copy command text". 

So in the normal edito you will see:

Text Type (Simulate Keystrokes): Howdy

But the actual command string is:

<TEXT TYPE Action="0" Text="Howdy"/>

If you copy the later, from here, you can paste it into your macro. 

Link to comment
Share on other sites

I gave you the code to export 4 messages ago. Copy this and paste it into a blank macro to examine it. 

<VARIABLE SET INTEGER Option="\x00" Destination="%Delay%" Value="300"/>
<DELAY Flags="\x02" Time="%delay%"/>
<TEXT TYPE Action="0" Text="<TAB>"/>
<DELAY Flags="\x02" Time="%delay%"/>
<TEXT TYPE Action="0" Text="<ENTER>"/>
<REPEAT START Start="1" Step="1" Count="5" Save="FALSE"/>
<TEXT TYPE Action="0" Text="<ARROW DOWN>"/>
<DELAY Flags="\x02" Time="%delay%"/>
<END REPEAT/>
<TEXT TYPE Action="0" Text="<ENTER>"/>

Or distill it into this:

<KEYSTROKE SPEED Delay="200"/>
<TEXT TYPE Action="0" Text="<TAB><ENTER><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ARROW DOWN><ENTER>"/>

But if you type more after this, which you shouldn't, then you might want to change the keystroke speed back.

Link to comment
Share on other sites

I had already typed your code in before, and it had not worked, but this time I cleared away the repeats, and sure enough the Save dialog opened, - so impressive progress - thank you.

I will leave the SAVING till a time when I can bring a fresh mind to the task. But I am confident (and optimistic) that it will happen satisfactorily. If not, I'll report it in this thread.

 

 

 

Link to comment
Share on other sites

You shoudl be able to put all three chunks together and have it work. Might be a small adjustment needed. And a "Wait for window" between chunks 1 and 2. 

I use MEP Windows Controls commands in the file-saveas. I highly recommend you learn these as soon as you can. I put off using them because I thought they were advanced and difficult, but they're not. And they give one more capabilities, make your code run so much smoother and everything. Win win win. I kicked myself for a week when I realized I would have save hundreds of hours had I learned them earlier. 

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...