Jump to content

WinMove


Recommended Posts

I am wanting to open a document using Notepad as the editor and have the Notepad window the size of the document as well as setting the x y position of the window. This code has no effect as the Notepad window is the size and position it was in when last closed.

Global $sLogDirHelp = @ScriptDir & "\Help\
Global $sESVersion = "sESVersion.txt" 
ShellExecute($sESVersion, "", $sLogDirHelp, "Edit")
WinActivate("[CLASS:Notepad]", "")
WinMove("[CLASS:Notepad]","",-1, -1, 500,300)

Help is always appreciated Ant.. Posted Image

Link to comment
Share on other sites

Try ShellExecuteWait instead of ShellExecute?

I use ShellExecute with a time out routine

Func _AutoCloseNotepadExe()
    While 1
        $MenuStartCycle = TimerInit()
        ;//Exit after nn Minutes
        While 1
            $MenuEndCycle = TimerDiff($MenuStartCycle)
            If $MenuEndCycle >= $EndMenuTimer * $sTextDurationX Then
                ProcessClose($sNotePadExe)
                ExitLoop (2)
            EndIf
            Sleep($SleepSLD)
            If Not ProcessExists($sNotePadExe) Then ExitLoop (2)
        WEnd
    WEnd
EndFunc   ;==>_AutoCloseNotepadExe

The issues with ShellExecuteWait is how do you time it out.

Ant..

Link to comment
Share on other sites

Try using the window handle, could work.

Global $sLogDirHelp = @ScriptDir & "\Help\"
Global $sESVersion = "sESVersion.txt" 
ShellExecute($sESVersion, "", $sLogDirHelp, "Edit")
$hWin = WinActivate("[CLASS:Notepad]", "")
WinMove("$hWin","",-1, -1, 500,300)
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Try using the window handle, could work.

Global $sLogDirHelp = @ScriptDir & "\Help\"
Global $sESVersion = "sESVersion.txt" 
ShellExecute($sESVersion, "", $sLogDirHelp, "Edit")
$hWin = WinActivate("[CLASS:Notepad]", "")
WinMove("$hWin","",-1, -1, 500,300)

Tried that and it does not work either if I was to guess then ShellExecute has got hold of the window simply because if you open the file yourself comment out ShellExecute it works. Now why is that so? Ant.. Edited by anixon
Link to comment
Share on other sites

  • Moderators

anixon,

You need to wait until the Notepad window is active before you try to use WinMove, so instead of WinActivate, use WinWaitActive:

Global $sLogDirHelp = @ScriptDir & "\Help\"
Global $sESVersion = "sESVersion.txt"
ShellExecute($sESVersion, "", $sLogDirHelp, "Edit")
WinWaitActive("[CLASS:Notepad]", "")
WinMove("[CLASS:Notepad]", "", Default, Default, 500, 300)

Using this I get Notepad opening to the size it was when last closed and then immediately resizing to the required dimensions. :mellow:

M23

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

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...