Development :  K-Meleon Web Browser Forum
K-Meleon development related discussions. 
Pages: Previous123Next
Current Page: 2 of 3
Re: Macrolanguage usage questions
Posted by: siria
Date: April 30, 2017 08:34PM

Quote
JohnHell
But you can't teach new tricks to an old dog, and with my first versions (0.8x, 0.9x) I started to use the get/set clipboard and... till today.

I think it also depends on how helpful those tricks are smiling smiley
But yes sure, it's a general prob that once we learned anything, it gets a lot harder to re-learn it differently later again. That's exactly why it's so important to learn things "right" from the beginning. But few people care. The same in society in general, it keeps shocking me how careless most people are what little kids are getting taught at an early age, but that's a whole different subject, sigh (e.g. the complete insanity that in some regions politicians insist that school kids must not be taught correct spelling in their first years, but just write as they 'hear' things and no one shall correct them!)

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: JohnHell
Date: April 30, 2017 08:40PM

Quote
JamesD
Quote
JohnHell
(And as I told back in time, if we could change macro code without restarting K-meleon, that would be awesome. Would be time saving.)

Are you making use of Restart2 macro?

No. If I understood when this was created, that won't make a difference.

K-meleon needs to be closed and re-opened to reload macros changes.

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: JamesD
Date: May 01, 2017 12:39PM

Quote
JohnHell
No. If I understood when this was created, that won't make a difference.

K-meleon needs to be closed and re-opened to reload macros changes.

IMPORTANT
Restart is faster and does the reread/reload of macros. Plus there are options to 'open previous session' and 'open the Error Console' automatically.

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: JohnHell
Date: May 01, 2017 03:41PM

Yes, JamesD, but still, isn't helpful, requires a close-open. Quicker or not.

Every close and open my hard drive "cracks" to hell. I feel its pain in my flesh.

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: rodocop
Date: May 01, 2017 04:43PM

JohnHell,
in other words - we need something like command to 'ReInit' or 'ReSetup' browser without restart - yes?

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: JohnHell
Date: May 01, 2017 04:50PM

Quote
rodocop
JohnHell,
in other words - we need something like command to 'ReInit' or 'ReSetup' browser without restart - yes?

I ignore what ReInit and what ReSetup are, but yes, something to coding macros without continues closes and opens when some stupid bug of you own breaks a macro.

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: JamesD
Date: May 01, 2017 04:53PM

siria

You will enjoy or cringe after reading this.

Funny code: http://thedailywtf.com/articles/do-while-false

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: JamesD
Date: May 01, 2017 09:05PM

Well this post is coming from a copy of my KM running on a ram disk. I would not normally do something real from the ram disk, but I wanted to show myself that it work work.

My KM is portable with the profile included. I got a free ram disk program from Miray, installed a "E" drive of 262 MB size and copied the KM folder there. The KM folder is only 118 MB so I have 143 MB free. I could probably have made the drive 128 MB and still have had room to work on many macros.

Since the whole KM and profile are on ram disk it is even faster than my SSD. I need only copy the new or changed macros back to my real profile folder after testing. Then I can delete the ram drive. This will save a lot of writes to my SSD which is a good thing.

JohnHell, I think this could help you now. No telling how long we could need to wait for a version of KM which could reread macros without a restart. You would need 128 MB of ram that you could commit to this. I know you have older ops sys and hardware. Hope this can help.

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: JohnHell
Date: May 01, 2017 09:29PM

Quote
JamesD
JohnHell, I think this could help you now. No telling how long we could need to wait for a version of KM which could reread macros without a restart. You would need 128 MB of ram that you could commit to this. I know you have older ops sys and hardware. Hope this can help.

Yep, and that is the problem.

I already use a RAMDisk for the cache and, partially, for the profile (not strictly a RAMDisk but a restricted hard disk area so the head doesn't move much, and the reads and writes are delimited to an small hard disk area of about 50Mcool smiley, but fully load the whole K-meleon, is too much. Not only by RAM needed, but by voltages (and it is a long story to explain here why I'm telling this).

