Run a autohotkey /self create hot key by imacros keypass

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Run a autohotkey /self create hot key by imacros keypass

by kingshok on Tue Jan 24, 2017 10:24 am

I create a .Bat file and create a auto hot key "Ctrl+Alt+B"
you can see it from https://gyazo.com/738451de64ed01389eae249b9e4fae13

i write code as
EVENT TYPE=KEYPRESS CHAR="b" MODIFIERS="ctrl,alt"

but it not working

or there is any way to call a .bat file using imacros

i keypass browser hot key like new tab
EVENT TYPE=KEYPRESS CHAR="n" MODIFIERS="ctrl"

But i need autohotkey for run a cmd command or i need to call a bat file using imacros.
kingshok
 
Posts: 6
Joined: Tue Jan 24, 2017 9:35 am

Re: Run a autohotkey /self create hot key by imacros keypass

by chivracq on Tue Jan 24, 2017 12:16 pm

kingshok wrote:I create a .Bat file and create a auto hot key "Ctrl+Alt+B"
you can see it from https://gyazo.com/738451de64ed01389eae249b9e4fae13

i write code as
Code: Select all
EVENT TYPE=KEYPRESS CHAR="b" MODIFIERS="ctrl,alt"


but it not working

or there is any way to call a .bat file using imacros

i keypass browser hot key like new tab
Code: Select all
EVENT TYPE=KEYPRESS CHAR="n" MODIFIERS="ctrl"


But i need autohotkey for run a cmd command or i need to call a bat file using imacros.

- Hum..., the 'Scripting and Command Line Interface' Sub-Forum would be the correct Sub-Forum if you were calling an iMacros Macro from your '.bat' File or 'AutoHotKey' File but for the other way around, the 'General' Sub-Forum would have been more relevant... But OK, I would have hesitated myself, no need to duplicate your Thread...

- More practical is to post your Screenshot directly in your Post rather than using some external Site:
Image

- CIM...! :mrgreen: (Always mention your FCI when you open a Thread or post for the first time in some existing Thread, read my Sig, not all Commands are implemented for all Browsers/Versions, and this is a Technical Forum...)

>>>

Your Statement(s) look(s) a bit strange to me, I'm not sure you can completely remove the 'SELECTOR' Parameter.

The Syntax you are using for 'MODIFIERS="ctrl,alt"' should be OK as it is documented (since recently) "like that" in the Wiki, I know that 'MODIFIERS="[ctrl,alt]"' works.
But iMacros seems to have quite some Problems catching Shortcuts (using the 'EVENT' Mode), even Browser Shortcuts and even more external Shortcuts from Add-ons or at the OS Level.

If you are on FF, pfff...!, that's where mentioning your FCI comes in handy...!, iMacros for FF is able to catch Shortcuts from some FF Add-on called 'External Application Buttons', but the Range of available Shortcuts is very limited as you can only use "Alt^[a,z]" and if there is the same Shortcut at the FF Level, the FF Shortcut will be called by iMacros (like 'Alt^b' for example for 'Bookmarks', 'Alt^e' for 'Edit', etc...)
And this Add-on works for '.BAT' Files, I've already used it from iMacros...

Still on FF, it seems to be possible to call/open some external Program/File from a '.js' Script like explained in this Thread for example:
- Re: Open external file
The same or another User had posted as well recently an Example to call an '.EXE' File (on Win OS), so I guess it should work as well for a '.BAT' File.
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Run a autohotkey /self create hot key by imacros keypass

by kingshok on Wed Jan 25, 2017 11:34 am

thank you , i can run a .bat file using Open external file .js

but now i have another problem , after run .js file i can't return to main script .after run code 2 how to return in main script and run code 3

1 VERSION BUILD=8961227 RECORDER=FX
2 URL GOTO=imacros://run/?m=Demo-Firefox%5CSelf-Test.js
3 WAIT SECONDS=15
4 TAB OPEN
5 TAB T=2
kingshok
 
Posts: 6
Joined: Tue Jan 24, 2017 9:35 am

Re: Run a autohotkey /self create hot key by imacros keypass

by chivracq on Wed Jan 25, 2017 1:09 pm

kingshok wrote:thank you , i can run a .bat file using Open external file .js

but now i have another problem , after run .js file i can't return to main script .after run code 2 how to return in main script and run code 3
Code: Select all
1 VERSION BUILD=8961227 RECORDER=FX
2 URL GOTO=imacros://run/?m=Demo-Firefox%5CSelf-Test.js
3 WAIT SECONDS=15
4 TAB OPEN
5 TAB T=2

