Input form to create chrome bookmarks html file. Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Elendiar
Posts: 13
Joined: 03 Jul 2018, 05:44

Input form to create chrome bookmarks html file.

16 Jul 2018, 13:17

With what method can i generate html file with bookmarks for chrome, submitting just input values like URL and bookmark name ?
Structure of bookmark file is simple:

Code: Select all

<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
    <DT><H3 ADD_DATE="1508843224" LAST_MODIFIED="0" PERSONAL_TOOLBAR_FOLDER="true">Bookmarks</H3>
    <DL><p>
        <DT><A HREF="http://"...>...</A>
        <DT><A HREF="http://"...>...</A>
    </DL><p>
</DL><p>
How create expanding page, ask for input website and name like <DT><A HREF="variable1">variable2</A>.
Need it for creating bookmarks file, and throught chrome deployment (when master_preferences file with setting (esp. bookmark file) is in directory with chrome exe, any new user, or after deleting chrome user folder, anyway start chrome with given bookmarks. So for simple changing script just replace bookmarks.html, kill chrome, delete userdir, start chrome.
It is possible to make simply html file, but whether it is possible to make it with ahk?
Elendiar
Posts: 13
Joined: 03 Jul 2018, 05:44

Re: Input form to create chrome bookmarks html file.  Topic is solved

21 Jul 2018, 05:54

Resolved:

GUI Edit element look like :

Code: Select all

GUI, Uploader: Add, Edit, left gBookmark1 vBookmark1, http://
GUI, Uploader: Add, Edit, left gName1 vName1

Code: Select all

;variables with static content
bookmark_head = 
(
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
 )

bookmark_footer =
(
    </DL><p>
)

master_pref_file := "master_preferences.txt"
master_pref_file_noext := "master_preferences"

master_pref_header =
(
	{
  "homepage": "http://ua.sebn.com", 
  "homepage_is_newtabpage": false, 
  "browser": { 
    "show_home_button": true 
  }, 
  "bookmark_bar": { 
    "show_on_all_tabs": true 
  }, 
   "session": {
    "restore_on_startup": 4,
    "startup_urls": [
)

master_pref_footer = 
(
    ]
  },
    "sync_promo": {
    "show_on_first_run_allowed": false
  },
  "distribution": {
    "import_bookmarks": false,
    "import_bookmarks_from_file": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\bookmarks_MAO.html",
    "skip_first_run_ui": true, 
    "import_search_engine": true, 
    "import_history": false,
    "make_chrome_default": true,
    "make_chrome_default_for_user": true,
    "suppress_first_run_default_browser_prompt": true
  }, 
  "first_run_tabs": [ 
)

master_pref_footer2 = 
(
  ] 
} 
)


; generator sub

Generate_Bookmarks:
FileDelete, %bookmarks_file%
FileAppend, %bookmark_head%`n, %bookmarks_file%, UTF-8
if ( Bookmark1 = "" or Bookmark1 = "http://" )
		goto goto2
	else
		{
		FileAppend, <DT><A HREF="%Bookmark1%">, %bookmarks_file%, UTF-8
		FileAppend, %Name1%</A>, %bookmarks_file%, UTF-8
		}

	goto2:
	if ( Bookmark2 = "" or Bookmark2 = "http://" )
		goto goto3
	else
		{
		FileAppend, `n<DT><A HREF="%Bookmark2%">, %bookmarks_file%, UTF-8
		FileAppend, %Name2%</A>, %bookmarks_file%, UTF-8
		}

	goto3:
	if ( Bookmark3 = "" or Bookmark3 = "http://" )
		goto goto4
	else
		{
		FileAppend, `n<DT><A HREF="%Bookmark3%">, %bookmarks_file%, UTF-8
		FileAppend, %Name3%</A>, %bookmarks_file%, UTF-8
		}

	goto4:
	if ( Bookmark4 = "" or Bookmark4 = "http://" )
		goto goto5
	else
		{
		FileAppend, `n<DT><A HREF="%Bookmark4%">, %bookmarks_file%, UTF-8
		FileAppend, %Name4%</A>, %bookmarks_file%, UTF-8
		}

	goto5:
	if ( Bookmark5 = "" or Bookmark5 = "http://" )
		goto goto6
	else
		{
		FileAppend, `n<DT><A HREF="%Bookmark5%">, %bookmarks_file%, UTF-8
		FileAppend, %Name5%</A>, %bookmarks_file%, UTF-8
		}

	goto6:
	if ( Bookmark6 = "" or Bookmark6 = "http://" )
		goto goto7
	else
		{
		FileAppend, `n<DT><A HREF="%Bookmark6%">, %bookmarks_file%, UTF-8
		FileAppend, %Name6%</A>, %bookmarks_file%, UTF-8
		}

	goto7:
	if ( Bookmark7 = "" or Bookmark7 = "http://" )
		goto goto8
	else
		{
		FileAppend, `n<DT><A HREF="%Bookmark7%">, %bookmarks_file%, UTF-8
		FileAppend, %Name7%</A>, %bookmarks_file%, UTF-8
		}

	goto8:
	if ( Bookmark8 = "" or Bookmark8 = "http://" )
		goto goto9
	else
		{
		FileAppend, `n<DT><A HREF="%Bookmark8%">, %bookmarks_file%, UTF-8
		FileAppend, %Name8%</A>, %bookmarks_file%, UTF-8
		}

	goto9:
	if ( Bookmark9 = "" or Bookmark9 = "http://" )
		goto goto10
	else
		{
		FileAppend, `n<DT><A HREF="%Bookmark9%">, %bookmarks_file%, UTF-8
		FileAppend, %Name9%</A>, %bookmarks_file%, UTF-8
		}

	goto10:
	if ( Bookmark10 = "" or Bookmark10 = "http://" )
		goto goto11
	else
		{
		FileAppend, `n<DT><A HREF="%Bookmark10%">, %bookmarks_file%, UTF-8
		FileAppend, %Name10%</A>, %bookmarks_file%, UTF-8
		}

	goto11:
	if ( Bookmark11 = "" or Bookmark11 = "http://" )
		goto goto12
	else
		{
		FileAppend, `n<DT><A HREF="%Bookmark11%">, %bookmarks_file%, UTF-8
		FileAppend, %Name11%</A>, %bookmarks_file%, UTF-8
		}
		
		
	goto12:
	if ( Bookmark12 = "" or Bookmark12 = "http://" )
		{
		FileAppend, `n%bookmark_footer%, %bookmarks_file%, UTF-8
		return
		}
	else
		{
		FileAppend, `n<DT><A HREF="%Bookmark12%">, %bookmarks_file%, UTF-8
		FileAppend, %Name12%</A>, %bookmarks_file%, UTF-8
		FileAppend, `n%bookmark_footer%, %bookmarks_file%, UTF-8
		return
		}
	
