AutoHotkey Community

It is currently May 27th, 2012, 6:01 am

All times are UTC [ DST ]




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1036 posts ]  Go to page Previous  1 ... 58, 59, 60, 61, 62, 63, 64 ... 70  Next
Author Message
 Post subject:
PostPosted: September 28th, 2010, 9:01 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
jethrow wrote:
Is there currently any way to support missing parameters ... ?
I haven't tested, but based on COM.ahk, I suppose this might work:
Code:
ComMissing() {  ; VT_ERROR:=10, DISP_E_PARAMNOTFOUND:=0x80020004
    static prm := ComObjParameter(10,0x80020004)
    return prm
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2010, 2:16 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Thank you Lexikos - I confimed that does work :) - though I just realized that's the first question Sean answered for me.

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 28th, 2010, 2:43 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
When dealing with COM, currently AHK_L passes an Object parameter which is not a ComObject as VT_EMPTY. I think it better be passed as (VT_ERROR, DISP_E_PARAMNOTFOUND), which will also ease the usage of missing parameters like in this case.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 28th, 2010, 9:08 pm 
Offline

Joined: August 2nd, 2009, 6:40 am
Posts: 215
I am attempting to use SendMessage to retrieve LB_GETSELITEMS.
This is not possible with normal AHK due to the requirement of an array parameter:
(Line from VB Code) ---> SendMessage ThisBox.hwnd, LB_GETSELITEMS, iNumItems, ItemIndexes(0)
VB Code:
Code:
Private Declare Function SendMessage Lib "user32" _
   Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg _
   As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const LB_GETSELITEMS = &H191

Public Function SelectedItems(ThisBox As ListBox) _
   As Collection
Dim ItemIndexes() As Long, x As Integer
Dim colItems As Collection, iNumItems As Integer
iNumItems = ThisBox.SelCount
If iNumItems Then
   ReDim ItemIndexes(iNumItems - 1)
   Set colItems = New Collection
   SendMessage ThisBox.hwnd, LB_GETSELITEMS, _
      iNumItems, ItemIndexes(0)
End If
For x = 0 To iNumItems - 1
   colItems.Add ThisBox.List(ItemIndexes(x))
Next x
Set SelectedItems = colItems
Set colItems = Nothing
End Function

I can LB_GETCOUNT with an AHK function:
Code:
LB_GetCount(byRef controlName="", byRef activeWin="")
{
   activeWin := (!activeWin ? "A" : activeWin)
   if( !controlName )
      ControlGetFocus, controlName, %activeWin%
   ; LB_GETCOUNT = 0x18B
   sendMessage, 0x18B, 0x0, 0x0, %controlName%, %activeWin%
return !(ErrorLevel=="FAIL" ? ErrorLevel : 0)
}
(Related VB Code above) ---> iNumItems = ThisBox.SelCount

What I can't figure out, is if it's possible to do something like the following for LB_GetSelItems()
Code:
LB_GetSelItems(controlName="", byRef activeWin="")
{
   if( !(iNumItems := LB_GetCount(controlName, activeWin)) )
      return 0
   ControlGet, cID, Hwnd,, %controlName%, %activeWin%
   A__itemDX := Object()
   SendMessage, %cID%, 0x191, %iNumItems%, %A__itemDX%
return A__itemDX
}
Which doesn't work as is.

I also thought perhaps that's not the correct parameter order,
but neither of these SendMessage's work either:
--> SendMessage, 0x191, %iNumItems%, &A__itemDX, ahk_id %cID%
--> SendMessage, 0x191, %iNumItems%, %A__itemDX%, ahk_id %cID%
--> SendMessage, 0x191, %iNumItems%, A__itemDX[0], ahk_id %cID%
--> SendMessage, 0x191, %iNumItems%, A__itemDX, ahk_id %cID%

Possibly address referencing could be used, from the Help:
Object( address | object )
Quote:
address := Object(object)
object := Object(address)

But I'm not familiar enough to know where to start with that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 29th, 2010, 8:16 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Has nothing to do with AHKL (and no, u can't send object address, the fact that you can do so in VB here means nothing). See this (can be simplified now with NumGet).

The point of confusion for you is that in VB, you can declare array to hold integers (long) so VB lets you specify first array element as syntax sugar (it can deduce from array declaration how to get the data). In AHK variables are not declared (and in AHKL array too which serves as container of variables)

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject: comerror handling
PostPosted: September 30th, 2010, 5:22 pm 
Offline

Joined: August 3rd, 2007, 8:01 am
Posts: 555
Location: Houston, TX
I know the documentation says that handling specific com errors is not supported, but sean had posted this:
Code:
ComObjConnect("ComError", "ErrMsg")
...