Yeah but sorry "CIM" again, or "FCIM" now, for me to follow up, you missed my 3rd Remark... :roll:

And if I need to run your Script, I won't be removing all "1"/"2"/etc Line Numbers one by one... :idea:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Run a autohotkey /self create hot key by imacros keypass

by kingshok on Wed Jan 25, 2017 2:17 pm

Sorry , i am a new user in iMacros Forum and using iMacros about 2 week.I have a shortness knowledge about everything.

i an using
windows 7 64bit Eternity
Mozilla FireFox 42.0
iMacros for Firefox 8.9.7

After run .js file i can't return to main script .imm to complete other command.after run .js it automatically close .it don't wait 15 sec or open new tab.
please help me for last time.

URL GOTO=imacros://run/?m=Demo-Firefox%5CSelf-Test.js
WAIT SECONDS=15
TAB OPEN
TAB T=2
kingshok
 
Posts: 6
Joined: Tue Jan 24, 2017 9:35 am

Re: Run a autohotkey /self create hot key by imacros keypass

by chivracq on Wed Jan 25, 2017 2:57 pm

kingshok wrote:Sorry , i am a new user in iMacros Forum and using iMacros about 2 week.I have a shortness knowledge about everything.

i an using
Code: Select all
windows 7 64bit Eternity
Mozilla FireFox 42.0
iMacros for Firefox 8.9.7


After run .js file i can't return to main script .imm to complete other command.after run .js it automatically close .it don't wait 15 sec or open new tab.
please help me for last time.

Code: Select all
URL GOTO=imacros://run/?m=Demo-Firefox%5CSelf-Test.js
WAIT SECONDS=15
TAB OPEN
TAB T=2

OK, good for FCI, every Technical Forum needs your exact and full Configuration when you have a Qt/Pb...
Hum, funny, I've never heard of this "Eternity" Flavour of Win7, ah-ah...! I guess/hope you get Win-Updates for "Eternity", ah-ah...!
Hum, FF42 is a bit old, but OK... (... good to know that v8.9.7 for FF works on this Version, as v8.9.6/7 for FF got released to cope with some "big" Changes introduced in FF44/45, I think...)

But yep, normal, the 'URL GOTO=imacros://run/?m=' Syntax you are using, which is an Unsupported Syntax btw, is meant to call an '.iim' or '.js' Script from some already running '.iim' Macro and the 2nd Macro becomes the "main" Macro/Script and doesn't know anything at all about what was happening before it got launched.
=> You need to split the Logic of your "main" '.iim' into 2 Macros and have the '.js' Script call at its end the 2nd '.iim' Sub-Macro using 'iimPlay()', or compute that 2nd part as an on-the-fly '.iim' Macro using 'iimPlay(CODE)' or 'iimPlayCode()'.

