Welcome to our forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Forum Statistics

  • Forum Members:
  • Total Threads:
  • Total Posts: 8
There are 1 users currently browsing forums.
Visual Basic Programming This area is for talking about programming with visual basic.

Reply
  #1  
Old 02-01-2007
A Toddler - Don't be Fooled!
 
Join Date: Apr 2006
Posts: 152
Rep Power: 5
types is on a distinguished road
VBS get window handle

Hi

I whenever i try to use the findwindow function, i get a type mismatch error. What do i do? do i have to declare it somewhere?
Reply With Quote
  #2  
Old 02-01-2007
waheedahmed's Avatar
C# += C++ += C ;
 
Join Date: Apr 2006
Location: Pakistan
Posts: 1,002
Rep Power: 6
waheedahmed is on a distinguished road
Re: VBS get window handle

You have to declare the FindWindow function. Could you post the error you are getting, if possible also post the code you are using.

Waheed
Reply With Quote
  #3  
Old 02-01-2007
GrantThomas's Avatar
Mr. Disappointment
 
Join Date: May 2006
Location: Newcastle Upon Tyne, England
Age: 25
Posts: 790
Rep Power: 5
GrantThomas is on a distinguished road
Re: VBS get window handle

The declaration of the 'FindWindow' function, in vb, should be...

Code:
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
...to use the ANSII character set...

Code:
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowW" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
...to use the Unicode character set, which is only supported on systems above NT4.

Maybe it could be you have a typo in your current declaration, or an error with the passed parameters, where do you get them from? are they variables?

Grant.
Reply With Quote
  #4  
Old 02-01-2007
A Toddler - Don't be Fooled!
 
Join Date: Apr 2006
Posts: 152
Rep Power: 5
types is on a distinguished road
Re: VBS get window handle

Still getting some errors, this is the current code:

Code:
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

FindwindowA("Shell_TrayWnd")
Reply With Quote
  #5  
Old 02-02-2007
hot_cakes's Avatar
Moderat0r!!1
 
Join Date: Aug 2005
Location: Bristol, UK
Age: 28
Posts: 2,939
Rep Power: 8
hot_cakes will become famous soon enough
Re: VBS get window handle

Please show the error that you get.

Complete guess: in your example, you only pass FindWindowA one argument whereas the declaration seems to indicate that it needs 2.

Edd
Reply With Quote
  #6  
Old 02-02-2007
waheedahmed's Avatar
C# += C++ += C ;
 
Join Date: Apr 2006
Location: Pakistan
Posts: 1,002
Rep Power: 6
waheedahmed is on a distinguished road
Re: VBS get window handle

You want to get the handle of the task bar (I think).

Code:
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
 
--------------------------------------------------------------------------------------------
        Dim handle As Long
        handle = FindWindow("Shell_TrayWnd", "")
NOTE: Its FindWindow not FindWindowA, since you used Alias, FindWindow is mapped to FindWindowA
If you are using VB6 or below you can use Null in place of "", in .NET you may use System.DBNull (System.DBNull.Value.ToString()), empty quotes work well.

Waheed
Reply With Quote
  #7  
Old 02-02-2007
A Toddler - Don't be Fooled!
 
Join Date: Apr 2006
Posts: 152
Rep Power: 5
types is on a distinguished road
Re: VBS get window handle

Code:
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
 
Dim handle As Long
handle = FindWindow("Shell_TrayWnd", "")
Produces the following error:
Reply With Quote
  #8  
Old 02-03-2007
waheedahmed's Avatar
C# += C++ += C ;
 
Join Date: Apr 2006
Location: Pakistan
Posts: 1,002
Rep Power: 6
waheedahmed is on a distinguished road
Re: VBS get window handle

I think VB script doesn't support declaring Windows APIs. Look at this http://msdn.microsoft.com/library/de...7f5a41f8b9.asp
go to VBA features not in VBS and look at the declare category, looks like VBS does not support declaring from DLLs , you may have to use VB itself or VBA perhaps.

Waheed

Last edited by waheedahmed; 02-03-2007 at 04:59 AM.
Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Close window and launch another Matty JavaScript Coding 8 10-08-2006 12:32 PM
how to pass variable between windows AngeloBlu JavaScript Coding 9 04-20-2006 03:16 AM
pass $_POST data into popup window ktsirig JavaScript Coding 7 04-19-2006 03:48 PM
new window redirect WMO PHP Scripting 16 12-21-2005 03:34 PM
pop up window scott300 JavaScript Coding 6 06-03-2005 01:57 PM