AutoHotkey Community

It is currently May 27th, 2012, 10:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 646 posts ]  Go to page Previous  1 ... 26, 27, 28, 29, 30, 31, 32 ... 44  Next
Author Message
 Post subject:
PostPosted: October 23rd, 2009, 8:10 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
COM_L now supports named parameters too. So, the code with the old (AHK,COM)
Code:
COM_Invoke(oWorkbooks,"OpenXML",sFileName,"-0",xlXmlLoadImportToList:=2)
can be written in either way with the new (AHK_L,COM_L)
Code:
oWorkbooks.OpenXML(sFileName,"-0",2)
; or
oWorkbooks.OpenXML(sFileName,COM_Parameter("LoadOption",2))
; or
oWorkbooks.OpenXML(COM_Parameter("Filename",sFileName),COM_Parameter("LoadOption",2))

Another Example.

AHK and COM:
Code:
COM_Invoke(oWord, "ActiveDocument.Content.Find.Execute", "Hello", "-0", "-0", "-0", "-0", "-0", "-0", "-0", "-0", "World")
AHK_L and COM_L:
Code:
oWord.ActiveDocument.Content.Find.Execute( COM_Parameter("FindText","Hello"), COM_Parameter("ReplaceWith","World") )


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 2:06 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
holy cow

very nice

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 2:33 pm 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
Is a COM_Parameter( equivalent possible in AHK native ?

eg,. via using scripting to create & pass pointer, or via DLL to structure ?

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 8:53 pm 
Sean wrote:
COM_L now supports named parameters too.

Is it possible to have named parameters for the standard COM, too, please ?
It would be marvelous.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 2:34 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Joy2DWorld wrote:
Is a COM_Parameter( equivalent possible in AHK native ?
AHK doesn't support named parameters yet.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 2:37 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Roudoudou wrote:
Is it possible to have named parameters for the standard COM, too, please ?
It's straightforward to add to COM_Invoke_, however you cannot set the type then, which is possible with COM_L like COM_Parameter( "Filename",sFileName,8 ).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 8:16 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
I came across the following issue when working with MS Word:
Code:
word := COM_GetActiveObject("Word.Application")
word.Selection.Font.Bold := True ; "True" <-- neither work

oWord := COM_Unwrap(word)
COM_Invoke(oWord, "Selection.Font.Bold=", True) ; <-- works
COM_Release(oWord)

This seems to work as long as the equals sign is included after the word Bold. Would there be anyway to write this without having to unwrap the object?

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 8:28 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
jethrow,
Sean wrote:
Code:
obj["name="] := value

Try either of the following:
Code:
word.Selection.Font["Bold="] := True
word["Selection.Font.Bold="] := True


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 8:34 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Wow, I completely missed where Sean wrote that. Both examples work. Thanks Lexikos! :D

EDIT - thank you for the next post Sean :D

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Last edited by jethrow on October 26th, 2009, 10:00 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 1:43 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
OK, I changed __Set so that the following works as it is.
Code:
word := COM_GetActiveObject("Word.Application")
word.Selection.Font.Bold := True


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 7th, 2009, 2:39 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
I uploaded COM_U to be used with the latest AutoHotkeyU. There are not much differences with COM_L for AutoHotkey_L, essentially COM_Ansi4Unicode/COM_Unicode4Ansi are now retired.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Bug in COM_L library
PostPosted: November 7th, 2009, 4:52 am 
This script Works Fine with COM library, but breaks if I use COM_L library
Code:
COM_Init() ; Initialize COM - requires COM.ahk library
objIE := COM_CreateObject("InternetExplorer.Application")
COM_Invoke(objIE, "Visible", "True")
COM_Invoke(objIE, "Navigate", "www.gmail.com")
loop
{
           If (rdy:=COM_Invoke(objIE,"ReadyState") = 4)
{
               break
}
}
msgbox, I Will now magically fill in a field!
COM_Invoke(objIE, "document.getElementById[Email].value", "111111111111")
exitapp


It only breaks if the value you are entering into the field is not a number greater than 10 digits long (and for my app I need to enter an 11 digit number!), so for example, if I change..
Code:
 
COM_Invoke(objIE, "document.getElementById[Email].value", "111111111111")

To
Code:
COM_Invoke(objIE, "document.getElementById[Email].value", "1234") 
 

it will work fine.

I am pretty sure it is a problem with the COM_L library, not Autohotkey_L, because if I compile with Autohotkey_L while using the COM library it works fine.


Report this post
Top
  
Reply with quote  
 Post subject: Re: Bug in COM_L library
PostPosted: November 7th, 2009, 5:28 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Anonymous wrote:
if I compile with Autohotkey_L while using the COM library it works fine.
Are you sure? COM_Invoke passes integers as VT_I4, which is 32-bit and therefore limited to the range -2147483648 to 2147483647. Any decimal integer longer than 10 digits is too long/high to pass as VT_I4. Try this:
Code:
COM_Invoke_(objIE, "document.getElementById[Email].value", VT_BSTR:=8, "111111111111")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 7th, 2009, 5:34 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Quote:
This script Works Fine with COM library, but breaks if I use COM_L library
Wrong, unless you switched the condition to the commented one in COM. Anyway:
Code:
COM_Invoke(objIE, "document.getElementById[Email].value", COM_Parameter(8,"111111111111"))


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 7th, 2009, 5:42 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Lexikos wrote:
Code:
COM_Invoke_(objIE, "document.getElementById[Email].value", VT_BSTR:=8, "111111111111")
COM_Invoke_ no longer exists in COM_L. It's removed as it's now redundant, superseded by COM_Parameter, Object.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 646 posts ]  Go to page Previous  1 ... 26, 27, 28, 29, 30, 31, 32 ... 44  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: XX0 and 21 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group