Or you put the whole Logic of your Scenario into a main '.js' Script which will handle the 2 '.iim' parts. (And that's actually more the "Standard" way, as like I mentioned, the 'URL GOTO=imacros://run/?m=' Syntax is Unsupported and more of a Workaround...)
A '.js' Script launching an '.iim' will be waiting for the '.iim' Macro to finish, can "communicate" in both Directions with it, and (conditionally if necessary) go on with the further Workflow of the "Scenario"...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Run a autohotkey /self create hot key by imacros keypass

by kingshok on Sun Jun 18, 2017 7:52 pm

Final Solution

I converted code .imm file to .js file

Then i easily run .bat file from .js file

'reconnect.bat' is my .bat.
I use this code for run .bat file in .js file

Code: Select all
var file = Components.classes["@mozilla.org/file/local;1"] 
                     .createInstance(Components.interfaces.nsILocalFile); 
file.initWithPath("C:\\reconnect.bat"); 
file.launch();
kingshok
 
Posts: 6
Joined: Tue Jan 24, 2017 9:35 am

Re: Run a autohotkey /self create hot key by imacros keypass

by chivracq on Mon Jun 19, 2017 8:10 am

kingshok wrote:Final Solution

I converted code .imm file to .js file

Then i easily run .bat file from .js file

'reconnect.bat' is my .bat.
I use this code for run .bat file in .js file

Code: Select all
var file = Components.classes["@mozilla.org/file/local;1"] 
                     .createInstance(Components.interfaces.nsILocalFile); 
file.initWithPath("C:\\reconnect.bat"); 
file.launch();

OK, never too late to share your Solution, ah-ah...! Thanks for Sharing, anyway...! :D

But, hum, this is an "interesting" Syntax that I "vaguely" knew indeed, you could have mentioned in which FCI you tested this Script as your OP was already from 6 months ago and you were then already using some "older" Version of FF (FF42 at that time) while "current" FF Version (June 2017) is now FF53/54 (+ iMacros for FF v8.9.7) and I think all Browsers regularly keep tightening "Security" and prevent to run '.EXE' or '.BAT' Files (especially located in the 'C:\' Root...!) directly from the Browser from some JS Script...

But I tested your Script in the following 2 FCI's and it works fine indeed, so that's very nice and very interesting, let's hope some future Version of FF will not break it, I find it a better Solution actually than the one I had, which involves using some extra FF Add-on (called 'External Application Buttons'), plus adding some Shortcut and calling that Shortcut with the 'EVENT' Mode...
FCI's I tested on:
Code: Select all
- iMacros for FF v8.8.2, Pale Moon v26.3.3 (=FF47), Win10-x64.
- iMacros for FF v8.9.7, FF54, Win10-x64.


The only mini-"Difficulty" I encountered was that I had to provide (OS=Win10-x64) Admin Credentials when copying the '.BAT' File to the 'C:\' Root... (No big deal...)

I tried to run this Script from an 'URL GOTO=javascript:' Command, which would allow to use this Syntax directly from an '.iim' Macro, but I didn't get it to work, I tried several Syntax Combinations, by first constructing the Script in some User Defined Var, with '<BR>' / '\n' / all in one Line, escaping the Double Quotes of course, but to no avail. No Error at all, but the 'BAT' File doesn't get launched... Pity...!
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Run a autohotkey /self create hot key by imacros keypass

by green.pine on Sun Dec 10, 2017 3:06 pm

Imacros v8.9.7,
FF ver 55.0.3, 32 bit,
Win 7, 32 bit

this is a couple of months old thread, but it could be useful for me if anyone can help;
I want to use this js script part to call a js file instead of batch file,

I tried this script already and it works fine but only once, as my javascript converted imacros contains 2 macros in it, loop, and nested loop, the script works only (once) when I play it with play button, when the loop plays the macro the js script part does not play or load the file, I guess because it is not inside the macro+,

chivracq you said you put the whole script into a var, would you mind to share the whole coding as variable?
it tried to put <sp> in every space of the script, to make it as variable, but it did not work, I am not sure how to do it.

I want it to have it inside iim file as a variable and convert iim file to js, and see if it works.


thanks.
green.pine
 
Posts: 62
Joined: Thu Nov 04, 2010 10:21 am

Re: Run a autohotkey /self create hot key by imacros keypass

by chivracq on Sun Dec 10, 2017 3:57 pm

green.pine wrote:
Code: Select all
Imacros v8.9.7,
FF ver 55.0.3, 32 bit,
Win 7, 32 bit


this is a couple of months old thread, but it could be useful for me if anyone can help;
I want to use this js script part to call a js file instead of batch file,

I tried this script already and it works fine but only once, as my javascript converted imacros contains 2 macros in it, loop, and nested loop, the script works only (once) when I play it with play button, when the loop plays the macro the js script part does not play or load the file, I guess because it is not inside the macro+,

chivracq you said you put the whole script into a var, would you mind to share the whole coding as variable?
it tried to put <sp> in every space of the script, to make it as variable, but it did not work, I am not sure how to do it.

I want it to have it inside iim file as a variable and convert iim file to js, and see if it works.

thanks.

Hum..., that was an interesting Thread indeed, and I see I had already bookmarked it, ah-ah...! :wink:

And re-hum..., funny to notice that some User opened a Thread yesterday on SOF using this very same Syntax with 'createInstance()' + 'initWithPath()' + 'launch()', even if they mentioned "I am trying a imacros code found on Stackoverflow ( could not provide link here)...", ah-ah...!

OK, it's a few months ago for me, I don't remember exactly everything I did and tried at that time, I would need to start a bit all over again..., but hum..., if you simply want to call a '.js' Script from a '.js' Script, there is a much simpler Syntax/Workaround to use in this Case which consists of creating some mini-'.iim' Macro on the fly and this '.iim' Macro will in return call your 2nd '.js' Script using the "URL GOTO=imacros://run/?m=Demo-Firefox%5CSelf-Test.js" Syntax @OP had already mentioned in their 2nd Post in this Thread...

You have some Explanation about the Technique and a direct Link to some other Thread on the Forum with more Info and Code Example at the bottom of the Wiki Page for the 'iimPlay()' Command... :idea:
And you are luckily on v8.9.7 for FF, be aware that this Syntax is not supported in v9.0.3 anymore, ah-ah...! :twisted:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: No registered users and 6 guests

-->