AutoHotkey Community

It is currently May 27th, 2012, 3:53 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 646 posts ]  Go to page Previous  1 ... 39, 40, 41, 42, 43, 44  Next
Author Message
 Post subject:
PostPosted: July 24th, 2010, 6:20 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Show your code. I'd like to see how you separated it first before I comment. BTW, I bet your errors were not consistent, I mean you did not always get the errors at the same item(s) when you run the code as the needed time for a procedure to complete is dependent on the current status of the system. So, you didn't get an error just once means little in this case.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2010, 10:37 pm 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
The errors appeared to happen randomly, this is mainly why I tried the sleep command.

Code:
items := Array()
itemnames := Array()
Loop % doc.Folder.Items.Count
{
   items.append(doc.Folder.Items.Item(A_Index - 1))
   itemnames.append(items[A_Index].Name)
   Sleep 10
}
Loop % Select.len()
{
   filter := Select[A_Index]
   If filter <>
   {
      If(InStr(filter, "*"))
      {
         filter := "\Q" StringReplace(filter, "*", "\E.*\Q", 1) "\E"
         filter := strTrim(filter,"\Q\E")
         Loop % items.len()
         {
            if(RegexMatch(itemnames[A_Index],"i)" filter))
            {
               COM_Invoke(doc,"SelectItem",items[A_Index],index=1 ? value1 : value) ;http://msdn.microsoft.com/en-us/library/bb774047(VS.85).aspx               
               index++
               ;Sleep 10
            }
         }
      }
      else
         COM_Invoke(doc,"SelectItem",doc.Folder.ParseName(filter),(A_Index=1 ? value1 : value)) ;http://msdn.microsoft.com/en-us/library/bb774047(VS.85).aspx               
   }
}


I also just tried this kind of loop so that Count is only requested once:
Code:
count := doc.Folder.Items.Count
Loop % count


It does not seem to do much to the frequency of errors, with both methods I get 0-2 errors on a folder with 44 elements, of which 42 should get selected.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2010, 7:25 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
So, back to the my first reply. I already suggested two other solutions than using sleep which may be the simplest but inaccurate. My preferred solution is using the event SelectionChanged, but it's really up to you which one to choose. BTW another simple solution may be turning off the error notification and when retrieving a name is failed, just retry it until succeeded. The result/name will be an empty string when failed. Or you can obtain the hResult(s) of the current invoke by using the global variable COM_HR/COM_LR or by calling COM_Error().


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2010, 8:40 am 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I guess I'll have to use one of those. The drawback of the SelectionChanged event would be having to split the function in two parts, but that's more of cosmetic nature. Thanks for your input!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 10th, 2010, 8:25 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Hi Sean, I have an error in AutoHotkey_L53 but same code works using COM.ahk
Any Idea what is wrong :(
Code:
COM_Init() ; Initialize COM.
d := COM_CreateObject("Scripting.Dictionary") ; Create dictionary.
d.Item("a", "Athens")
MsgBox % d.Item("a")
COM_Release(d) ; Done using dictionary d.
      
d := COMObjCreate("Scripting.Dictionary") ; Create dictionary.
d.Item("a", "Athens") ;Error:  0x8002000E - Invalid number of parameters.
d.Item("a") := "Athens" ;works fine
MsgBox % d.Item("a")

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 10th, 2010, 8:30 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
You already pointed out the issue - the item property is only supposed to have one param. The way the COM Library was designed, the second param was the value to be assigned. With built-in COM support, this is no longer valid syntax. See Item Property.

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 10th, 2010, 8:57 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
I see, thanks jethrow :roll:

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 11th, 2010, 6:00 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
I'm not sure if you want these messages in this thread or not, but I noticed a difference in performance between the COM Library to Built-In COM. The following works as expected with COM_CreateObject, but errors out with ComObjCreate:
Code:
x:=ComObjCreate("ScriptControl"), x.Language:="jScript", a:=x.Eval("a=[1,2]")

loop, % a.length {
   MsgBox, % a[A_Index-1] ; <-- Error:  0x80020006 - Unknown name.
   ; MsgBox, % a[n:=A_Index-1] ; works fine for both
   ; MsgBox, % a["" A_Index-1] ; works fine for both
}

EDIT - the exact error message is: Error: 0x80020006 - Unknown name. (error in the MsgBox line)
EDIT2 - This has now been fixed.

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Last edited by jethrow on August 11th, 2010, 11:45 pm, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 11th, 2010, 6:28 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
What was the exact error message? Anyway, the function name of a COM Object should be a string basically. And I suppose that the error was produced in your example since A_Index-1 was resolved to a name of an empty string. BTW, compare it with the following which will work as you expect:
Code:
MsgBox, % a[0] . "|" . a["0"]
MsgBox, % a[1] . "|" . a["1"]

Although making it work as you want is relatively straightforward (:which I don't like to add personally), I think you better post it in AHK_L thread.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 11th, 2010, 6:59 pm 
Offline

Joined: September 28th, 2007, 3:56 am
Posts: 279
Location: New York
I hate to keep being a bother about this but can someone help me out. I had a compiler working fine and now it doesn't.

I found that Compile_AHK II does not work with AutoHotKey_La.exe but the standard issue .ahk to .exe did. Now when using either I get issues.

When using Compile_AHK II I get:
Code:
Could not extract script from .EXE

When using .ahk to .exe I get:
Code:
Error at line 66.

The following variable name contains an illegal character:
".Name"

The program will exit.

It's at a line with rs.Fields(0).Name when trying to get the field name from an ADODB recordset.

I'm at a loss because it works without compiling.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 11th, 2010, 8:48 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
You need to use correct AutoHotkeySC.bin :!:

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2010, 12:53 pm 
Offline

Joined: September 28th, 2007, 3:56 am
Posts: 279
Location: New York
I don't know how that got screwed up but I know for next time, thanks. Sorry for the dumb mistake.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2010, 10:03 pm 
Just a thought, but now that AHKL has built-in COM Support, should all the COM_Enwrap calls in the COM_L Library be changed to ComObjEnwrap. I noticed this when trying to determine the ComObjType from an object created with COM_AtlAxCreateControl.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 13th, 2010, 6:03 am 
Many of the functions which use COM_Enwrap are also obsolete. I think that the following can probably be removed (but it wouldn't hurt to confirm): Init, Term, GetObject, GetActiveObject, AddRef, Release, Enumerate, Error, Invoke, Invoke_, Parameter, Dis/ConnectObject and dependencies (FindConnectionPoint, GetConnectionInterface, Advise, Unadvise, DispInterface, CreateIDispatch, GetDefaultEvents). That's a significant portion of the library. It's possible that some of these might be useful with non-dispatch COM interfaces (which aren't directly supported by AHK_L). On that note, CreateInstance must be kept as it allows non-dispatch objects to be created, but CreateObject can be removed as it's a simple wrapper around CreateInstance.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2010, 8:21 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Now you can think of COM.ahk as just a collection of miscellaneous functions which you can copy when you need them.

BTW, the supported features of COM_Invoke/COM_Parameter and those of the native COM are different. The most notable may be that COM.ahk does support named parameters. For the native COM to be competitive in this respect, I think it should support the same named parameters, or missing parameters, or both. My preference is the second one, support of missing parameters. Until then, I think better leave COM.ahk as it is.


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 ... 39, 40, 41, 42, 43, 44  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 24 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