mr-es335 Posted September 9, 2023 Share Posted September 9, 2023 (edited) Good day, For a considerable period of time, I was employing "nircmd" in all of my scripts. For various reasons, nircmd was not able to do the tasks that I was requiring, so I looked into "other" alternatives. This is when I discovered "AutoIt!" Thus far, things have been going very well. However, I have written a scripts that positions tow windows side-by-side. During testing, I was able to have these positioning to display very consistently. Then there are those times where the window positionings are simply not being positioned properly - and I have no idea why? I have attached a sampling of the script and am wondering what it is that I am doing wrong. Any assistance would be appreciated! shell.au3 Edited September 9, 2023 by mr-es335 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
ioa747 Posted September 9, 2023 Share Posted September 9, 2023 (edited) shell.au3 ; ----------------------------------------------- #include <AutoItConstants.au3> #include <Constants.au3> #include <FileConstants.au3> ; ----------------------------------------------- WinClose("[folder_path_1]", "") WinClose("[name_1].txt - metapad", "") ; ----------------------------------------------- ShellExecute("[folder_path_2]") Sleep(150) WinMove ("[folder_path_2]", "", 460, 100, 550, 650) Sleep(150) ; ----------------------------------------------- ShellExecute("[name_2].txt") Sleep(150) WinMove ("[name_2].txt - metapad", "", 1010, 100, 550, 650) ; ----------------------------------------------- what did you say it does that? how-to-post-code-on-the-forum Edited September 9, 2023 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
Trong Posted September 9, 2023 Share Posted September 9, 2023 Let's try this script: expandcollapse popup#NoTrayIcon Global $iTestMode = True Global $sWorkingDir = @ScriptDir Global $sNotepadFile_1 = '[name_1].txt' Global $sNotepadFile_Path_1 = $sWorkingDir & '\' & $sNotepadFile_1 Global $sNotepadFile_2 = '[name_2].txt' Global $sNotepadFile_Path_2 = $sWorkingDir & '\' & $sNotepadFile_2 Global $sNotepad_exe = FileExists(@WindowsDir & '\System32\Notepad.exe') ? @WindowsDir & '\System32\Notepad.exe' : @WindowsDir & '\Notepad.exe' If $iTestMode Then _OpenTestFile() OnAutoItExitRegister("Terminate") Global $g_bPaused = False ; Press Esc to terminate script, HotKeySet("{PAUSE}", "TogglePause") ; Press Pause/Break to "pause" HotKeySet("{ESC}", "Terminate") ; Press F5 to "Snap" HotKeySet("{F5}", "SnapNotepad") If $iTestMode Then WinWait($sNotepadFile_2, "", 2) SnapNotepad() While 1 Sleep(100) WEnd Func SnapNotepad() Local $aWin = WinList("[CLASS:Notepad]") If $aWin[0][0] > 2 Then MsgBox(48 + 262144, "Error", "Open 2 instances (C: " & $aWin[0][0] & ") of Notepad only ", 2) _OpenTestFile() EndIf Local $iW = Int(@DesktopWidth / $aWin[0][0]) Local $iH = @DesktopHeight - 40 For $i = 1 To $aWin[0][0] WinActivate($aWin[$i][1]) WinMove($aWin[$i][1], "", ($i - 1) * $iW, 0, $iW, $iH, 1) Next EndFunc ;==>SnapNotepad Func TogglePause() $g_bPaused = Not $g_bPaused While $g_bPaused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() If $iTestMode Then _Close_Notepad_NoSave() FileDelete($sNotepadFile_Path_1) FileDelete($sNotepadFile_Path_2) EndIf Exit EndFunc ;==>Terminate Func _OpenTestFile() If $iTestMode Then _Close_Notepad_NoSave() If Not FileExists($sNotepadFile_Path_1) Then FileWriteLine($sNotepadFile_Path_1, "Tab 1") If Not FileExists($sNotepadFile_Path_2) Then FileWriteLine($sNotepadFile_Path_2, "Tab 2") If Not ProcessExists("notepad.exe") Or Not WinExists($sNotepadFile_1) Then ShellExecute($sNotepad_exe, $sNotepadFile_Path_1, $sWorkingDir) If Not WinExists($sNotepadFile_2) Then ShellExecute($sNotepad_exe, $sNotepadFile_Path_2, $sWorkingDir) EndFunc ;==>_OpenTestFile Func _Click_Notepad_NoSave() WinClose($sNotepadFile_1) WinClose($sNotepadFile_2) Local $aWin = WinList("[CLASS:Notepad]") If $aWin[0][0] > 0 Then For $i = 1 To $aWin[0][0] WinActivate($aWin[$i][1]) WinClose($aWin[$i][1], "") Next EndIf Local $iCount = 99 While WinExists("Notepad", "&Save") WinActivate("Notepad", "&Save") ControlClick("Notepad", "&Save", "[CLASS:Button; INSTANCE:2]") $iCount = $iCount - 1 If $iCount < 2 Then ExitLoop WEnd EndFunc ;==>_Click_Notepad_NoSave Func _Close_Notepad_NoSave() _Click_Notepad_NoSave() Local $iCount = 99 While ProcessExists("notepad.exe") ProcessClose("notepad.exe") $iCount = $iCount - 1 If $iCount < 2 Then ExitLoop WEnd EndFunc ;==>_Close_Notepad_NoSave Regards, Link to comment Share on other sites More sharing options...
mr-es335 Posted September 9, 2023 Author Share Posted September 9, 2023 Trong, WOW! That is quite the listing!! But this is more than I really require... Please see attached... * Requirements: A folder called "Me" and a text files called "Me" placed on the desktop... 1. I have a number of previously created folders/text that I need positioned in the same location 2. All that is changing is the name of the folder and the name of text 3. The positionings as noted - always remain the same My issue is that the positions of the folders and text are never consistent, and therefore, at times, appear in random locations on the display. shell_2.au3 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
ioa747 Posted September 9, 2023 Share Posted September 9, 2023 (edited) Now that I understand, I also have an example expandcollapse popup; ----------------------------------------------- ShellExecute("E:\Desktop\Me") ;~ WinMove ("E:\Desktop\Me", "", 450, 100, 550, 650) $hWinFolder = WinWait("E:\Desktop\Me") ; ----------------------------------------------- ShellExecute("E:\Desktop\Me.txt") ;~ WinMove ("E:\Desktop\Me.txt - metapad", "", 1020, 100, 550, 650) $hWinMetapad = WinWait("E:\Desktop\Me.txt - metapad") ; ----------------------------------------------- ;$hWinMetapad with 60% of @DesktopWidth _WinSideBySide($hWinMetapad, $hWinFolder, 60) ToolTip("$hWinMetapad with 60% of @DesktopWidth") Sleep(5000) ;$hWinMetapad with 40% of @DesktopWidth _WinSideBySide($hWinMetapad, $hWinFolder, 40) ToolTip(";$hWinMetapad with 40% of @DesktopWidth") Sleep(5000) ;with out parameter $iView1 = 65% _WinSideBySide($hWinMetapad, $hWinFolder) ToolTip(";with out parameter $iView1 = 65%") Sleep(5000) ;---------------------------------------------------------------------------------------- Func _WinSideBySide($hWin1, $hWin2, $iView1 = 65) ;Get DeskTop size Local $DTs = WinGetPos("[CLASS:Shell_TrayWnd]") ConsoleWrite("X=" & $DTs[0] & " Y=" & $DTs[1] & " W=" & $DTs[2] & " H=" & $DTs[3] & @CRLF) Local $iScale = (@DesktopWidth / 100) ConsoleWrite("$iScale=" & $iScale & @CRLF) WinMove($hWin1, "", @DesktopWidth - ($iScale * $iView1), 0, ($iScale * $iView1) + 7, $DTs[1] + 7) WinMove($hWin2, "", -7, 0, @DesktopWidth + 21 - ($iScale * $iView1), $DTs[1] + 7) WinActivate($hWin1) EndFunc ;==>_WinSideBySide Edited September 9, 2023 by ioa747 prettify I know that I know nothing Link to comment Share on other sites More sharing options...
Solution mr-es335 Posted September 9, 2023 Author Solution Share Posted September 9, 2023 (edited) Good day, Thanks to you both for the efforts...however, both of the examples have the folder and text maximized. In my example, the left folder is positioned at 450,100,550,650 and the text is positioned at 1050,100,550,650. [UPDATE!!] Apparently the following is now working....all that was required was to increase Sleep by 100... ; ----------------------------------------------- #include <AutoItConstants.au3> #include <Constants.au3> #include <FileConstants.au3> ; ----------------------------------------------- ShellExecute("E:\Desktop\Me") Sleep(250) WinMove ("E:\Desktop\Me", "", 450, 100, 550, 650) Sleep(250) ; ----------------------------------------------- ShellExecute("E:\Desktop\Me.txt") Sleep(250) WinMove ("E:\Desktop\Me.txt - metapad", "", 1020, 100, 550, 650) ; ----------------------------------------------- Edited September 9, 2023 by mr-es335 Addition mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
ioa747 Posted September 9, 2023 Share Posted September 9, 2023 ; ----------------------------------------------- ShellExecute("E:\Desktop\Me") $hWinFolder = WinWait("E:\Desktop\Me") WinMove ($hWinFolder, "", 450, 100, 550, 650) ; ----------------------------------------------- ShellExecute("E:\Desktop\Me.txt") $hWinMetapad = WinWait("E:\Desktop\Me.txt - metapad") WinMove ($hWinMetapad, "", 1020, 100, 550, 650) ; ----------------------------------------------- I know that I know nothing Link to comment Share on other sites More sharing options...
argumentum Posted September 9, 2023 Share Posted September 9, 2023 ..give credit where credit is due. I like that. Also like that every question you ever posted, you are the one that brought the solution. Remarkable !. One thing that would be appreciated is that the code is in the code box, the icon with the "<>" symbol, click that before pasting your code. Andreik 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Andreik Posted September 9, 2023 Share Posted September 9, 2023 He gave the final solution, don't be sad my friend. If you change a letter after someone assisted you along the process it means you are a true solver. argumentum and Xandy 2 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
mr-es335 Posted September 9, 2023 Author Share Posted September 9, 2023 ioa747, WOW! What an incredible and vast improvement over what I had done! * I now need to understand what it is that yo have accomplished!! Thank you so very, very much for this!! Solved...and now "double solved"!!! Very much appreciated! mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Nine Posted September 9, 2023 Share Posted September 9, 2023 @argumentum @Andreik Like Meat Loaf sang, " you find it, you showed him, but there is no way you gonna be recognized for it, but don't be sad cause two out of three ain't bad" Andreik and argumentum 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Andreik Posted September 9, 2023 Share Posted September 9, 2023 For me, it doesn't really matter who get the credit as long people get a solution. Xandy 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Xandy Posted September 10, 2023 Share Posted September 10, 2023 Your character alone is all the ego you need. TheDcoder, Andreik and TheSaint 3 Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) 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