anixon Posted March 1, 2010 Share Posted March 1, 2010 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.. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted March 1, 2010 Share Posted March 1, 2010 Use Default instead of -1 - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
anixon Posted March 1, 2010 Author Share Posted March 1, 2010 Use Default instead of -1Tried that and it does not work either it only works if the document is already open and not called using 'Shellexecute' Ant.. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted March 1, 2010 Share Posted March 1, 2010 Try ShellExecuteWait instead of ShellExecute? - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
anixon Posted March 1, 2010 Author Share Posted March 1, 2010 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 More sharing options...
anixon Posted March 1, 2010 Author Share Posted March 1, 2010 Quite apart from the time out requirement I have tried with 'ShellExecuteWait' which does not resolve the issue. Link to comment Share on other sites More sharing options...
JohnOne Posted March 1, 2010 Share Posted March 1, 2010 (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 March 1, 2010 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 More sharing options...
anixon Posted March 1, 2010 Author Share Posted March 1, 2010 (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 March 1, 2010 by anixon Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 1, 2010 Moderators Share Posted March 1, 2010 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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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