Is it possible to specify a Preference Name in about:config?

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
dforionstar
Posts: 12
Joined: Sun Jun 26, 2011 11:13 pm

Is it possible to specify a Preference Name in about:config?

Post by dforionstar » Sun Jun 26, 2011 11:38 pm

This is my first Firefox imacro using v. 7.2.2.0.

I'm trying to toggle screen colors as follows. The macro isn't complete; it gets into about:config and stops with the following error:

"UnsupportedCommand: command DS is not supported in the current version, line: 4 (Error code: -912)"

Here is the macro so far:

Code: Select all

1  VERSION BUILD=7220523 RECORDER=FX
2  TAB OPEN
3  URL GOTO=about:config
4  DS CMD=KEY CONTENT={ENTER} 
5  DS CMD=KEY X=0 Y=0 CONTENT=browser.display.use_document_colors
6  DS CMD=KEY CONTENT={TAB}
7  DS CMD=KEY CONTENT={ENTER}  
8  DS CMD=KEY CONTENT={SHIFT}{TAB}
9  DS CMD=KEY CONTENT=browser.display.use_system_colors
10 DS CMD=KEY CONTENT={TAB}
11 DS CMD=KEY CONTENT={ENTER}
12 TAB CLOSE
How do I properly code lines 5, 8, and 9?

Any help is greatly appreciated.
Thanks in advance! :D
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Is it possible to specify a Preference Name in about:con

Post by siniy » Mon Jun 27, 2011 2:24 pm

DS commands don't work in firefox. Use javascript instead. This is code for changing proxies, imacros has now a command for proxies, so its just an example.

Code: Select all

URL GOTO=about:config
'Proxy type
URL GOTO=javascript:gPrefBranch.setIntPref("network.proxy.type",1);

'Host exceptions
URL GOTO=javascript:var<SP>prefb<SP>=<SP>Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);var<SP>str<SP>=<SP>Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);str.data<SP>=<SP>"localhost,127.0.0.1,mbiltd.net,";prefb.setComplexValue("network.proxy.no_proxies_on",<SP>Components.interfaces.nsISupportsString,<SP>str);

'Proxy host
URL GOTO=javascript:var<SP>prefb<SP>=<SP>Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);var<SP>str<SP>=<SP>Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);str.data<SP>=<SP>"{{!EXTRACT}}";prefb.setComplexValue("network.proxy.http",<SP>Components.interfaces.nsISupportsString,<SP>str);

'Proxy port
URL GOTO=javascript:gPrefBranch.setIntPref("network.proxy.http_port",3128);

URL GOTO=javascript:gPrefBranch.setBoolPref("network.proxy.share_proxy_settings",true);
dforionstar
Posts: 12
Joined: Sun Jun 26, 2011 11:13 pm

Re: Is it possible to specify a Preference Name in about:con

Post by dforionstar » Mon Jun 27, 2011 11:41 pm

Thank you siniy.

Unfortunately I don't know Javascript. While I am able to figure out how to replace the preference names in your example with my own, I am clueless about the rest of the script.

I had read a post (circa 2007) where iMacros was considering adding some of what I need in a future release. I searched the postings, google, and and the reference commands. DS was the only thing that came close.

Thanks anyway! :)
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Is it possible to specify a Preference Name in about:con

Post by siniy » Tue Jun 28, 2011 9:20 am

Paste this in your .iim file.

Code: Select all

URL GOTO=about:config
URL GOTO="javascript:gPrefBranch.setBoolPref('browser.display.use_document_colors',false);"
URL GOTO="javascript:gPrefBranch.setBoolPref('browser.display.use_system_colors',true);"
'You can remove this alert
URL GOTO="javascript:alert('Done');"
dforionstar
Posts: 12
Joined: Sun Jun 26, 2011 11:13 pm

Re: Is it possible to specify a Preference Name in about:con

Post by dforionstar » Thu Jun 30, 2011 2:00 am

Thank you again siniy!

What I need to do is to be able to toggle both prefs = true when I run the macro, then both prefs=false, then both=true, etc. That is why I was trying to use the ENTER key in About:config.

