Area751 Posted May 1, 2008 Share Posted May 1, 2008 I'm using AutoItX as COM object in Csharp. string handle = oAutoIt.WinGetHandle("Untitled - Notepad",""); oAutoIt.WinMove(handle,"",0,0,640,480); I can't get this to work. Does anyone know what I am doing wrong? It works perfectly if I use WinMove() function with "Untitled - Notepad" instead of passing the handle. Thanks. Link to comment Share on other sites More sharing options...
DarkMatter Posted May 1, 2008 Share Posted May 1, 2008 (edited) WinMove accepts the Title of the window only. Not a handle.This is in VB.NET 2005:Imports AutoItX3Lib Public Class Form1 Dim oAutoit As AutoItX3 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load oAutoit = New AutoItX3 oAutoit.WinMove("Untitled - Notepad", "", 0, 0, 640, 480) End Sub End Class Edited May 1, 2008 by DarkMatter [sub]Quantum mechanics: The dreams stuff is made of[/sub] Link to comment Share on other sites More sharing options...
Area751 Posted May 1, 2008 Author Share Posted May 1, 2008 (edited) WinMove accepts the Title of the window only. Not a handle.I am going to have multiple windows with the same Title. That's why I wanted to use the handle.Is there a solution for this?BTW I found in the documentation that every function that accepts a title, can also be used by providing the handle to the window. So it seems that WinMove is an exception to this rule?edit: the documentation is at the bottom of this page: http://hiddensoft.com/autoit3/docs/intro/windowsadvanced.htm Edited May 1, 2008 by Area751 Link to comment Share on other sites More sharing options...
DarkMatter Posted May 1, 2008 Share Posted May 1, 2008 (edited) I think it might be an exception for the COMObject itself. If you do the following: Dim Handle As String oAutoIT = New AutoItX3 Handle = oAutoIT.WinGetHandle("Untitled - Notepad") Debug.WriteLine(oAutoIT.WinMove(Handle, "", 0, 0, 480, 600)) 0 is written to the debug window. Return Value Success: Returns 1. Failure: Returns 0 if window is not found. 0 is indicating that the window was not found. Now what you could do is just do a straight call to MoveWindow in user32.dll Public Declare Auto Function MoveWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal X As Int32, ByVal Y As Int32, ByVal nWidth As Int32, _ ByVal nHeight As Int32, ByVal bRepaint As Boolean) As Boolean Edited May 1, 2008 by DarkMatter [sub]Quantum mechanics: The dreams stuff is made of[/sub] Link to comment Share on other sites More sharing options...
DarkMatter Posted May 1, 2008 Share Posted May 1, 2008 (edited) Here is some sample code of what I was talking about in VB.NET 2005: Full Code: Private Declare Function MoveWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal X As Int32, ByVal Y As Int32, ByVal nWidth As Int32, ByVal nHeight As Int32, ByVal bRepaint As Boolean) As Boolean Private Declare Auto Function FindWindow Lib "user32.dll" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim Handle As IntPtr Handle = FindWindow(Nothing, "Untitled - Notepad") MoveWindow(Handle, 0, 0, 480, 600, True) End Sub Plus this is a cleaner way than having DLLs with your app... Edited May 1, 2008 by DarkMatter [sub]Quantum mechanics: The dreams stuff is made of[/sub] Link to comment Share on other sites More sharing options...
ProgAndy Posted May 1, 2008 Share Posted May 1, 2008 Mybe the AutoIt-Code would work, if you used Dim Handle As Long *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
DarkMatter Posted May 1, 2008 Share Posted May 1, 2008 Tried it already... Accepts a string not long you will get a type mismatch. [sub]Quantum mechanics: The dreams stuff is made of[/sub] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 1, 2008 Moderators Share Posted May 1, 2008 I am going to have multiple windows with the same Title. That's why I wanted to use the handle.Is there a solution for this?BTW I found in the documentation that every function that accepts a title, can also be used by providing the handle to the window. So it seems that WinMove is an exception to this rule?edit: the documentation is at the bottom of this page: http://hiddensoft.com/autoit3/docs/intro/windowsadvanced.htmYou are looking at the online documentation for AutoIt itself, not the AutoItX.Since autoit itself handles variant data types, I'd suggest maybe making one yourself with MoveWindow and overloading the function(s) to accept strings/hwnds... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Area751 Posted May 2, 2008 Author Share Posted May 2, 2008 Thanks DarkMatter. I solved it by using user32.dll ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now