anixon Posted March 4, 2010 Posted March 4, 2010 I have deployed Notepad as editor called by my script to either display, edit and or print a document. Notepad always opens using the default setting. The default setting is always the Width Height X and Y co-ordinates of the Notepad window the last time that it was displayed and then closed. I am using the 'WinMove' to resize the window based on the diamentions of the document. There are many documents all of differences which I would like to open at the correct size window. What I am trying to achieve is a smooth visual transaction to the document size after opening 'Notepad.exe' At the moment when you open 'Notepad' you get the Notebook window flashed for the last document size then opened at the new size. What I am trying to eliminate is the 'Flashed Window on Opening' In Excel for example in a macro you can freeze window updating perform the process and then allow window updating which has the effect of hiding the process which the Excel macro is performing. Is this type of functionality available in the AutoIT environment? or alternatively can you open Notepad with its location beyond the width and height of the Desktop perofrm an SW_Hide then a 'WinMove' that includes Width Height X and Y Location and then a SW_SHOW.Func _AutoNotepadExe($nPFile, $nPDir, $nPCorT, $nPWidth, $nPHeight, $nPTimer) ;//Cleanup to make sure Notepad not running If ProcessExists("Notepad.exe") Then $list = ProcessList("Notepad.exe") $s = $list[0][0] For $i = 1 To $list[0][0] ProcessClose($list[$i][1]) Next EndIf ;//Open Notepad and Document ShellExecute($nPFile, "", $nPDir, "Edit") ;//Wait until Notepad becomes active WinWaitActive("[CLASS:Notepad]", "") ;//Resize the Window to Display the Document Text [Centre 1 Top 0) If $nPCorT = 1 Then WinMove("[CLASS:Notepad]", "", (@DesktopWidth / 2) - $nPWidth / 2, (@DesktopHeight / 2) - $nPHeight / 2, $nPWidth, $nPHeight, 1) Else WinMove("[CLASS:Notepad]", "", (@DesktopWidth / 2) - $nPWidth / 2, 0, $nPWidth, $nPHeight, 1) EndIf $MenuStartCycle = TimerInit() While 1 If Not ProcessExists("Notepad.exe") Then ExitLoop ;//Exit after nn Minutes $MenuEndCycle = TimerDiff($MenuStartCycle) If $MenuEndCycle >= $nPTimer * 1000 Then Exitloop Wend EndFunc ;==>_AutoNotepadExeHelp is always appreciated Ant..
Yoriz Posted March 5, 2010 Posted March 5, 2010 How about jumping the gun and setting the default size's of notepad before its even open. _PresizeNotePad(0,0,200,150) run("NotePad") WinWait("Untitled - Notepad") WinSetTitle("Untitled - Notepad","","First - NotePad") _PresizeNotePad(201,151,300,500) run("NotePad") WinWait("Untitled - Notepad") WinSetTitle("Untitled - Notepad","","Second - NotePad") Func _PresizeNotePad($iLeft,$iTop,$iWidth,$iHeight) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Notepad", "iWindowPosX", "REG_DWORD", $iLeft) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Notepad", "iWindowPosY", "REG_DWORD", $iTop) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Notepad", "iWindowPosDX", "REG_DWORD", $iWidth) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Notepad", "iWindowPosDY", "REG_DWORD", $iHeight) EndFunc GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
anixon Posted March 5, 2010 Author Posted March 5, 2010 (edited) How about jumping the gun and setting the default size's of notepad before its even open. _PresizeNotePad(0,0,200,150) run("NotePad") WinWait("Untitled - Notepad") WinSetTitle("Untitled - Notepad","","First - NotePad") _PresizeNotePad(201,151,300,500) run("NotePad") WinWait("Untitled - Notepad") WinSetTitle("Untitled - Notepad","","Second - NotePad") Func _PresizeNotePad($iLeft,$iTop,$iWidth,$iHeight) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Notepad", "iWindowPosX", "REG_DWORD", $iLeft) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Notepad", "iWindowPosY", "REG_DWORD", $iTop) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Notepad", "iWindowPosDX", "REG_DWORD", $iWidth) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Notepad", "iWindowPosDY", "REG_DWORD", $iHeight) EndFunc Thank you what an excellent Idea and very elegant indeed. I am never ceased to be amazed by the level of knowledge possessed by AutoIT Contributors and the speed of the responses. Thank you very much for your contribution it is very much appreciated. Thanks again.. Edited March 5, 2010 by anixon
anixon Posted March 5, 2010 Author Posted March 5, 2010 Thank you what an excellent Idea and very elegant indeed. I am never ceased to be amazed by the level of knowledge possessed by AutoIT Contributors and the speed of the responses. Thank you very much for your contribution it is very much appreciated. Thanks again.. And this is the final version _AutoNotepadExe($sESHelp, $sLogDirHelp,(@DeskTopWidth/2)-(750/2), 20, 750, @DesktopHeight - 50, 60) Func _AutoNotepadExe($nPFile, $nPDir, $iLeft,$iTop,$iWidth,$iHeight,$nPTimer) ;//Close all running instances of Notepad If ProcessExists($sNotePadExe) Then $list = ProcessList($sNotePadExe) $s = $list[0][0] For $i = 1 To $list[0][0] ProcessClose($list[$i][1]) Next EndIf ;//Re-set Notepad X Y Width and Height settings in Registry [Document Size] RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Notepad", "iWindowPosX", "REG_DWORD", $iLeft) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Notepad", "iWindowPosY", "REG_DWORD", $iTop) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Notepad", "iWindowPosDX", "REG_DWORD", $iWidth) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Notepad", "iWindowPosDY", "REG_DWORD", $iHeight) ;//Open the Document with the Notepad Text Editor ShellExecute($nPFile, "", $nPDir, "Edit") ;//Set the Unattended Exit Timer $MenuStartCycle = TimerInit() While 1 ;//Process Ceases to Exist [closed by User] Exit If Not ProcessExists($sNotePadExe) Then ExitLoop ;//Calculate Timer Difference $MenuEndCycle = TimerDiff($MenuStartCycle) ;//Process and Unattended Exit [nn Minutes] If $MenuEndCycle >= $nPTimer * 1000 Then ProcessClose($sNotePadExe) ExitLoop EndIf WEnd EndFunc ;==>_AutoNotepadExe
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