ErrMsg(err)
{
   MsgBox 0, COM Error, % "Name:`t" err.Name "`n" err.Number ":`t" err.Message "`nSource:`t" err.Source "`nDescription:`t" err.Description "`nHelp:`t" err.HelpFile "," err.HelpContext
}
Can this work with the current release of AutoHotkey_L ?
The following doesn't work:
Code:
ComObjConnect("ComError", "ErrMsg")
comobjcreate("bla") ; causes com error becaause bla doesn't exist
return

ErrMsg(err)
{
msgbox catching error ; doesn't work
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2010, 2:55 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
No.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2010, 11:21 pm 
Offline

Joined: March 9th, 2009, 12:15 am
Posts: 28
Hi,
the following call works on "normal" autohotkey build, but not on the Lexikos build. (WinXP)
Why? I could not find any hint in the doc or this thread...
Code:
DllCall("shell32\ShellExecuteA", "uint", 0, "uint", 0
, "str", "c:\"     ; path of file
, "uint", 0    ; arguments
, "uint", 0      ; working dir
, "int", 1)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2010, 2:52 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Are you using a Unicode build? What do you think ShellExecuteA expects?
Quote:
Note: When passing a string to a function, be aware what type of string the function expects.

Source: DllCall - Str

Quote:
AStr, WStr

[AHK_L 42+]: An ANSI or Unicode (Wide character) string.


Source: DllCall - AStr

There's also a section going into detail about Script Compatibility: DllCall.
Quote:
I could not find any hint in the doc or this thread...
Did you look? :roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2010, 11:22 am 
Offline

Joined: March 9th, 2009, 12:15 am
Posts: 28
Lexikos, thanks for the info.

But there is a small inconsistency - the manual says:
Quote:
Str -- TCHAR*, LPTSTR, LPCTSTR Equivalent to WStr in Unicode builds and AStr in ANSI builds.

I tried it with "Str" the ansi build, but it still does not work - it explicitly requires "AStr".


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2010, 12:17 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
"Str" and "AStr" share the same implementation on the ANSI build, so it is impossible for them to give different results. Your DllCall works just fine with "str" on my ANSI build. I suspect your "ansi build" was in fact a Unicode build, in which case the following would show "1":
Code:
MsgBox % A_IsUnicode

Anyway, read the links I gave again. In particular, the DllCall section under Script Compatibility explains about the "A" suffix and demonstrates why you should omit it when you are using the "Str" type. You don't need to use the ANSI build just to call ShellExecute. For that matter, you most likely don't need to call ShellExecute at all; use the Run command.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2010, 1:12 pm 
Offline

Joined: March 9th, 2009, 12:15 am
Posts: 28
you are right: A_IsUnicode shows "1".
But the autohotkey.exe (344064 bytes) is from the file: Autohotkey_La.zip from your download page named as ANSI x86.

The problem occurred on an old script - i've replaced the dllcall now with the "run" cmd and it works also.

Thanks for your time!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2010, 3:16 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
I checked just now and confirmed the AutoHotkey.exe contained within AutoHotkey_La.zip is 344064 bytes as you say (and the current Unicode build is not), but it shows A_IsUnicode is empty/undefined (as it should be), not 1.

How did you launch the script? I'm convinced you're not using the EXE you think you're using.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2010, 4:08 pm 
Offline

Joined: March 9th, 2009, 12:15 am
Posts: 28
i launch it in total commander: autohotkey.exe test.ahk
where both files are in current directory.

Edit: i made additional tests: .bat file or cmdline call with autohotkey.exe test.ahk runs the right version (from current directory), but the same line in total commander uses the wrong version (associated with .ahk files).

As it turned out, its a bug in total commander.
Sorry for bothering you Lexikos.


Last edited by Moebius on October 3rd, 2010, 10:54 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2010, 7:05 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Quote:
Revision 61 - October 3, 2010
  • Added: ObjClone(Object), forgotten when Object.Clone() was implemented.
  • Added: Support for RegEx Unicode properties in Unicode builds. Also upgraded PCRE to 8.10.
  • Added: Object.Remove(int, "") - removes Object[int] without affecting other keys.
  • Changed: ComObj.xyz() is now always treated as a method-call.
  • Changed: Var := 123 is now left as an expression, for consistency. This makes Var := 123 and Var := (123) equivalent, whereas previously the former assigned only a string and the latter assigned both a string and a cached binary integer. In particular, this avoids some confusing type mismatch errors with COM objects.
  • Fixed: Dynamic variadic calls to functions with mandatory parameters.
  • Fixed: The final parameter of an assume-global variadic function had to be explicitly declared local.
  • Fixed: Static initializers interfering with setting of breakpoints.
  • Fixed: More pointer size-related errors with PCRE callouts on x64 builds.
  • Fixed: Input with 'M' option treated Ctrl-M (`r) as Ctrl-J (`n).
  • Fixed: Object.Remove(n) returned 0 (not "") if Object[n] didn't exist.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1036 posts ]  Go to page Previous  1 ... 58, 59, 60, 61, 62, 63, 64 ... 70  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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