Jump to content

moving a window


sbrady
 Share

Recommended Posts

here is a GUI with 7 buttons. Very simply, most of the buttons open a window and places it. If you just look at the 'case' for button 3................it does NOT move the window to the numbers in the script. No matter what numbers I put in.........the window opens to the same place everytime.

; GUI create

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
;#include <Array.au3>

Example()

Func Example()
Local $Button_1, $Button_2, $Button_3, $Button_4,$Button_5,$Button_6,$Button_7, $msg
GUICreate("DAW1 Scripts", 220,320) ; will create a dialog box that when displayed is centered

;$textbox_input = GUICtrlCreateInput("AR123 Smith, Bob", 10, 35, 350, 20) ; will not accept drag&drop files
;$new_project_name = GUICtrlRead($textbox_input)

Opt("GUICoordMode", 2)
$Button_1 = GUICtrlCreateButton(" 1. Full Promo Prep", 20, 30, 180,30, $BS_LEFT)
$Button_2 = GUICtrlCreateButton(" 2. Open NPR Promo folder", -180, 10, 180,30, $BS_LEFT)
$Button_3 = GUICtrlCreateButton(" 3. Open Promo AM Folder", -180, 10, 180,30, $BS_LEFT)
$Button_4 = GUICtrlCreateButton(" 4. Open 1030View", -180, 10, 180,30, $BS_LEFT)
$Button_5 = GUICtrlCreateButton(" 5. Make NPR Promo folder", -180, 10, 180,30, $BS_LEFT)
$Button_6 = GUICtrlCreateButton(" 6. NEXTDAY to DMG", -180, 10, 180,30, $BS_LEFT)
$Button_7 = GUICtrlCreateButton(" 7. Rename Mixes", -180, 10, 180,30, $BS_LEFT)


GUISetState() ; will display an dialog box with 2 button

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop





;BUTTON 1 Promo Prep
Case $msg = $Button_1
;open each promo window
;MsgBox(8192, "Test", "you pushed button 1", 5)

; format the date
$the_month = @MON ; get the month 11
$the_day = @mday ;get the day 09
$the_year = @YEAR ;get the year 12
$the_year2 = StringTrimLeft ($the_year,2)
$todays_promo1 = $the_month & "-" & $the_day & "-" & $the_year2 & " Promos NPR" ;10-15-12 Promos NPR
$todays_promo2 = $the_month & "-" & $the_day & "-" & $the_year2 & " Promos" ;10-15-12 Promos

; set the path for the NPR Promo folder
$NPR_PROMO_FOLDER = "C:\Documents and Settings\sebrad\Desktop\shawn\Nuendo Projects\NPR Promo\" & $todays_promo1

; make the NPR folder at the usual location
DirCreate($NPR_PROMO_FOLDER) ; 10-15-12 Promo NPR



; open Promo AM folder
ShellExecute("C:\Documents and Settings\sebrad\Desktop\shawn\Promo AM")
$iCurrentMode = Opt("WinTitleMatchMode", 2)
WinMove("C:\Documents and Settings\sebrad\Desktop\shawn\Promo AM","",200,200,400,400)
;Opt("WinTitleMatchMode", $iCurrentMode)




; open 1030View folder
ShellExecute("C:\Documents and Settings\sebrad\Desktop\shawn\1030Viewfolder")
$iCurrentMode = Opt("WinTitleMatchMode", 2)
WinMove("C:\Documents and Settings\sebrad\Desktop\shawn\1030Viewfolder","",200,400,400,400)
;Opt("WinTitleMatchMode", $iCurrentMode)