Old hardware.


The following is fully off-topic:
By the way, you may be asking yourself why the profile in such strange configuration.

Since K-meleon 74, or better said, since we use a Gecko engine that makes use of places.sqlite for history and statistics, you won't imagine how many reads and writes are made to this file and the temporary modifications files (.sqlite-shm and .sqlite-wal). I found sometimes that K-meleon has read/wrote in a session over 2GB each (read/write not each file)!!!. This is because every back and forward browsing makes a read and write to add information to the database (not only cache files databases, that are another story). As in some forums I visit I go back and forward several times, that increases the read/writes a lot, and then I decided to move cache files and profile to a less hard disk consuming environments. Really, you can't imagine what does that mean for a 5400rpm hard disk (that I used for that time around K-meleon 74 for caching).

And, not only for this, but it would be great to edit macros without restart. How I'd wish it. But I think this might be quite complex to implement.



Edited 2 time(s). Last edit at 05/01/2017 09:59PM by JohnHell.

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: siria
Date: May 01, 2017 09:50PM

Yikes. What a nightmare :O
And such RAMdisks sound really interesting.
Have no clue of such stuff, but despite my disk and RAM permanently being cramped full and over the limit, it feels like luxury now to be able to restart without major problems. Of course, the disk is working hard each time, but not THAT scary. Usually I just start a parallel session for macro testing, not wanting to close and reopen my 30+ open tabs in the main session... The prob is that (probably due to lack of RAM), the parallel session has no context menus and other missing menu and toolbar stuff. But except for that can live well with it.
Perhaps would use for first tests an older KM-version, and if the macro runs okay there, then try it in KM75 - but you certainly have already considered all sorts of such options.

What I'm sometimes missing is a possibility to compose variable names, just as macro names can be composed by macros(a.b.c) Oh well.

(Perhaps we should split this into a new thread for Old Hardware or Systems?)

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: JohnHell
Date: May 01, 2017 10:03PM

Quote
siria
(Perhaps we should split this into a new thread for Old Hardware or Systems?)

I'd better delete the messages. There is no need for a new thread, just stop talking this off-topic xD

I fixed above because looks like I'm saying 2GB each file, no, by each I mean, 2GB read and write.

For me, off-topic ended winking smiley

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: siria
Date: October 08, 2017 11:37AM

Am still unsure if the download page should be updated to RC2 as "latest dev version" or not?
(and most non-english Download pages even still show KM76-ALPHA from 2015 - yikes!)
Not sure about RC1/RC2 because Dorian posted this after his disk crash:
http://kmeleonbrowser.org/forum/read.php?8,138447,140501#msg-140501

Quote
Dorian (2016-12-20)
So, I've gathered what I have to make what could be a RC2. But I'm afraid this could not be complete and could have more problem than the RC. I don't have a changelog except for the code history

Anyway, What I notice only now in the changelog above:
Quote

2016-08-07 Add OnSwitchTab

=> Is this something like "$OnActivateWindow" ?
It's not mentioned anywhere else yet, neither here of course:
http://kmeleonbrowser.org/wiki/MacroLanguage2#events

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: JamesD
Date: October 08, 2017 09:26PM

If $OnSwitchTab was planned, then it was not included in the KM76RC2 that I use.


_Snippet_Cnt_Tab_chg{
$_Snippet_tabCount = $_Snippet_tabCount + 1;
alert($_Snippet_tabCount, "Switched Tabs #", INFO);
}

_Snippet_Start {
$_Snippet_tabCount = 1;
}

##---------------------
$OnInit=$OnInit."_Snippet_Start;";
$OnSwitchTab=$OnSwitchTab."_Snippet_Cnt_Tab_chg;";
$macroModules=$macroModules."Snippet;";

Results in error console item:
Sun Oct 08 2017 17:15:23
Error: The variable '$OnSwitchTab' is used without being initialized

Hanlon’s razor is an eponymous adage named after Robert J. Hanlon that states: “Never attribute to malice that which is adequately explained by stupidity.”

