COM Imacros

Post your working scripts, libraries and tools
User avatar
Xeo786
Posts: 193
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

COM Imacros

16 Aug 2017, 05:04

I am not COM tycoon, I have just made this script that run iMacros code on tab 1 of Active IE window that has iMacros sidebar enabled/running.

Code: Select all

iim1 := ComObjCreate("IMacros")
i := iim1.iimOpen("-IE", false) ; connect to active IE window which is which has Imacro slide bar already open or it will open new window.

; following is imacro code 
macro =
(
TAB T=1
URL GOTO=http://demo.imacros.net/Automate/TestForm1
'We use quotation marks for a content with spaces
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:name CONTENT="iMacros User"
'Selecting a drop down
TAG POS=1 TYPE=SELECT ATTR=NAME:food CONTENT=`%French<SP>Fries
TAG POS=1 TYPE=SELECT ATTR=NAME:drink CONTENT=`%Coke
'Selecting a radio button
TAG POS=2 TYPE=INPUT:RADIO ATTR=NAME:drinksize
TAG POS=1 TYPE=SELECT ATTR=NAME:dessert CONTENT=`%chocolate<SP>cake
TAG POS=1 TYPE=INPUT:RADIO ATTR=NAME:Customer
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD ATTR=NAME:Reg_code CONTENT=pwd
)

; displaying message
i := iim1.iimDisplay("This is a test")  ; i do not know why it does not display any msg :(

; play macro see http://wiki.imacros.net/iimPlay()
;i := iim1.iimPlay("Macro")     ; it run code from file
i := iim1.iimPlayCode(Macro) ; why we need file when we can do it with ahk variable

; check success
If (i > 0)
	s := "Everything OK"
Else
  s := iim1.iimGetLastError()
If s
	MsgBox %s%

; exit iMacros  
;i := iim1.iimExit() this will close already open IE window 
waiting for your suggestions
"When there is no gravity, there is absolute vacuum" -Game changer theory
User avatar
Xeo786
Posts: 193
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: COM Imacros

16 Aug 2017, 08:05

sometime clicking on element won't trigger event specially webpages with complex events.

Code: Select all

<div class="x-grid3-hd-inner x-grid3-hd-checker " id="ext-gen5679" unselectable="on"> ; I tried clicking on all
<a class="x-grid3-hd-btn" href="#"></a>
<div class="x-grid3-hd-checker" id="ext-gen5669">&nbsp;</div>
<img class="x-grid3-sort-icon" src="/clear.cache.gif">
</div>

Code: Select all

wb.document.getElementsByClassName("x-grid3-hd-checker")[0].fireEvent("MouseUp")  ; not working
wb.document.getElementsByClassName("x-grid3-hd-checker")[0].click() ; not working either
but following code worked due to DS click and TagX extract screen coord

Code: Select all

TAG =
(
TAB T=1
TAG POS=1 TYPE=DIV ATTR=CLASS:x-grid3-hd-checker
DS CMD=CLICK X={{!TAGX}} Y={{!TAGY}}
)
iMACROS(TAG)
return


iMACROS(code="")
{
iim := ComObjCreate("IMacros")
iim.iimOpen("-IE", false) ; connect to active IE window which is which has Imacro slide bar already open or it will open new window.
iim.iimPlayCode(code)
iim := ""
}

Code: Select all

TAG POS=1 TYPE=DIV ATTR=CLASS:x-grid3-hd-checker  ;  = wb.document.getElementsByClassName("x-grid3-hd-checker")[0].click()
DS CMD=CLICK X={{!TAGX}} Y={{!TAGY}}			; = controlclick with element coord
above code emulates manual click right on small checkbox which has actually a link to image of checkbox :wtf: and no event attached to this concerned div :facepalm: ,

I am curious how to extract screen coordinates via ClassName or ID using AHK and emulate AHK's controlclick accordingly :think:

DS http://wiki.imacros.net/DirectScreen_Technology ;
TagX http://wiki.imacros.net/TAG#Special_TAG ... Down_Menus
"When there is no gravity, there is absolute vacuum" -Game changer theory

Return to “Scripts and Functions”

Who is online

Users browsing this forum: loupis45 and 31 guests