vladedoty Posted October 1, 2009 Share Posted October 1, 2009 sometimes my window move and sometimes they don't. was wondering if there was a more concrete way for an array of windows to move to their destination i've tried winmove which works sometimes, and _WinAPI_SetWindowPos which i'm not sure if i'm using correctly here is my code expandcollapse popup#include <array.au3> #include <WinAPI.au3> Func StartProcess($titleN) Opt("WinWaitDelay", 100) Opt("WinTitleMatchMode", 2) Opt("WinDetectHiddenText", 1) Opt("MouseCoordMode", 0) Global $titWin Global $handleWin If $Num == "1" Then $positionx[0] = ControlGetText($mainGUI, "", $x1Txt) $positiony[0] = ControlGetText($mainGUI, "", $y1Txt) ElseIf $botNum == "2" Then $positionx[0] = ControlGetText($mainGUI, "", $x1Txt) $positiony[0] = ControlGetText($mainGUI, "", $y1Txt) $positionx[1] = ControlGetText($mainGUI, "", $x2Txt) $positiony[1] = ControlGetText($mainGUI, "", $y2Txt) ElseIf $botNum == "3" Then $positionx[0] = ControlGetText($mainGUI, "", $x1Txt) $positiony[0] = ControlGetText($mainGUI, "", $y1Txt) $positionx[1] = ControlGetText($mainGUI, "", $x2Txt) $positiony[1] = ControlGetText($mainGUI, "", $y2Txt) $positionx[2] = ControlGetText($mainGUI, "", $x3Txt) $positiony[2] = ControlGetText($mainGUI, "", $y3Txt) ElseIf $botNum == "4" Then $positionx[0] = ControlGetText($mainGUI, "", $x1Txt) $positiony[0] = ControlGetText($mainGUI, "", $y1Txt) $positionx[1] = ControlGetText($mainGUI, "", $x2Txt) $positiony[1] = ControlGetText($mainGUI, "", $y2Txt) $positionx[2] = ControlGetText($mainGUI, "", $x3Txt) $positiony[2] = ControlGetText($mainGUI, "", $y3Txt) $positionx[3] = ControlGetText($mainGUI, "", $x4Txt) $positiony[3] = ControlGetText($mainGUI, "", $y4Txt) ElseIf $botNum == "5" Then $positionx[0] = ControlGetText($mainGUI, "", $x1Txt) $positiony[0] = ControlGetText($mainGUI, "", $y1Txt) $positionx[1] = ControlGetText($mainGUI, "", $x2Txt) $positiony[1] = ControlGetText($mainGUI, "", $y2Txt) $positionx[2] = ControlGetText($mainGUI, "", $x3Txt) $positiony[2] = ControlGetText($mainGUI, "", $y3Txt) $positionx[3] = ControlGetText($mainGUI, "", $x4Txt) $positiony[3] = ControlGetText($mainGUI, "", $y4Txt) $positionx[4] = ControlGetText($mainGUI, "", $x5Txt) $positiony[4] = ControlGetText($mainGUI, "", $y5Txt) Else $positionx[0] = ControlGetText($mainGUI, "", $x1Txt) $positionx[1] = ControlGetText($mainGUI, "", $x2Txt) $positionx[2] = ControlGetText($mainGUI, "", $x3Txt) $positionx[3] = ControlGetText($mainGUI, "", $x4Txt) $positionx[4] = ControlGetText($mainGUI, "", $x5Txt) $positionx[5] = ControlGetText($mainGUI, "", $x6Txt) $positiony[0] = ControlGetText($mainGUI, "", $y1Txt) $positiony[1] = ControlGetText($mainGUI, "", $y2Txt) $positiony[2] = ControlGetText($mainGUI, "", $y3Txt) $positiony[3] = ControlGetText($mainGUI, "", $y4Txt) $positiony[4] = ControlGetText($mainGUI, "", $y5Txt) $positiony[5] = ControlGetText($mainGUI, "", $y6Txt) EndIf For $a = 0 To ($Num - 1) Do Sleep(100) Until WinExists($titleN[$a], "") If WinExists($titleN[$a], "") Then WinWait($titleN[$a], "") If Not WinActive($titleN[$a], "") Then WinActivate("$", "") WinWaitActive($titleN[$a], "") ;$titWin[0] = WinGetTitle("$", "") $titWin = WinGetTitle($titleN[$a], "") $handleWin = WinGetHandle($titleN[$a], "") _WinAPI_SetWindowPos($handleWin, $HWND_BOTTOM, $positionx[$a], $positiony[$a], 802, 574, $SWP_NOZORDER) ;WinMove($titWin, "", $positionx[$a], $positiony[$a]) endif next endfunc() Link to comment Share on other sites More sharing options...
vladedoty Posted October 2, 2009 Author Share Posted October 2, 2009 sometimes my window move and sometimes they don't. was wondering if there was a more concrete way for an array of windows to move to their destination i've tried winmove which works sometimes, and _WinAPI_SetWindowPos which i'm not sure if i'm using correctly here is my code expandcollapse popup#include <array.au3> #include <WinAPI.au3> Func StartProcess($titleN) Opt("WinWaitDelay", 100) Opt("WinTitleMatchMode", 2) Opt("WinDetectHiddenText", 1) Opt("MouseCoordMode", 0) Global $titWin Global $handleWin If $Num == "1" Then $positionx[0] = ControlGetText($mainGUI, "", $x1Txt) $positiony[0] = ControlGetText($mainGUI, "", $y1Txt) ElseIf $botNum == "2" Then $positionx[0] = ControlGetText($mainGUI, "", $x1Txt) $positiony[0] = ControlGetText($mainGUI, "", $y1Txt) $positionx[1] = ControlGetText($mainGUI, "", $x2Txt) $positiony[1] = ControlGetText($mainGUI, "", $y2Txt) ElseIf $botNum == "3" Then $positionx[0] = ControlGetText($mainGUI, "", $x1Txt) $positiony[0] = ControlGetText($mainGUI, "", $y1Txt) $positionx[1] = ControlGetText($mainGUI, "", $x2Txt) $positiony[1] = ControlGetText($mainGUI, "", $y2Txt) $positionx[2] = ControlGetText($mainGUI, "", $x3Txt) $positiony[2] = ControlGetText($mainGUI, "", $y3Txt) ElseIf $botNum == "4" Then $positionx[0] = ControlGetText($mainGUI, "", $x1Txt) $positiony[0] = ControlGetText($mainGUI, "", $y1Txt) $positionx[1] = ControlGetText($mainGUI, "", $x2Txt) $positiony[1] = ControlGetText($mainGUI, "", $y2Txt) $positionx[2] = ControlGetText($mainGUI, "", $x3Txt) $positiony[2] = ControlGetText($mainGUI, "", $y3Txt) $positionx[3] = ControlGetText($mainGUI, "", $x4Txt) $positiony[3] = ControlGetText($mainGUI, "", $y4Txt) ElseIf $botNum == "5" Then $positionx[0] = ControlGetText($mainGUI, "", $x1Txt) $positiony[0] = ControlGetText($mainGUI, "", $y1Txt) $positionx[1] = ControlGetText($mainGUI, "", $x2Txt) $positiony[1] = ControlGetText($mainGUI, "", $y2Txt) $positionx[2] = ControlGetText($mainGUI, "", $x3Txt) $positiony[2] = ControlGetText($mainGUI, "", $y3Txt) $positionx[3] = ControlGetText($mainGUI, "", $x4Txt) $positiony[3] = ControlGetText($mainGUI, "", $y4Txt) $positionx[4] = ControlGetText($mainGUI, "", $x5Txt) $positiony[4] = ControlGetText($mainGUI, "", $y5Txt) Else $positionx[0] = ControlGetText($mainGUI, "", $x1Txt) $positionx[1] = ControlGetText($mainGUI, "", $x2Txt) $positionx[2] = ControlGetText($mainGUI, "", $x3Txt) $positionx[3] = ControlGetText($mainGUI, "", $x4Txt) $positionx[4] = ControlGetText($mainGUI, "", $x5Txt) $positionx[5] = ControlGetText($mainGUI, "", $x6Txt) $positiony[0] = ControlGetText($mainGUI, "", $y1Txt) $positiony[1] = ControlGetText($mainGUI, "", $y2Txt) $positiony[2] = ControlGetText($mainGUI, "", $y3Txt) $positiony[3] = ControlGetText($mainGUI, "", $y4Txt) $positiony[4] = ControlGetText($mainGUI, "", $y5Txt) $positiony[5] = ControlGetText($mainGUI, "", $y6Txt) EndIf For $a = 0 To ($Num - 1) Do Sleep(100) Until WinExists($titleN[$a], "") If WinExists($titleN[$a], "") Then WinWait($titleN[$a], "") If Not WinActive($titleN[$a], "") Then WinActivate("$", "") WinWaitActive($titleN[$a], "") ;$titWin[0] = WinGetTitle("$", "") $titWin = WinGetTitle($titleN[$a], "") $handleWin = WinGetHandle($titleN[$a], "") _WinAPI_SetWindowPos($handleWin, $HWND_BOTTOM, $positionx[$a], $positiony[$a], 802, 574, $SWP_NOZORDER) ;WinMove($titWin, "", $positionx[$a], $positiony[$a]) endif next endfunc() Now the WinMove doesn;t work properly I'm lost Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 2, 2009 Share Posted October 2, 2009 Provide a short demo that can actually be run. You seem to expect others to code a complete test script to try using your functions, undefined global variables and all... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Vlasssov Posted October 6, 2009 Share Posted October 6, 2009 (edited) Provide a short demo that can actually be run. You seem to expect others to code a complete test script to try using your functions, undefined global variables and all... I have a similar problem. At work in a constraction "for..next" moving of a window sometimes they don't.. It can depends on the program where the script is carried out? Edited October 6, 2009 by Vlasssov Link to comment Share on other sites More sharing options...
Vlasssov Posted October 6, 2009 Share Posted October 6, 2009 ; Run Notepad Run("notepad.exe") ; Wait for the Notepad become active - it is titled "Untitled - Notepad" on English systems WinWaitActive("Untitled - Notepad") winmove("Untitled - Notepad","",0,0) $n=10 for $i=1 to $n send("Text"&$i) ;save MouseClick("left",15,34,1,0) for $j=1 to 4 Send("{down}") Next Send("{Enter}") WinWaitActive("Open") winmove("Open","",0,0) Send("c:\proekt\a\file"&$i&".txt") Send("{Enter}") Next Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 6, 2009 Share Posted October 6, 2009 (edited) ; Run Notepad Run("notepad.exe") ; Wait for the Notepad become active - it is titled "Untitled - Notepad" on English systems WinWaitActive("Untitled - Notepad") winmove("Untitled - Notepad","",0,0) $n=10 for $i=1 to $n send("Text"&$i) ;save MouseClick("left",15,34,1,0) for $j=1 to 4 Send("{down}") Next Send("{Enter}") WinWaitActive("Open") winmove("Open","",0,0) Send("c:\proekt\a\file"&$i&".txt") Send("{Enter}") Next You might find something like this more reliable: Run("notepad.exe") WinWait("Untitled - Notepad") $hNotepad = WinGetHandle("Untitled - Notepad") WinMove($hNotepad, "", 0, 0) For $i = 1 To 10 ControlSend($hNotepad, "", "Edit1", "Text" & $i & @CRLF) ControlSend($hNotepad, "", "", "!fa") ; Alt-f, a = Save As WinWait("Save As") $hSaveAs = WinGetHandle("Save As") WinMove($hSaveAs, "", 0, 0) ControlSend($hSaveAs, "", "Edit1", @ScriptDir & "\file" & $i & ".txt") ControlSend($hSaveAs, "", "", "!s") ; Alt-s = Save WinWaitClose($hSaveAs) Next Note the use of window handles, hotkeys, and ControlSend(). For example, once you save the file, the window title changes and won't match anymore, but the handle still works. P.S. Of course, if writing text to the files is the object, you don't need Notepad at all: For $i = 1 To 10 FileWriteLine(@ScriptDir & "\file" & $i & ".txt", "Text" & $i) Next Edited October 6, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Vlasssov Posted October 6, 2009 Share Posted October 6, 2009 I also thinking what to use controls more favourable, but my code - an example, for the decision of a problem in other program. How I can learn names of elements of the form there? Do you want I shall result the text of the real program? Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 6, 2009 Share Posted October 6, 2009 I also thinking what to use controls more favourable, but my code - an example, for the decision of a problem in other program. How I can learn names of elements of the form there?If you installed the full version of AutoIt, there should have been an AutoIt Window Info Tool, AU3Info.exe. That will give you the control ID information.Do you want I shall result the text of the real program? Don't dismiss the idea too quickly. If there is an application to do whatever it is, then there may not be any good way to directly produce the results. But many things can be done straight from AutoIt and might be more reliable than hacking the GUI\Menu of the application. Depends on the application. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Vlasssov Posted October 6, 2009 Share Posted October 6, 2009 Thanks for the information! Big thanks for the information! I shall take advantage AU3Info.exe, but I still the beginner in Autoit, therefore for me to use GUI \Menu of the application easier. In difference from "notepad" this program uses non-standard controls. 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