; master_pref generator (for set up startup pages, same as bookmarks):

Generate_master_pref:
FileDelete, %A_Temp%\%master_pref_file%
FileAppend, %master_pref_header%`n, %A_Temp%\%master_pref_file%, UTF-8
	if ( Bookmark1 = "" or Bookmark1 = "http://" )
		goto goto2p
	else
		FileAppend, "%Bookmark1%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto2p:
	if ( Bookmark2 = "" or Bookmark2 = "http://" )
		goto goto3p
	else
		FileAppend, `,`"%Bookmark2%"`n, %A_Temp%\%master_pref_file%, UTF-8


	goto3p:
	if ( Bookmark3 = "" or Bookmark3 = "http://" )
		goto goto4p
	else
		FileAppend, `,`"%Bookmark3%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto4p:
	if ( Bookmark4 = "" or Bookmark4 = "http://" )
		goto goto5p
	else
		FileAppend, `,`"%Bookmark4%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto5p:
	if ( Bookmark5 = "" or Bookmark5 = "http://" )
		goto goto6p
	else
		FileAppend, `,`"%Bookmark5%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto6p:
	if ( Bookmark6 = "" or Bookmark6 = "http://" )
		goto goto7p
	else
		FileAppend, `,`"%Bookmark6%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto7p:
	if ( Bookmark7 = "" or Bookmark7 = "http://" )
		goto goto8p
	else
		FileAppend, `,`"%Bookmark7%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto8p:
	if ( Bookmark8 = "" or Bookmark8 = "http://" )
		goto goto9p
	else
		FileAppend, `,`"%Bookmark8%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto9p:
	if ( Bookmark9 = "" or Bookmark9 = "http://" )
		goto goto10p
	else
		FileAppend, `,`"%Bookmark9%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto10p:
	if ( Bookmark10 = "" or Bookmark10 = "http://" )
		goto goto11p
	else
		FileAppend, `,`"%Bookmark10%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto11p:
	if ( Bookmark11 = "" or Bookmark11 = "http://" )
		goto goto12p
	else
		FileAppend, `,`"%Bookmark11%"`n, %A_Temp%\%master_pref_file%, UTF-8
		
		
	goto12p:
	if ( Bookmark12 = "" or Bookmark12 = "http://" )
		FileAppend, %master_pref_footer%`n, %A_Temp%\%master_pref_file%, UTF-8
	else
		{
		FileAppend, `,`"%Bookmark12%"`n, %A_Temp%\%master_pref_file%, UTF-8
		FileAppend, %master_pref_footer%`n, %A_Temp%\%master_pref_file%, UTF-8
		}
