Re: want to resize window in vbs
- From: "Gary Roach" <jgroach@xxxxxxxxxxxxxxx>
- Date: Thu, 14 Apr 2005 14:16:01 -0400
thanks jw,
it sounds like what i'm doing can't be done without a c++ compiler. however,
from what you said, it seems i should be able to get the address of a vbs
variant using the varptr function. i tried the vba version at it worked
properly for variants. however, when i tried this code:
UserWrap.Register "msvbvm50.dll", "VarPtr", "i=l", "f=s", "r=l"
Dim PID
Dim lpProcessID
lpProcessID = UserWrap.VarPtr(PID)
UserWrap.MessageBoxA Null, CStr(lpProcessID), "From DynaWrap Object", 3
i get "0" for the pointer. i don't know why that is, since i should be
interfacing to the same function that i called from VBA. if this would work,
then as you say all i have to do is add 8 to the value to get the pointer to
the long.
"mr_unreliable" <kindlyReplyToNewsgroup@xxxxxxxxxxx> wrote in message
news:OfPQPMRQFHA.2932@xxxxxxxxxxxxxxxxxxxxxxx
> hi Gary,
>
> For one thing, I'm surprised you get anything to work with DynaWrap,
> becasue you appear to be ignoring my advice about type-casting
> parameters (i.e., CStr(var), CLng(var), etc.).
>
> But as to your question about GetWindowThreadProcessID, you have
> run up against a limitation of DynaWrap that I don't know any way
> around. More specifically, processID is an [out] parameter, and
> as such must be passed "ByRef". DynaWrap does have a provision
> for byref parameters, BUT ONLY STRING parameters. Too Bad.
>
> There are a couple of ways to address this. For one, if you or
> a friend knows c++, you could take the source code provided and
> build in a capability for byref longs. Or alternatively, you
> could get a "pointer" (memory address) to your processID variable,
> and pass the pointer instead of the variable. The problem (or
> really two problems) is getting the pointer. You could get it
> with vb, using the VarPtr function (directly, or by writing an
> actX utility). Then you get to the second problem, i.e., that
> the vbscript variables are VARIANTS. That means that the address
> of the actual "long" value is 8 bytes beyond the address of the
> variant (those other bytes contain an integer which defines
> the type of the variant and three "filler" integers).
>
> Actually, if you are going to re-write DynaWrap, what I would
> really like to see would be for it to accept a VARIANT parameter.
> Then we could call vb's VarPtr directly with DynaWrap itself.
>
> oDW.Register("msvbvm50.dll", "VarPtr", "i=v", "f=s", "r=l")
> lpProcessID = oDW.VarPtr(myProcessID) + 8 ' add 8 bytes
> ThreadID = oDW.GetWindowThreadProcessID(CLng(hWnd), CLng(lpProcessID))
> MsgBox("GWTProcID returned: " & CStr(myProcessID))
>
> But of course that is all "air code".
>
> Sorry, but DynaWrap has some limitations, and I don't believe it
> will work in the situation you describe.
>
> I expect you will need to find some other solution.
>
> cheers, jw
>
> Gary Roach wrote:
>> thanks for the reply. i got dynacall and used some of your code. i'm
>> having a problem finding windows. i'm using a routine that cycles through
>> windows looking for the one i want. it uses a win32 routine called
>> GetWindowThreadProcessId() that takes a reference to a long uint and uses
>> it to pass back the PID given an hwnd. it works in VBA but not in vbs.
>> any idea how to make this work? thanks again for the help. here's the
>> code:
>>
>> UserWrap.Register "USER32.DLL", "GetWindowThreadProcessId", "I=Hl",
>> "f=s", "R=l"
>>
>> hWndJob = UserWrap.FindWindowA(vbNullString, vbNullString)
>> Do Until hWndJob = 0
>> If UserWrap.GetParent(hWndJob) = 0 Then
>> Call UserWrap.GetWindowThreadProcessId(hWndJob, PID)
>> If PID = ProcessID Then Exit Do
>> End If
>> hWndJob = UserWrap.GetWindow(hWndJob, 2)
>> Loop
.
- Follow-Ups:
- Re: want to resize window in vbs
- From: mr_unreliable
- Re: want to resize window in vbs
- References:
- want to resize window in vbs
- From: Gary Roach
- Re: want to resize window in vbs
- From: mr_unreliable
- Re: want to resize window in vbs
- From: Gary Roach
- Re: want to resize window in vbs
- From: mr_unreliable
- want to resize window in vbs
- Prev by Date: Re: want to resize window in vbs
- Next by Date: Re: Network Distribution of WSH
- Previous by thread: Re: want to resize window in vbs
- Next by thread: Re: want to resize window in vbs
- Index(es):
Relevant Pages
|
Loading