473,802 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FindWindow and GetCursorPos

2 New Member
Hi all you good m8

I try to make my first small program in vb, but im not very succesfull :D
(Im using Visual Studio 2005)

Form my own program i will like to set focus on an other running application. Then i will get and set cursor positon. After that i will like to send KeyCommand.

But to start with i will be very happy if i can get "user32" dll to work :)
Therefore i have try this code - but i got a 18 character long number back as windowshandel - can it be right ?

I have the feeling that my use of "user32" is wrong - im using windows XP.
Hobe any can help me :o)

Private Structure POINTAPI
Dim X As Integer
Dim Y As Integer
End Structure

Private Declare Function GetCursorPos Lib "user32" Alias "GetCursorP os" (ByVal lpPoint As POINTAPI)
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Public Declare Function FindWindow Lib "user32.dll " Alias "FindWindow A" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Public Function WindowHandle(By Val sTitle As String) As Long
WindowHandle = FindWindow(vbNu llString, sTitle)
End Function

Dim mouseposition As POINTAPI
Dim notepadID As Long
Dim lhWnd As Long

Sub Main()
' Shell runs a new instance of Notepad.
notepadID = Shell("C:\windo ws\system32\NOT EPAD.EXE", AppWinStyle.Nor malFocus)
' Activate the new instance of Notepad.
AppActivate(not epadID)

'First look at ID
lhWnd = FindWindow("Unt itled Notepad", vbNullString)
MsgBox(CStr(lhW nd))

'Next look at ID
MsgBox(WindowHa ndle("Untitled Notepad"))

End Sub
Sep 26 '06 #1
0 2530

Sign in to post your reply or Sign up for a free account.

Similar topics

17
3074
by: lauren quantrell | last post by:
I have an Access application with the name: MyAppName® It has the "®" symbol (ChrW$(&H00AE)) at the end of it. If I remane the application without the "®" symbol, I can use FindWindow to close the application, but with the "®" symbol it doesn't. Unfortunaetley this app is already distributed as MyAppName® and I cannot change it. I have tried: hwnd = FindWindow(vbNullString, "myAppName" & ChrW$(&H00AE)) But it won't work. Yikes.
5
27286
by: Tony | last post by:
I need to send a message to a window in another application. The name of the window is known at design time and set in the constant App2_MONITOR_CAPTION. The message is defined as X_GenerateEvent. The following VB6 code works. I assume this is possible in C#. How do you do it? Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
5
7057
by: victor | last post by:
Help .... This is my situation: I've made two apps, a Managed C# and an Unmanaged MFC. The C# app communicates with the MFC-app via (Win32-API) PostMessage, done with the P/Invoke method. One of the activities is "FindWindow". Everything works fine. Until ...: I needed the same procedure within another context: now I need to communicate the C# with a web service (dll) running somewhere on a Server machine. This doesnot work anymore!
3
3106
by: kd | last post by:
Hi All, I need to check whether an application is executing. I do not know the class name of the application; however, I know the window caption of the application. What would be the first parameter that I should be passing to the FindWindow API, in order to check whether the application is executing? Thanks. kd
0
2814
by: ntm | last post by:
Hi all you good m8 I try to make my first small program in vb, but im not very succesfull :D (Im using Visual Studio 2005) Form my own program i will like to set focus on an other running application. Then i will get and set cursor positon. After that i will like to send KeyCommand. But to start with i will be very happy if i can get "user32" dll to work :) Therefore i have try this code - but i got a 18 character long number back as...
0
1554
by: Jim S | last post by:
Is looping FindWindow() ok? We have a simple little c# 2.0 app that’s sole purpose is to look for a dialog box from another app to pop up and then click it’s OK button. To do this we use a form with a timer control and some unmanaged code. The app works perfectly in test but I’m concerned about long term problems/leaks caused by frequent FindWindow calls (10 per second)? Although the popups might only occur 50-100 times a day,...
8
6661
by: Rajesh Soni | last post by:
Hi! I'm getting a PInvoke error while trying to execute the following code... declaration: Structure POINTAPI Dim x As IntPtr
2
7896
by: Alex | last post by:
Dear coleagues, I am trying to call FindWindow function but it seems not to be working. It returns a loooooong value even if the Window "SoftMaxPro GxP" is not started. I can't even find a window which is open. What am I doing wrong? Plese help.... Kind regards, Alex Imports System
1
6135
by: Damjan Malis | last post by:
Hi guys... could anyone please help me with my problem getting mouse cursor position while desktop being locked (WIN + L). MSDN says: "The input desktop must be the current desktop when you call GetCursorPos. Call OpenInputDesktop to determine whether the current desktop is the input desktop. If it is not, call SetThreadDesktop with the HDESK returned by OpenInputDesktop to switch to that desktop." src:...
6
4671
by: Jajjo | last post by:
Hey there, I'm experimenting with GetCursorPos instead of "static_cast"ing the LOWORD and HIWORD params. This is because I want to work with positions relative to teh screen. Myt question is this: Does the POINT object get updated when the mouse is outside of the edge of my program? If not, how do I constantly update the cursor position regardless of whether it's inside the edges of my program? Thanks guys/gals. -Jajjo
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10305
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.