JamesD

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: siria
Date: October 08, 2017 10:44PM

Hmm.... still a tiny chance, perhaps if you add it in main.kmm too, in the block where all the other event-variables are created?

Because when I open macros.dll in notepad, it does contain that string among all that binary stuff, and the older macros.dll not yet. Might not mean much, but never know ;-)



Edited 1 time(s). Last edit at 10/08/2017 10:48PM by siria.

Options: ReplyQuote
Re: Macrolanguage usage questions
Posted by: JamesD
Date: October 09, 2017 01:09PM

siria

OK, I have made these changes.

Main.kmm

## test of OnSwitchTab
$OnSwitchTab="";


# test of OnSwitchTab
OnSwitchTab{
# When the active view moves from one tab to another.
macros($OnSwitchTab);
}

It does work! The alerts show. I had not saved the last change to main.kmm when I tested before. Oh, heck, now I must add to documentation. Should I ask Dorian if there are more things in RC2 which might be finished or could be finished easily for a KM76 FINAL?

Are there other items in the code that did not make it into main.kmm?

There is nothing in the error console, but no alert ever shows when I change the active view from tab to tab.

My memory is not so good anymore, but can you find the "C" code that goes with the "OnSwitchTab"? I think there should be variables linked to that reference. Also please check logic in my snippet.kmm file.


Hanlon’s razor is an eponymous adage named after Robert J. Hanlon that states: “Never attribute to malice that which is adequately explained by stupidity.”

JamesD



Edited 1 time(s). Last edit at 10/09/2017 01:28PM by JamesD.

Options: ReplyQuote
Re: Macrolanguage usage questions / $OnSwitchTab
Posted by: siria
Date: October 09, 2017 06:35PM

Hey great! grinning smiley smiling smiley smiling smiley
Thanks for testing James, and thanks of course to Dorian!
Just hope he doesn't forget again to finish it next time, first doing the complicated stuff and then tending to forget the last, less exciting bits for GUI and docu ;-)

In the past I'd really wished a couple times to have something like OnActivateTab, especially as a tool for quicker resetting some variables or finishing some macro function, because macros don't always know when their initial functions are completed and ready for next step.

Options: ReplyQuote
Re: Macrolanguage usage questions / $OnSwitchTab
Posted by: JamesD
Date: October 09, 2017 09:34PM

siria

I did send Dorian an e-mail about this. He has not answered yet, but likely not enough time yet.

Hanlon’s razor is an eponymous adage named after Robert J. Hanlon that states: “Never attribute to malice that which is adequately explained by stupidity.”

JamesD

Options: ReplyQuote
Re: Macrolanguage usage questions / $OnSwitchTab
Posted by: siria
Date: October 10, 2017 02:15PM

Thanks James, and sorry have currently no access to another computer to test myself, but in theory changes in main.kmm should NOT be necessary, if this part is just added inside the snippet-macro itself:

$OnSwitchTab ? 0 : $OnSwitchTab="";

OnSwitchTab{
macros($OnSwitchTab);
}

Is this correct? And in theory it should also do no harm regardless if main.kmm already contains this (KM76 final) or not (KM76RC)?

Oh and curious about older versions:
In earlier dev versions of KM76 (alpha, beta) it probably works too if macros.dll is exchanged...? :cool:
Perhaps even older ones, KM75.. 74 !? No idea, but looks like the dll's get only rarely changed if ever, until in KM76-beta2 the file size suddenly dropped about 25%, major update it seems (macros.dll)



Edited 1 time(s). Last edit at 10/10/2017 03:02PM by siria.

Options: ReplyQuote
Re: Macrolanguage usage questions / $OnSwitchTab
Posted by: JamesD
Date: October 10, 2017 07:02PM

siria

The initial value and macros call were items that I added to the main.kmm in the KM76RC2 version on my computer. I think that I need to back track to the information that Dorian provided in his 'rebuilt' RC2 to see if I did not get everything or the main.kmm available at that time did or did not have the items for OnSwitchTab.