;open todays NPR promo folder
ShellExecute("C:\Documents and Settings\sebrad\Desktop\shawn\Nuendo Projects\NPR Promo\" & $todays_promo1)
$iCurrentMode = Opt("WinTitleMatchMode", 2)
WinMove("C:\Documents and Settings\sebrad\Desktop\shawn\Nuendo Projects\NPR Promo\" & $todays_promo1,"",400,400,400,400)
;Opt("WinTitleMatchMode", $iCurrentMode)


; end button 1




















;BUTTON 2 Open NPR Promo folder
Case $msg = $Button_2
MsgBox(8192, "Test", "you pushed button 2", 5)

; get the month 11
$the_month = @MON

;get the day 09
$the_day = @mday

;get the year 12
$the_year = @YEAR
$the_year2 = StringTrimLeft ($the_year,2)

$todays_promo1 = $the_month & "-" & $the_day & "-" & $the_year2 & " Promos NPR" ;10-15-12 Promos NPR
$todays_promo2 = $the_month & "-" & $the_day & "-" & $the_year2 & " Promos" ;10-15-12 Promos

; set the path for the NPR Promo folder
$NPR_PROMO_FOLDER = "C:\Documents and Settings\sebrad\Desktop\shawn\" & $todays_promo1

; make the folder at the usual location
DirCreate($NPR_PROMO_FOLDER) ; 10-15-12 Promo NPR



; put the Promo title on the clipboard
;ClipPut($todays_promo2) ; 10-15-12 Promo
; end button 2

;open todays NPR promo folder
ShellExecute("C:\Documents and Settings\sebrad\Desktop\shawn\Nuendo Projects\NPR Promo")
$iCurrentMode = Opt("WinTitleMatchMode", 2)
WinMove("C:\Documents and Settings\sebrad\Desktop\shawn\Nuendo Projects\NPR Promo","",400,120,800,700)
Opt("WinTitleMatchMode", $iCurrentMode)











;Button 3 Open Promo AM Folder
Case $msg = $Button_3
;MsgBox(8192, "Test", "you pushed button 3", 5)
ShellExecute("C:\Documents and Settings\sebrad\Desktop\shawn\Promo AM")
;$iCurrentMode = Opt("WinTitleMatchMode", 2)
;WinWait("C:\Documents and Settings\sebrad\Desktop\shawn\Promo AM", "", 1)
WinMove("C:\Documents and Settings\sebrad\Desktop\shawn\Promo AM","",50,20,800,700)
;Opt("WinTitleMatchMode", $iCurrentMode)
;end button 3

















; BUTTON 4 Open 1030view Folder
Case $msg = $Button_4
MsgBox(8192, "Test", "you pushed button 5", 5)
ShellExecute("C:\Documents and Settings\sebrad\Desktop\shawn\1030Viewfolder")
$iCurrentMode = Opt("WinTitleMatchMode", 2)
WinMove("C:\Documents and Settings\sebrad\Desktop\shawn\1030Viewfolder","",400,120,800,700)
Opt("WinTitleMatchMode", $iCurrentMode)
; end button 4
















; BUTTON 5 Make NPR Promo folder
Case $msg = $Button_5
MsgBox(8192, "Test", "you pushed button 5", 5)
; month
$the_month = @MON

;the day
$the_day = @mday

;the year
$the_year = @YEAR
$the_year2 = StringTrimLeft ($the_year,2)

; set the name for DMG (Digital Media Group)
$todays_promo_NPR = $the_month & "-" & $the_day & "-" & $the_year2 & " Promos NPR";NEXTDAY 10-15-12
; end button 5


Local $todays_NPR_promo_folder = "C:\Documents and Settings\sebrad\Desktop\shawn\Nuendo Projects\" & $todays_promo_NPR
DirCreate($todays_NPR_promo_folder)













; BUTTON 6 NEXTDAY to DMG
Case $msg = $Button_6
MsgBox(8192, "Test", "you pushed button 6", 5)

; month
$the_month = @MON

;the day
$the_day = @mday

;the year
$the_year = @YEAR
$the_year2 = StringTrimLeft ($the_year,2)

; set the name for DMG (Digital Media Group)
$todays_promo_DMG = "NEXTDAY " & $the_month & "-" & $the_day & "-" & $the_year2 ;NEXTDAY 10-15-12

ShellExecute("\\10.100.20.40\DMG Drop Off\Streaming\PROMOS") ; open DMG folder
WinWait("PROMOS") ; wait till the drive exists
WinMove("PROMOS","",50,800,200,300) ; open the drive in lower left of the screen
$NDP_SRC = "D:\Promos\NEXTDAY.mxf"
$DEST = "\\10.100.20.40\DMG Drop Off\Streaming\PROMOS\" & $todays_promo_DMG
FileCopy ($NDP_SRC,$DEST) ;move NEXTDAY and rename to DMG
; end button 6

ShellExecute("C:\Documents and Settings\sebrad\Desktop\shawn\DMG")
$iCurrentMode = Opt("WinTitleMatchMode", 2)
WinMove("C:\Documents and Settings\sebrad\Desktop\shawn\DMG","",400,120,800,700)
Opt("WinTitleMatchMode", $iCurrentMode)



















; BUTTON 7 Rename Mixes
Case $msg = $Button_7
MsgBox(8192, "Test", "you pushed button 7", 5)
; end button 7


















EndSelect
WEnd
EndFunc ;==>Example
Link to comment
Share on other sites

Why do you have the winwait commented out?

Add some debugging:

$hWin =  WinMove("C:Documents and SettingssebradDesktopshawnPromo AM","",50,20,800,700)

If IsHwnd($hWin) Then
 consolewrite ("able to find window" & @crlf)
Else
 consolewrite ("UNable to find window" & @crlf)
EndIf

winmove returns:

Return Value

Success: Returns handle to the window. Failure: Returns 0 if window is not found.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

new code

ShellExecute("C:Documents and SettingssebradDesktopshawnPromo AM2")
$iCurrentMode = Opt("WinTitleMatchMode", 2)
WinMove("C:Documents and SettingssebradDesktopshawnPromo AM2","",50,20,800,700)
Opt("WinTitleMatchMode", $iCurrentMode)
sleep (200)

WinActive ( "Promo AM2" )

window output::

>"C:Program FilesAutoIt3SciTE..autoit3.exe" /ErrorStdOut "C:Documents and SettingssebradMy DocumentsSB AutoITDAW1 Scriptsopen folder and place.au3"

>Exit code: 0 Time: 1.647

Link to comment
Share on other sites

oh, not the console output. AutoIT comes with an exe = auto it window info tool

launch that, and drag the cursor over the window you are trying to attach to...copy the tool's info to the forum

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

>>>> Window <<<<

Title: Promo AM2

Class: CabinetWClass

Position: 55, 76

Size: 576, 517

Style: 0x16CF0000

ExStyle: 0x00000100

Handle: 0x005802E4

>>>> Control <<<<

Class: SysListView32

Instance: 1

ClassnameNN: SysListView321

Name:

Advanced (Class): [CLASS:SysListView32; INSTANCE:1]

ID: 1

Text: FolderView

Position: 263, 91

Size: 305, 386

ControlClick Coords: 137, 112

Style: 0x56100248

ExStyle: 0x00000000

Handle: 0x0099051C

>>>> Mouse <<<<

Position: 459, 315

Cursor ID: 2

Color: 0xF7F7F7

>>>> StatusBar <<<<

1: 3 objects

2: 0 bytes

3: My Computer

>>>> ToolsBar <<<<

>>>> Visible Text <<<<

C:Documents and SettingssebradDesktopshawnPromo AM2

C:Documents and SettingssebradDesktopshawnPromo AM2

FolderView

>>>> Hidden Text <<<<

3 objects

Link to comment
Share on other sites

  • Moderators

sbrady,

On my Vista system the path of an Explorer window is only visible in the "text" tab of the Window Info Tool. So you have the wrong parameters in WinWait and WinMove - which is why AutoIt does not find the window. ;)

If you do something like this it should work - it certainly does for me:

ShellExecute("Your_Path")
$hHandle = WinWait("", "Your_Path")        ; Look for the path in the text and get the handle of the window
WinMove($hHandle, "", 100, 120, 400, 400)  ; use the handle here

All clear? :)

M23

Edit: I see from the above that your XP system does the same so it should work for you too. :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

maybe, to narrow down the search, you should include the window class to search for:

ShellExecute("Your_Path")
$hHandle = WinWait("[CLASS:CabinetWClass]", "Your_Path")        ; Look for the path in the text and get the handle of the window
WinMove($hHandle, "", 100, 120, 400, 400)  ; use the handle here

just in case some other window exists with the text (doubtful, but why not)

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...