Jump to content

krpandrei

Members
  • Posts

    5
  • Joined

  • Last visited

krpandrei's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. I made this script to search for all open/visible windows with title which contains string ATHENA and put them into an array and after that arrange those windows side by side. My problem is that I also whant at the end to delete the arrays completely.I have searched the forum , tried examples but I didn't managed to empty/delete the arrays. #include <Array.au3> Global $GUIVersion = "0.0" Global $GUITitle = "Athena Windows Rearrange v" & $GUIVersion Global $HandlesArray[1] Global $TitlesArray[1] $W=@DesktopWidth/2 $H=@DesktopHeight-25 Local $Paused HotKeySet("{PAUSE}", "_TogglePause") HotKeySet("{ESC}", "_Terminate") #Region ### START Koda GUI section ### Form=g:\script\positons final\gui.kxf ;~ $GUI = GUICreate($GUITitle, 400, 400, -1, -1) ;~ GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _CreateArrays() $rows = UBound($TitlesArray)-1 If $rows = 0 Then $msgtext = "Could not find any open ATHENA projects" & @CRLF & "Please open some for me !" MsgBox ( 0, "Error", $msgtext) ElseIf $rows = 1 Then MsgBox(0, "Error", "I found just one ATHENA window" & @CRLF & "Nothing to do !") Else _RearangeWindows() ;_Delete ($TitlesArray) ;_Delete ($HandlesArray) EndIf Func _CreateArrays() $var = WinList() For $i = 1 to $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then $nOffset = 1 ;Option 1, using offset $asResult=StringRegExp($var[$i][0], "ATHENA", 1, $nOffset) ; Search windows titles that contains "ATHENA" sting If @error = 0 Then _ArrayAdd($HandlesArray, $var[$i][1]) ; array with only "Athena" -handels- _ArrayAdd($TitlesArray, $var[$i][0]) ; array with only "Athena" -title names- ;Else ;ExitLoop EndIf EndIf Next ;~ _ArrayDisplay($HandlesArray, "Array: ATHENA handles") ;~ _ArrayDisplay($TitlesArray, "Array: ATHENA titles") EndFunc ;==> Create arrays for existing Athena windows Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc ;==> Checkes window state is visible Func _RearangeWindows() $WindowsNumber = UBound($TitlesArray)-1 ;total windows number in Titels Array For $i=1 to $WindowsNumber If Mod($i, 2) <> 0 Then ;check if a number is even or not WinMove ($HandlesArray[$i], "",0 ,0 , $W, $H) Else WinMove ($HandlesArray[$i], "", @DesktopWidth/2, 0, $W, $H) EndIf Next EndFunc ;==> Arange windows side by side Func _TogglePause () $Paused = NOT $Paused While $Paused sleep(100) ToolTip($GUITitle & ' is "Paused"',@DesktopHeight/2,@DesktopWidth/2, "", 0, 2) WEnd ToolTip("") EndFunc ;==> TogglePause Func _Terminate () MsgBox(0, $GUITitle, "Exit!") Exit 0 EndFunc ;==> Terminate This is what I tried _Delete ($TitlesArray) _Delete ($HandlesArray) Func _Delete ($aArray) For $i = 1 To Ubound($aArray)-1 _ArrayDelete($aArray, 0) ; Always the first element until $aArray = "" or nothing. Next ;_ArrayDisplay($aArray, "Array after delete") EndFunc
  2. Thank you for the your answer , the problem is that I try to make a loop that only when I click in the first window the click will be send also to the second window and vice versa
  3. ; Script function: DOUBLE CLICKS ; Version: 0.0 alpha ; Features: ; Esc to terminate script, Pause/Break to "pause" Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client ; Change into the WinTitleMatchMode that supports classnames and handles AutoItSetOption("WinTitleMatchMode", 4) ; Press Esc to terminate script, Pause/Break to "pause" Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") ; Prompt the user to run the script - use a Yes/No prompt $answer = MsgBox(4, "AutoIt Script", "Run?") ; Check the user's answer to the prompt ; If "No" was clicked (7) then exit the script If $answer = 7 Then Terminate() EndIf ;HANDLE WINDOWS $DesktopWidth=1280 $DesktopHeight=1024-25 ;Minimizes all windows WinMinimizeAll() ; Get the handle of a notepad window 1 and resize & move to left Run("notepad.exe") WinWaitActive("[TITLE:Untitled - Notepad; CLASS:Notepad; ACTIVE; INSTANCE:1]", "") $handle1 = WinGetHandle("[TITLE:Untitled - Notepad; CLASS:Notepad; ACTIVE; INSTANCE:1]", "") If @error Then MsgBox(4096, "Error", "Could not find the correct window") Else WinMove($handle1, "", 0, 0, $DesktopWidth/2, $DesktopHeight) EndIf ; Get the handle of a notepad window 2 and resize & move to right Run("notepad.exe") WinWaitActive("[TITLE:Untitled - Notepad; CLASS:Notepad; ACTIVE; INSTANCE:1]", "") $handle2 = WinGetHandle("[TITLE:Untitled - Notepad; CLASS:Notepad; ACTIVE; INSTANCE:2]", "") If @error Then MsgBox(4096, "Error", "Could not find the correct window") Else WinMove($handle2, "", $DesktopWidth/2, 0, $DesktopWidth/2, $DesktopHeight) EndIf Mouse() Func Mouse() $x = MouseGetPos(0) $y = MouseGetPos(1) ;~ ;decide in what window the click was made ;~ If wuindow 1 ;~ ;select window 2 ;~ ;execute function clicksendL2R ;~ Else ;~ If wuindow 2 ;~ ;select window 1 ;~ ;execute function clicksendR2L While 1 ;infinite loop If WinActive($handle1) Or MouseDown("primary")=1 Then ;If $x < $DesktopWidth/2 Then WinActivate($handle2, "") ;MouseClick ( "primary", $x, $y) Sleep(500) ElseIf WinActive($handle2) Or MouseDown("primary")=1 Then WinActivate($handle1, "") ;MouseClick ( "primary", $x, $y) Sleep(500) EndIf WEnd EndFunc ;==>Mouse Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() MsgBox(0, "Stop", "OK. Bye!") Exit 0 EndFunc ;==>Terminate I used Notepad windows just for example until the whole script will work This is what I done so far but I have some problems with my noobe code: How can I distinguish better between two Notepad windows using &handle or something else because my Mouse function gets stuck on selection between windows ?
  4. no way ... because i'm just a maps tester training to make my work yease proof
  5. Hello @all I'm wondering that this event can be done in AutoIt: To clone the mouse movements from an app./tool window let's say instance_1 with content_1 to the same app. but this time window instance_2 with content_2. Just for the porpoise to compare two verions of one map (in my case) in the same time side by side using same app./tool THX!
×
×
  • Create New...