; ===================================
	if ( Bookmark1 = "" or Bookmark1 = "http://" )
		goto goto2p2
	else
		FileAppend, "%Bookmark1%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto2p2:
	if ( Bookmark2 = "" or Bookmark2 = "http://" )
		goto goto3p3
	else
		FileAppend, `,`"%Bookmark2%"`n, %A_Temp%\%master_pref_file%, UTF-8


	goto3p3:
	if ( Bookmark3 = "" or Bookmark3 = "http://" )
		goto goto4p4
	else
		FileAppend, `,`"%Bookmark3%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto4p4:
	if ( Bookmark4 = "" or Bookmark4 = "http://" )
		goto goto5p5
	else
		FileAppend, `,`"%Bookmark4%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto5p5:
	if ( Bookmark5 = "" or Bookmark5 = "http://" )
		goto goto6p6
	else
		FileAppend, `,`"%Bookmark5%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto6p6:
	if ( Bookmark6 = "" or Bookmark6 = "http://" )
		goto goto7p7
	else
		FileAppend, `,`"%Bookmark6%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto7p7:
	if ( Bookmark7 = "" or Bookmark7 = "http://" )
		goto goto8p8
	else
		FileAppend, `,`"%Bookmark7%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto8p8:
	if ( Bookmark8 = "" or Bookmark8 = "http://" )
		goto goto9p9
	else
		FileAppend, `,`"%Bookmark8%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto9p9:
	if ( Bookmark9 = "" or Bookmark9 = "http://" )
		goto goto10p10
	else
		FileAppend, `,`"%Bookmark9%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto10p10:
	if ( Bookmark10 = "" or Bookmark10 = "http://" )
		goto goto11p11
	else
		FileAppend, `,`"%Bookmark10%"`n, %A_Temp%\%master_pref_file%, UTF-8

	goto11p11:
	if ( Bookmark11 = "" or Bookmark11 = "http://" )
		goto goto12p12
	else
		FileAppend, `,`"%Bookmark11%"`n, %A_Temp%\%master_pref_file%, UTF-8
		
		
	goto12p12:
	if ( Bookmark12 = "" or Bookmark12 = "http://" )
		{
		FileAppend, %master_pref_footer2%, %A_Temp%\%master_pref_file%, UTF-8
		return
	}
	else
		{
		FileAppend, `,`"%Bookmark12%"`n, %A_Temp%\%master_pref_file%, UTF-8
		FileAppend, %master_pref_footer2%, %A_Temp%\%master_pref_file%, UTF-8
		return
		}
 


Return to “Ask For Help”

Who is online

Users browsing this forum: 2X7W, Bing [Bot], buzstringer, swagfag and 97 guests