Jump to content

Screen Hopping script help


shamsh
 Share

Recommended Posts

Short: I want to build a script that hops through open screens with a slight latency. Don't know what screens are open, cript would need to capture that whilst running.

Recently i implemented a script which basically keeps hopping through your open screens with a slight delay (minimised/restored/maximised - any basically open). Use? I have a few monitoring screens that i want to keep hopping through. So:

While 1; run always
    WinActivate("<Title of your first window>") 
    Sleep(3000)
; ... repeat (copy + paste) above 2 lines of code repeatedly as 
; needed for as many screens
WEnd

However I (1) decide WHAT screens i need to hop through, i.e. will be open; then (2) MANUALLY put in their titles in the script; and finally (3) compile or run.

Now however i want to build a script that doesn't need to know before hand what screens are open, i.e. it captures first what screens are open, then hops through them in sequence.

Is there a function that (1) captures, (2) stores currently open screens on your computer system tray? I came. I searched, I couldn't find... help.

Thanks! :lmao:

Shams

Link to comment
Share on other sites

Short: I want to build a script that hops through open screens with a slight latency. Don't know what screens are open, cript would need to capture that whilst running.

Recently i implemented a script which basically keeps hopping through your open screens with a slight delay (minimised/restored/maximised - any basically open). Use? I have a few monitoring screens that i want to keep hopping through. So:

While 1; run always
    WinActivate("<Title of your first window>") 
    Sleep(3000)
; ... repeat (copy + paste) above 2 lines of code repeatedly as 
; needed for as many screens
WEnd

However I (1) decide WHAT screens i need to hop through, i.e. will be open; then (2) MANUALLY put in their titles in the script; and finally (3) compile or run.

Now however i want to build a script that doesn't need to know before hand what screens are open, i.e. it captures first what screens are open, then hops through them in sequence.

Is there a function that (1) captures, (2) stores currently open screens on your computer system tray? I came. I searched, I couldn't find... help.

Thanks! :lmao:

Shams

Few things to ponder...

1. Welcome to the forums.

2. Wrong forum to post in. This should be in the v3 Support...dont create another one, a MOD will move this one.

3. WinList() (Helpfile)

That should help you get started. WinList will give you a list of all open windows. You will need to sort through that list, make a GUI where a user can decide which windows he wants to scroll through, and you will need a configuration's GUI to allow the user to select how much time per window he wants to spend, and any other options you can think to add on a per GUI basis.

I hope this helps,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

You could try this

(Straight from help with small activation modification)

While 1
$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]) And Not StringInStr(WinGetTitle($var[$i][0]), "Activating...", 1) Then
    WinActivate($var[$i][0])
    Sleep(3000)
    ToolTip("Activating... "&$var[$i][0],0,0)
  EndIf
Next
Wend


Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then
    Return 1
  Else
    Return 0
  EndIf
EndFunc
Edited by Paulie
Link to comment
Share on other sites

Here's what i did in the end (works well):

; + ------------------------------------------------------------------+
; | Script Function:                                                  |
; | -  Jumps screens constantly. Includes an interupt and         |
; |    terminate option.                                           |
; | -  Matches the title from the start - i.e. not complete, only  | 
; |    enough to differentiate.                                 |
; + ------------------------------------------------------------------+
HotKeySet("+!s", "ShowMessage") ; Shift+Alt+d pauses/interupts the 
                                ; hopping
HotKeySet("+!{ESC}", "Terminate"); Shift+Alt+Esc terminates the 
                                ; program. You would need to re run.
$var = WinList()

; While 1; run always
    For $i = 1 to $var[0][0]; $var[0][0] == # windows returned
        WinActivate($var[$i][0]) 
        Sleep(3000)
    Next
; WEnd

; interrupt function, answers Shift + Alt + s
Func ShowMessage()
    MsgBox(0,"Screen Hopping Interrupt","Press OK to continue screen hopping!")
EndFunc

;terminate function, answers Shift + Alt + Esc
Func Terminate()
    Exit 0
EndFunc

My next step would be to have the hop time as a command line argument.

Any other cool additions for this script? insights?

By the way... just so that i understand what is actually happening... what iS WinList() and WinActivate() actually doing? i mean how is it interacting with Windows in the background to caputre as it does all instances? what APIs is it playing with, etc... a little education. i.e. if i wanted to do this wihtout AutoIt could i? and how?

Shams

Link to comment
Share on other sites

WinList() takes all of the windows that are created by all of the processes running in your task manager, even the hidden ones, the disabled ones, the countless unnamed ones etc. It puts them into an array, [x][0] returns the name and [x][1] returns its handle (handles are more advanced, but better). also [0][0] is how many windows were returned (dont be suprised if its around 300...lol)

WinActive() simply gives a window input focus.

I messed around with your script a bit, i made it only use the real windows your can actually see... although you might have a few you need to add to the If/then that is pretty clear (where Program manager is).

Along with that, it waits until the window is active before activating the next one. Its a bit smooth too...

I dont really get what you mean here:

i mean how is it interacting with Windows in the background to caputre as it does all instances? what APIs is it playing with, etc... a little education. i.e. if i wanted to do this wihtout AutoIt could i?

i've heard window API's alot before and i have no idea what they are :lmao:, and what do you mean backgrounds to capture? Screenshots? Not exactly sure what this program is meant to do!

; + ------------------------------------------------------------------+
; | Script Function:                                                  |
; | -  Jumps screens constantly. Includes an interupt and         |
; |    terminate option.                                           |
; | -  Matches the title from the start - i.e. not complete, only  |
; |    enough to differentiate.                                 |
; |                                                                |
; + ------------------------------------------------------------------+
#include <array.au3>;needed for _ArrayAdd
;~ HotKeySet("+!s", "ShowMessage");dont need this really
HotKeySet("+!{ESC}", "Terminate")
$var = WinList()
Dim $RealList[1]

For $i = 1 to $var[0][0]
    $state = WinGetState($var[$i][0])
    If BitAnd($state, 2) AND $var[$i][0] <> "" AND $var[$i][0] <> " " AnD  $var[$i][0] <> "Program Manager" Then
        _ArrayAdd($RealList, $var[$i][0]) ;=; add to the end of reallist an active, standard window
    EndIf
Next
For $i = 1 to UBound($RealList) -1
;~  msgbox(0,"",'"' & $RealList[$i] & '"');=l testing purposes, worked fine
    WinActivate($RealList[$i]);activate window
    tooltip("activating: " & $reallist[$i], 0,0)
    winwaitactive($reallist[$i]);waits for the window to become active first... useful if it actives a game on a slow PC
    sleep(1000)
Next
Exit

;~ Func ShowMessage()
;~   MsgBox(0,"Screen Hopping Interrupt","Press OK to continue screen hopping!")
;~ EndFunc

Func Terminate()
    Exit 0
EndFunc
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...