|
-
Jun 17th, 2012, 03:36 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] position external application?
i want to move a program that already is running, and by move, i mean change the x and y coordinates of the application on the screen. how would i go about doing this?
-
Jun 17th, 2012, 03:55 PM
#2
Re: position external application?
here's an example that finds + moves an instance of notepad:
vb Code:
Public Class Form1
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Const HWND_TOPMOST As Integer = -1
Const HWND_NOTOPMOST As Integer = -2
Const SWP_NOSIZE As Integer = &H1
Const SWP_NOACTIVATE As Integer = &H10
Const SWP_SHOWWINDOW As Integer = &H40
Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As IntPtr, ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim iHwnd As IntPtr = FindWindow("notepad", vbNullString)
SetWindowPos(iHwnd, HWND_TOPMOST, 100, 100, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOSIZE)
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 18th, 2012, 02:06 AM
#3
Thread Starter
Fanatic Member
Re: position external application?
this works nicely, but how would i go about finding the window from process id, instead of a name?
-
Jun 18th, 2012, 04:31 AM
#4
Re: position external application?
 Originally Posted by Justa Lol
this works nicely, but how would i go about finding the window from process id, instead of a name?
try GetProcessById,
Code:
Dim p = Process.GetProcessById(pid)
Dim iHwnd = p.MainWindowHandle
If Not iHwnd.Equals(IntPtr.Zero) Then
SetWindowPos(iHwnd, .....
-
Jun 18th, 2012, 02:39 PM
#5
Thread Starter
Fanatic Member
Re: position external application?
thanks very much i tried to use process.getprocessbyid, but i did it wrong
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|