If I knew how to code this:
If a pref = TRUE, then set to FALSE.
Else set to TRUE (because it would have already be FALSE).

Thanks again.
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Is it possible to specify a Preference Name in about:con

Post by siniy » Thu Jun 30, 2011 5:51 am

This will toggle the values.

Code: Select all

URL GOTO=about:config
URL GOTO="javascript:val=gPrefBranch.getBoolPref('browser.display.use_document_colors');gPrefBranch.setBoolPref('browser.display.use_document_colors',!val);"
URL GOTO="javascript:val=gPrefBranch.getBoolPref('browser.display.use_system_colors');gPrefBranch.setBoolPref('browser.display.use_system_colors',!val);"
dforionstar
Posts: 12
Joined: Sun Jun 26, 2011 11:13 pm

Re: Is it possible to specify a Preference Name in about:con

Post by dforionstar » Thu Jun 30, 2011 9:40 pm

Thanks siniy! That works! :D

Code: Select all

TAB OPEN
TAB T=2 
URL GOTO=about:config
URL GOTO="javascript:val=gPrefBranch.getBoolPref('browser.display.use_document_colors');gPrefBranch.setBoolPref('browser.display.use_document_colors',!val);"
URL GOTO="javascript:val=gPrefBranch.getBoolPref('browser.display.use_system_colors');gPrefBranch.setBoolPref('browser.display.use_system_colors',!val);"
TAB CLOSE
TAB T=1
Sometimes the new TAB doesn't close at the end ??
I am trying to attach this to the F2 key. Any ideas? I looked at http://www.donesmart.com/sitelauncher/ but unfortunately it doesn't support Firefox 5. Any suggestions?

Thanks again!
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Is it possible to specify a Preference Name in about:con

Post by siniy » Thu Jun 30, 2011 9:48 pm

Maybe this will help.

Code: Select all

...
WAIT SECONDS=1
TAB CLOSE
I don't know about hotkeys and imacros. You can add an imacros bookmark to your bookmark panel. Right click on imacros script to create a bookmark.
dforionstar
Posts: 12
Joined: Sun Jun 26, 2011 11:13 pm

Re: Is it possible to specify a Preference Name in about:con

Post by dforionstar » Thu Jun 30, 2011 10:04 pm

Thanks siniy! :D

1) The WAIT is not working even from the bookmark. I tried up to 5 seconds with no improvement.

2) I use Macro Express http://www.macroexpress.com/ and assigned F2 to run a one line batch program

Code: Select all

 "C:\APPS\WEB\Firefox\firefox.exe"  http://run.imacros.net/?m=Toggle-Colours.iim
but still TAB2 stays open.

3) Finally, is it possible to run the macro (from the bookmark) WITHOUT opening the sidebar?

Thanks!
dforionstar
Posts: 12
Joined: Sun Jun 26, 2011 11:13 pm

Re: Is it possible to specify a Preference Name in about:con

Post by dforionstar » Thu Jun 30, 2011 11:47 pm

OK, I think I got it:

Code: Select all

VERSION BUILD=7220523 RECORDER=FX
URL GOTO=about:config
WAIT SECONDS=1
URL GOTO="javascript:val=gPrefBranch.getBoolPref('browser.display.use_document_colors');gPrefBranch.setBoolPref('browser.display.use_document_colors',!val);"
WAIT SECONDS=1
URL GOTO="javascript:val=gPrefBranch.getBoolPref('browser.display.use_system_colors');gPrefBranch.setBoolPref('browser.display.use_system_colors',!val);"
WAIT SECONDS=1
TAB CLOSE
Only issue is ABOUT:CONFIG always opens as rightmost tab, and when macro closes, focus is always on the last TAB. I figured out I could back up the TAB position by using TAB T=-1, but the TAB position from the end will always vary.

Is it possible to save the position of the TAB with current focus at the beginning of the macro so I can return to it at the end of the macro, instead of always ending at the rightmost TAB?
Post Reply