What happened during testing was that I added the items to main.kmm but did not save the change. I first reported a fail, but then when closing out the notepad++, I saw that the save flag was still red for main.kmm. I did a save and then started KM and my alerts began to pop at every tab switch. I had to rush back to edit my post and report success. Not everything is a plus when one gets very old.

Do you think that we should move the rest of this to the announcements area or just stay in development until something is really ready to post?

Even if Dorian does not answer, I have no qualms about making a RC2.1 release. I did that once before. But before we/I jump the gun, did not someone add a new item to the history display? I would like to get everything possible to include.

I still intend to work on your addperm macro. My first try did nothing, but that might be my fault. Age and Parkinson's again.

Hanlon’s razor is an eponymous adage named after Robert J. Hanlon that states: “Never attribute to malice that which is adequately explained by stupidity.”

JamesD



Edited 1 time(s). Last edit at 10/10/2017 07:02PM by JamesD.

Options: ReplyQuote
Re: Macrolanguage usage questions / $OnSwitchTab
Posted by: siria
Date: October 10, 2017 07:25PM

Let's just drop a little notice in Dorian's KM76 thread as a reminder, the rest I'd leave here as is. As long as there are no macros yet that actively use this event it's not worth a new build just for this. And even if we do use this function in a future macro, it can still include the above workaround directly, no need to have it in main.kmm before Dorian includes it himself.
So far main.kmm did never include it yet, have checked in my downloaded zips of last versions.

Yes I think someone posted a little fix or two for other stuff, which was a lot more important, but am sure others will remember more details...

Options: ReplyQuote
Re: Macrolanguage usage questions / $OnSwitchTab
Posted by: JamesD
Date: October 11, 2017 11:52PM

siria

I found one other event that works. OnUserSetup works when added to main.kmm. It is right after OnSetup in order of events. Have no idea why exists without use previously.

Perhaps soon, I will hear back from Dorian.

Hanlon’s razor is an eponymous adage named after Robert J. Hanlon that states: “Never attribute to malice that which is adequately explained by stupidity.”

JamesD

Options: ReplyQuote
Re: Macrolanguage usage questions / resource:// path
Posted by: siria
Date: November 14, 2017 08:56PM

Quote
rodocop
The big KM 7x-problem touching readme-files but not limited to them is the fail of resource:// protocol.

Earlier we were able to give relative links to any file inside KM-folder using that thing, but now it's addressed just inside omni.ja.

So we need hardcode readme-file address somewhere in settings or macros. But this isn't big prob as it was solved by some macro as I can recall (it gets the locale code from pref and uses it as variable to get into that locale folder)

But in other cases you want to relatively point to some file to open it in KM tab - but you cannot do it through resource:// (and this breaks backwards compatibility with 1.x-branch)

I thought "resource:" now points to the km/browser/ folder?
And if I understand it right that path is the same as for "inside browser/omni.ja". Have no experience, but my impression ever since those "jar" extensions and now "omni.ja" was that it doesn't matter if a file is inside a real folder km/browser/xyz/file or zipped into km/browser/omni.ja/xyz/file
That's why I'm also keen that you remove that useragent script out of omni.ja, to make it easier accessible (changeable ir removable) for users :cool:
But would have to test this assumption again to verify.

How this affects the readme files and their locale versions I'm not sure. Only noticed that the english version is now in the "browser" folder instead of root. But doesn't Help>Welcome open them fine? And I also thought the language versions work fine again. Are there still macro tricks needed? Can't quite imagine.

If a macro only wants to open a file, instead of "resource" it can still use getfolder(RootFolder), as you just mentioned in your other thread too.
Hmm, dimly remember only that "file" paths didn't work anymore to attach userscripts in one of those newer gecko version... It was a nightmare, have given up struggling with all those many 7X versions and especially loads of new Mozilla "security" related bugs quite some time ago. It was a futile struggle, so was just hoping it would all be fixed over time, especially macro functions, until the stable versions. Am just a little macro-player after all, all that c++ and JS stuff is Mount Everest for me, not going to happen.



Edited 1 time(s). Last edit at 11/14/2017 08:57PM by siria.

