Sign in to follow this  
Followers 0
anixon

WinMove

9 posts in this topic

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

Share this post


Link to post
Share on other sites



Use Default instead of -1


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Use Default instead of -1

Tried that and it does not work either it only works if the document is already open and not called using 'Shellexecute' Ant..

Share this post


Link to post
Share on other sites

Try ShellExecuteWait instead of ShellExecute?


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
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..

Share this post


Link to post
Share on other sites

Quite apart from the time out requirement I have tried with 'ShellExecuteWait' which does not resolve the issue.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0