DonkeyHottt 14:09 03-10-2008 Цитата: как в vbs заставить активное окно переместиться в нужное место экрана?
Встроенными средствами никак.
Можно использовать
AutoItX3.dll:
Код: On Error Resume Next
'================== AutoItX3.Control Object Check & Register ==================
Set oShell = WScript.CreateObject("WScript.Shell")
Set oFS = WScript.CreateObject("Scripting.FileSystemObject")
AutoItX3_dll = ".\AutoItX3.dll"
If Not oFS.FileExists(AutoItX3_dll) Then
MsgBox "AutoItX3.dll Not found." & vbCRLF & vbCRLF & "OK ==> EXIT", 16, "Error"
WScript.Quit 0
End If
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
If Not IsObject(oAutoIt) Then
oShell.Exec "regsvr32.exe /S " & oFS.GetFile(AutoItX3_dll).Path
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
If Not IsObject(oAutoIt) Then
MsgBox "Can not register the AutoItX3.Control object." & vbCRLF & vbCRLF & "OK ==> EXIT", 16, "Error"
WScript.Quit 0
End If
End If
'================== AutoItX3.Control Object Check & Register ==================
'================================ Script Part ================================
'Title
sTitle = "[CLASS:Notepad;TITLE:Безымянный]"
'Positions
xPos = 100
yPos = 200
Width = 350
Height = 250
'Run Notepad
iPID = oAutoIt.Run(oShell.ExpandEnvironmentStrings("%WinDir%") & "\Notepad.exe")
oAutoIt.WinWait sTitle, "", 5
'Set some text
oAutoIt.ControlSetText sTitle, "", "Edit1", "Test with AutoItX3.Control object"
'Activate the window
oAutoIt.WinActivate sTitle
'Change window positions
oAutoIt.WinMove sTitle, "", xPos, yPos, Width, Height
'Wait 2 seconds
oAutoIt.Sleep 3000
'Set closing text
oAutoIt.ControlSetText sTitle, "", "Edit1", ""
oAutoIt.ControlCommand sTitle, "", "Edit1", "EditPaste", "Now we close this window"
For i = 0 To 5
'Wait 1 second
oAutoIt.Sleep 1000
oAutoIt.ControlCommand sTitle, "", "Edit1", "EditPaste", "."
Next
'Close the Notepad
oAutoIt.ProcessClose iPID
'================================ Script Part ================================