Options: ReplyQuote
Re: Macrolanguage usage questions / resource:// path
Posted by: JamesD
Date: November 15, 2017 01:08PM

I am sure the resource bit died when KM 74 came along. I had to make changes to the macro and location for 'Local Documents'. I found that I could use this method to locate them with a macro. I added '74' to the macro name to keep it separate from the earlier macro for 1.6.

_localdocs_find_res {
$_localdocs_res = getfolder( ResFolder );
}

The res folder is located in KMroot\browser\ along with Defaults, Extensions, Plugins, Omni.ja and the readme.html folders and files.

Note that this is just one of many macros that I have in two versions - 1.x or 7x. I have not found any way to make them all inclusive.

Hanlon’s razor is an eponymous adage named after Robert J. Hanlon that states: “Never attribute to malice that which is adequately explained by stupidity.”

JamesD

Attachments: localdocs74.kmm (3.2 KB)  
Options: ReplyQuote
Re: Macrolanguage usage questions / resource:// path
Posted by: siria
Date: November 15, 2017 01:54PM

@JamesD
Let's test something? Have attached a modified kmm version.
Move your single files temporarily into ROOT/localdocs_manual/...
Disable current localdocs macro

Have modified:
- default path out of res-folder, to allow installation in all KM versions with same zip
- added "manual" to folder name just to avoid possible misunderstanding about downloaded user documents or such
- added a path conversion from \\ to / and more little bits

Attachments: localdocs_manual.kmm (3.2 KB)  
Options: ReplyQuote
Re: Macrolanguage usage questions / resource:// path
Posted by: JamesD
Date: November 15, 2017 07:56PM

siria

That works. Now to go see how you do it.

Hanlon’s razor is an eponymous adage named after Robert J. Hanlon that states: “Never attribute to malice that which is adequately explained by stupidity.”

JamesD

Options: ReplyQuote
Re: Macrolanguage usage questions / resource:// path
Posted by: siria
Date: November 15, 2017 08:42PM

Great!

The main difference is simply to use the same folder path in old and new KM.
"Resfolder" is in root/res/ in old KM, but in root/browser/res in new KM.
That's why there must be 2 different zips, with different folder paths.

Now simply using common RootFolder as parent, and no prob anymore.
Or the macros folder would work fine too.

Options: ReplyQuote
Re: Macrolanguage usage questions / regex?
Posted by: siria
Date: December 15, 2017 12:41PM

Wishlist :cool:
A regex function, that works also in "menuchecked" lines etc.

Could have used it occasionally in the past. Current case: would like to show a checkmark if the current page has an automatic UA set. For page "xyz.example.com", but also working if the automatic is for "example.com"
Then again, the bigger prob is: does the main domain contain MIN 2 dots or 3, as for ".co.uk" domains? Stuck at the moment...

Options: ReplyQuote
Re: Macrolanguage usage questions / win10?
Posted by: siria
Date: December 15, 2017 10:16PM

Just a little question for users on Win10:
what happens when you click Win+R (start run commandline),
type "write" and hit enter?

Options: ReplyQuote
Re: Macrolanguage usage questions / win10?
Posted by: JamesD
Date: December 16, 2017 01:07PM

Quote
siria
Just a little question for users on Win10:
what happens when you click Win+R (start run commandline),
type "write" and hit enter?

Wordpad opens in a new document.

Hanlon’s razor is an eponymous adage named after Robert J. Hanlon that states: “Never attribute to malice that which is adequately explained by stupidity.”

JamesD

Options: ReplyQuote
Re: Macrolanguage usage questions / win10?
Posted by: siria
Date: December 16, 2017 01:34PM

Perfect - what I wanted to hear smiling smiley Thanks James!

=> means that exec("write $_path) works in ALL win versions ancient or new, and is much better as horrible exec("notepad.exe $_path), which doesn't even understand all linebreaks formats

Options: ReplyQuote
Pages: Previous123Next
Current Page: 2 of 3


K-Meleon forum is powered by Phorum.