Jump to content

Search the Community

Showing results for tags 'recursive return'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I recently got a second monitor for my computer and wrote this program to move windows to one side or the other if they are split across two screens. It uses a recursive function to move the window either to the right or the left. The problem is when a window exists that apparently has no title, text, class, process, or state, but still manages to get past line 27 AND past lines 201 and 122, where the function should return if there is any error. When I run this script, I get this output: This error pops up when you drag a file between windows; GameRanger also randomly causes it to crash. My question is this: why is the function not returning on line 201 or line 122? Source: Global $iDiff, $iCenter = @DesktopWidth / 2, $bSwitchView = False, $bIconSwitch = False Global $bContinue = False Opt("GUIOnEventMode", 1) Opt("WinDetectHiddenText", 1) TraySetPauseIcon(@WindowsDir & '\explorer.exe', -10) If Not @Compiled Then HotKeySet('{esc}', '_exit') AutoItSetOption('TrayIconDebug', 1) EndIf AdlibRegister('_SwitchIcon', 1000) TraySetIcon(@WindowsDir & '\explorer.exe', -12) While True $aList = WinList() If @error Or Not IsArray($aList) Then ConsoleWrite('Error: could not complete WinList()' & @crlf) ConsoleWrite('Press {esc} to continue...' & @crlf) HotKeySet('{esc}', '_continue') Do Sleep(1000) Until $bContinue $bContinue = False ContinueLoop EndIf For $i = 1 To $aList[0][0] If $aList[$i][0] = "Program Manager" Then ContinueLoop If $aList[$i][0] <> "" And _IsVisible($aList[$i][1]) And Not _IsMaximized($aList[$i][1]) Then $iCoords = WinGetPos($aList[$i][1]) If $iCoords[0] + $iCoords[2] > $iCenter And $iCoords[0] < $iCenter Then $iDiff = @DesktopWidth - ($iCoords[0] + $iCoords[2]) If $iDiff < $iCoords[0] Then _MoveWindowLeft($aList[$i][1]) Else _MoveWindowRight($aList[$i][1]) EndIf EndIf ElseIf $aList[$i][0] <> "" And _IsMaximized($aList[$i][1]) And _IsVisible($aList[$i][1]) Then $bSwitchView = Not $bSwitchView If $bSwitchView Then WinSetState($aList[$i][1], '', @SW_RESTORE) WinMove($aList[$i][1], '', 0, 10, $iCenter, @DesktopHeight - 50) Else WinSetState($aList[$i][1], '', @SW_RESTORE) WinMove($aList[$i][1], '', $iCenter + 5, 10, $iCenter, @DesktopHeight - 50) EndIf EndIf Next Sleep(5) WEnd Func _continue() HotKeySet('{esc}') $bContinue = True Return $bContinue EndFunc ;==>_continue Func _exit() Exit 1 EndFunc ;==>_exit Func _MoveWindowLeft($hWnd) Local $iCoords, $sClassList, $sWindowTitle, $iPID, $iState, $sText, $sMsg, $sRet $iCoords = WinGetPos($hWnd) If @error Or Not IsArray($iCoords) Then ConsoleWrite('Error: could not complete WinGetPos(' & $hWnd & ')' & @crlf) ConsoleWrite('Extended information: $hWnd = ' & $hWnd & @crlf) $sWindowTitle = WinGetTitle($hWnd) If $sWindowTitle <> 0 Then ConsoleWrite('WinGetTitle(' & $hWnd & ') = ' & $sWindowTitle & @crlf) Else ConsoleWrite('Could not complete WinGetTitle' & @crlf) EndIf $sClassList = WinGetClassList($hWnd) If Not @error Then ConsoleWrite('WinGetClassList(' & $hWnd & ') = ' & $sClassList & @crlf) Else ConsoleWrite('Could not complete WinGetClassList' & @crlf) EndIf $iPID = WinGetProcess($hWnd) If $iPID <> -1 Then ConsoleWrite('WinGetProcess(' & $hWnd & ') = ' & $iPID & @crlf) Else ConsoleWrite('Could not complete WinGetProcess' & @crlf) EndIf $iState = WinGetState($hWnd) If Not @error Then $sMsg = 'States of window ' & $hWnd & ':' Switch True Case BitAND($iState, 1) $sMsg &= 'window exists, ' ContinueCase Case BitAND($iState, 2) $sMsg &= 'window is visible, ' ContinueCase Case BitAND($iState, 4) $sMsg &= 'window is enabled, ' ContinueCase Case BitAND($iState, 8) $sMsg &= 'window is active, ' ContinueCase Case BitAND($iState, 16) $sMsg &= 'window is minimized, ' Case BitAND($iState, 32) $sMsg &= 'window is maximized, ' EndSwitch If not ($sMsg = 'States of window ' & $hWnd & ':') Then $sMsg = StringTrimRight($sMsg, 2) EndIf ConsoleWrite($sMsg & @crlf) Else ConsoleWrite('Could not complete WinGetState' & @crlf) EndIf $sText = WinGetText($hWnd) If $sText <> 0 Then ConsoleWrite('WinGetText(' & $hWnd & ') = ' & $sText & @crlf) Else ConsoleWrite('Could not complete WinGetText' & @crlf) EndIf ConsoleWrite('Press {esc} to continue...' & @crlf) HotKeySet('{esc}', '_continue') Do Sleep(1000) Until $bContinue $bContinue = False Run(@ScriptFullPath) Return False ;<<<<<<<<<<<<<<<<<<<<<<<<<SHOULD RETURN HERE>>>>>>>>>>>>>>>>>>>>>>>>> Else WinMove($hWnd, '', $iCoords[0] - 25, $iCoords[1]) If $iCoords[0] + $iCoords[2] > $iCenter And $iCoords[0] < $iCenter Then Sleep(5) _MoveWindowLeft($hWnd) EndIf $iCoords = WinGetPos($hWnd) If $iCoords[0] < 0 Then WinMove($hWnd, '', 5, $iCoords[1], $iCenter - 10) EndIf EndIf Return True EndFunc ;==>_MoveWindowLeft Func _MoveWindowRight($hWnd) Local $sClassList, $sWindowTitle, $iPID, $iState, $sText, $sMsg, $sRet $iCoords = WinGetPos($hWnd) If @error Or Not IsArray($iCoords) Then ConsoleWrite('Error: could not complete WinGetPos(' & $hWnd & ')' & @crlf) ConsoleWrite('Extended information: $hWnd = ' & $hWnd & @crlf) $sWindowTitle = WinGetTitle($hWnd) If $sWindowTitle <> 0 Then ConsoleWrite('WinGetTitle(' & $hWnd & ') = ' & $sWindowTitle & @crlf) Else ConsoleWrite('Could not complete WinGetTitle' & @crlf) EndIf $sClassList = WinGetClassList($hWnd) If Not @error Then ConsoleWrite('WinGetClassList(' & $hWnd & ') = ' & $sClassList & @crlf) Else ConsoleWrite('Could not complete WinGetClassList' & @crlf) EndIf $iPID = WinGetProcess($hWnd) If $iPID <> -1 Then ConsoleWrite('WinGetProcess(' & $hWnd & ') = ' & $iPID & @crlf) Else ConsoleWrite('Could not complete WinGetProcess' & @crlf) EndIf $iState = WinGetState($hWnd) If Not @error Then $sMsg = 'States of window ' & $hWnd & ':' Switch True Case BitAND($iState, 1) $sMsg &= 'window exists, ' ContinueCase Case BitAND($iState, 2) $sMsg &= 'window is visible, ' ContinueCase Case BitAND($iState, 4) $sMsg &= 'window is enabled, ' ContinueCase Case BitAND($iState, 8) $sMsg &= 'window is active, ' ContinueCase Case BitAND($iState, 16) $sMsg &= 'window is minimized, ' Case BitAND($iState, 32) $sMsg &= 'window is maximized, ' EndSwitch If not ($sMsg = 'States of window ' & $hWnd & ':') Then $sMsg = StringTrimRight($sMsg, 2) EndIf ConsoleWrite($sMsg & @crlf) Else ConsoleWrite('Could not complete WinGetState' & @crlf) EndIf $sText = WinGetText($hWnd) If $sText <> 0 Then ConsoleWrite('WinGetText(' & $hWnd & ') = ' & $sText & @crlf) Else ConsoleWrite('Could not complete WinGetText' & @crlf) EndIf ConsoleWrite('Press {esc} to continue...' & @crlf) HotKeySet('{esc}', '_continue') Do Sleep(1000) Until $bContinue $bContinue = False Run(@ScriptFullPath) Return False ;<<<<<<<<<<<<<<<<<<<<<<<<<SHOULD RETURN HERE>>>>>>>>>>>>>>>>>>>>>>>>> Else WinMove($hWnd, '', $iCoords[0] + 25, $iCoords[1]) If $iCoords[0] + $iCoords[2] > $iCenter And $iCoords[0] < $iCenter Then Sleep(5) _MoveWindowRight($hWnd) EndIf $iCoords = WinGetPos($hWnd) If ($iCoords[0] + $iCoords[2]) > @DesktopWidth Then WinMove($hWnd, '', $iCenter + 5, $iCoords[1], $iCenter - 10) EndIf EndIf Return True EndFunc ;==>_MoveWindowRight Func _IsMaximized($handle) If BitAND(WinGetState($handle), 32) Then Return 1 Else Return 0 EndIf EndFunc ;==>_IsMaximized Func _IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>_IsVisible Func _SwitchIcon() $bIconSwitch = Not $bIconSwitch If $bIconSwitch Then TraySetIcon(@WindowsDir & '\explorer.exe', -12) Else TraySetIcon(@WindowsDir & '\explorer.exe', -13) EndIf EndFunc ;==>_SwitchIcon
×
×
  • Create New...