Sign in to follow this  
Followers 0
HexCore

Basic Help needed - trouble sending Alt+Tab - probably doing it wrong ;]

19 posts in this topic

1st post so please take it easy on me... I'm working on some NOC TV dashboard monitors and I have been using some basic AutoIT to assist, but for some reason I cannot get the Alt+Tab may be a better way of doing it.

current setup is this.

3 virtual desktops using VirtualWin (from sourceforge) hotkey to change desktop = ctrldown + 1-3

desktop 1 has some Stats on it the script will be launched at startup from desktop 1 upon system boot that's why the code sleeps and goes to desktop 2

desktop 2 has IE running with 9 tabs that I script to change the tabs - running IE in full screen mode

desktop 3 is using Microsoft System Center Operations Manager - SCOM ( so it's the same program launched 3 times )

this is what I'm having trouble with, I can go to desktop 3 and run just the alt+tab portion of the script and it works as expected, but not when I use the full script... I run 3 instances of this application with different network dashboards...

I'm assuming I have to use WinActivate some how, but don't get how as the SCOM program all has the same title and name..ect..

Here is the code, I am open to all suggestions on this:

While 1=1
sleep(30000)
send("{ctrldown}{2}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{3}")
sleep(30000)
send("{altdown}{tab}{altup}")
sleep(30000)
send("{altdown}{tab}{altup}")
sleep(30000)
send("{altdown}{tab}{altup}")
sleep(30000)
send("{ctrldown}{1}")
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What about:

Send ("!{TAB}") ;Navigate to next WindowTab (on a Tabbed dialog window)

Send ("!+{TAB}") ;Navigate to previous WindowTab.

The SCOM problem seems a bit different of what im used to, you say its the same app started 3 times,

but the caption is the same? what about the text inside the window? if one has text that the other doesnt have you can use winactive, i think.

winwaitactive ("scomapp title", "singularanduniquewordonthethreemonitors")

;do something

Send ("!{TAB}")

winwaitactive ("scomapp title", "microsoft")

;do something

Send ("!{TAB}")

;etc

EDIT: Wasnt ^ but ! as guiness pointed out. Thanks.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

I thought "!" was Alt e.g.

Send("!{TAB}")


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

And you thought well, i messed up ^is Control, edited the previous post.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

Microsoft System Center Operations Manager is launched 3 times, the blue title bar on the program for all 3 instances state:

System Center Operations Manager 2007 R2

It is the same for all 3 instances of the program I launch, this application monitors my internal systems and displays dashboards.

as I said before what strikes me as odd is if on my local machine I throw together an AutoScripts that contains

While 1=1
send("{altdown}{tab}{altup}")
sleep(19000)
send("{altdown}{tab}{altup}")
sleep(1900)

WEnd

it works fine.... Also when I use that code on VirtualDesktop3 it works fine... it's when I try to combine all the items it fails on me and it's only the Alt+Tab function. I'm not opposed to using 1 desktop and removing the Virtual desktop side, just my lack of programming skill is preventing me from getting all the functionality using 1 screen.

I really appreciate the assistance.

Again the end goal here is I have 2 java applets being displayed / IE with tabs / SCOM dashboards

all I want to do is rotate these items on my display monitor, so my approach could be wrong and I'm welcome to suggestions.

Share this post


Link to post
Share on other sites

Trying this now

Send("!{TAB}")

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I understand that all 3 instances state:

System Center Operations Manager 2007 R2

And i sugested that you make the script search for text that is singular in each of them.

Something like:

winwaitactive ("System Center Operations Manager 2007 R2", "my aplication")
Send ("!{TAB}")
winwaitactive ("System Center Operations Manager 2007 R2", "popup window")
Send ("!{TAB}")
winwaitactive ("System Center Operations Manager 2007 R2", "something")
Send ("!{TAB}")
Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

Ok so I have been messing with this... figured it may be something with the way AutoIT is interacting with VirtualWin (my virtual desktop program)

I moved the SCOM dashboards to dekstop1 and using the following code it appears to be working, still tweaking

While 1=1
sleep(300)
WinActivate("System Center Operations Manager")
sleep(30000)
send("!{tab}")
sleep(30000)
send("!{tab 2}")
sleep(30000)
send("!{tab 3}")
sleep(30000)
send("{ctrldown}{2}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{tab}{ctrlup}")
sleep(30000)
send("{ctrldown}{1}")
WEnd

Now is this code clean? Also I would like to add a refresh to my IE on a set interval maybe like every 4 hours? does that have to be done on individual tabs? or can I blast one key to refresh IE in general? My IE had 9 tabs on it.

Share this post


Link to post
Share on other sites

maybe this will help, can I look for text within the focused window? or is it specific to the title bar? As you can see they are all the same, I may not be understanding what you mean.

Posted Image

Within the focused window I do have txt I can seperate them with.

Share this post


Link to post
Share on other sites

I understand that all 3 instances state:

System Center Operations Manager 2007 R2

And i sugested that you make the script search for text that is singular in each of them.

Something like:

winwaitactive ("System Center Operations Manager 2007 R2", "my aplication")
Send ("!{TAB}")
winwaitactive ("System Center Operations Manager 2007 R2", "popup window")
Send ("!{TAB}")
winwaitactive ("System Center Operations Manager 2007 R2", "something")
Send ("!{TAB}")

^^^ As I said my lack of skills just tested this... AMAZING... I love it when the light bulb finally goes off....

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Ok so I have completely re-done this..... having trouble with a few things...

WinActivate("Cisco Unified Computing System Manager - Vxxx")
WinActivate("Cisco Unified Computing System Manager - Vxxx")

the Vxxx are servername that I don't to publish, but each starts with "V" how can I make that 1 command?

Also

WinActivate("Tampa, Florida")
sleep(19000)
WinActivate("Vxxxx Forefront Dashboard")
sleep(19000)
WinActivate("Denver, Colorado")
sleep(19000)
WinActivate("Vxxxxx Security Summary")
sleep(19000)
WinActivate("PasswordDashboard")
sleep(19000)
WinActivate("AgingIncidentsDashboard")
sleep(19000)
WinActivate("AvayaCallsDashboard")
sleep(19000)
WinActivate("IncidentSatisfactionDashboard")
sleep(19000)
WinActivate("IncidentsChartDashboard")

Here I am cycling through IE with tabs, I would like to use a refresh on the pages say... every 4hours?

The last issue I run into is this... my windows resize themselves when I turn off the monitor as it's HDMI and the video rescales how would I ensure screen size?

Any assistance on these items would be extremely helpful.

Edited by HexCore

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Hmm i see your not using alt+tab anymore, you just activate next window, ok that works too.

the Vxxx are servername that I don't to publish, but each starts with "V" how can I make that 1 command?

To my knowledge you dont need to put it twice, if its the same, if its different you need to put it when needed.

not sure if i understood the question, or explained right.

say you have two windows, if they have different captions/titles, you need to write those

WinActivate("Cisco Unified Computing System Manager - V123")
sleep(19000)
WinActivate("Cisco Unified Computing System Manager - V456")
sleep(19000)

a refresh, well, can use F5 on each window/tab, with a hotkey, or as you say every 4h, like so.

Global $refresh
HotKeySet ("{END}", "refresh")
Func refresh()
WinActivate("Cisco Unified Computing System Manager - V123")
Send ("{F5}")
WinActivate("Cisco Unified Computing System Manager - V456")
Send ("{F5}")
WinActivate("Cisco Unified Computing System Manager - V789")
Send ("{F5}")
EndFunc

Func refresh()
WinActivate("Cisco Unified Computing System Manager - V123")
Send ("{F5}")
WinActivate("Cisco Unified Computing System Manager - V456")
Send ("{F5}")
WinActivate("Cisco Unified Computing System Manager - V789")
Send ("{F5}")
EndFunc

Do
Sleep (14400000) ;miliseconds, equivalent to 4h if math is right.
refresh()
Until $refresh = 1

didnt test this, let me know if some problems come up.

EDIT: about the screen size, dont know if autoit can help on that, resizing windows maybe, but the actual resolution or screen position, thats a different story.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

Hmm i see your not using alt+tab anymore, you just activate next window, ok that works too.

Is this a good / clean / efficient way to perform this task? I figured it was cleaner than sending Alt + Tab

To my knowledge you dont need to put it twice, if its the same, if its different you need to put it when needed.

not sure if i understood the question, or explained right.

say you have two windows, if they have different captions/titles, you need to write those

WinActivate("Cisco Unified Computing System Manager - V123")
sleep(19000)
WinActivate("Cisco Unified Computing System Manager - V456")
sleep(19000)

Yes that's exactly what I have, but I want these 2 windows to activate/focus at the same time, these windows I have sized 1/2 screen for each window.. I'm running the command below currently which works.... but wasn't sure if I could wrap it in one command.

WinActivate("Cisco Unified Computing System Manager - V123")
WinActivate("Cisco Unified Computing System Manager - V456")
sleep(19000)

wasn't sure if I could something like this, which I did try, but it only worked on one window...

[font="Courier New"]WinActivate("Cisco Unified Computing System Manager - V*") [/font]

a refresh, well, can use F5 on each window/tab, with a hotkey, or as you say every 4h, like so.

Global $refresh
HotKeySet ("{END}", "refresh")
Func refresh()
WinActivate("Cisco Unified Computing System Manager - V123")
Send ("{F5}")
WinActivate("Cisco Unified Computing System Manager - V456")
Send ("{F5}")
WinActivate("Cisco Unified Computing System Manager - V789")
Send ("{F5}")
EndFunc

Func refresh()
WinActivate("Cisco Unified Computing System Manager - V123")
Send ("{F5}")
WinActivate("Cisco Unified Computing System Manager - V456")
Send ("{F5}")
WinActivate("Cisco Unified Computing System Manager - V789")
Send ("{F5}")
EndFunc

Do
Sleep (14400000) ;miliseconds, equivalent to 4h if math is right.
refresh()
Until $refresh = 1

didnt test this, let me know if some problems come up.

I will be testing the above suggestion, thank you very much.

EDIT: about the screen size, dont know if autoit can help on that, resizing windows maybe, but the actual resolution or screen position, thats a different story.

Well what I have are 2 windows which I have scaled to 1/2 screen each to reduce whitespace... I would like AutoIT somehow to retain where these windows are located on the screen, not sure how to attain that.. either by window positioning... ? Or X,Y coorid? I have been reading up on those 2 methods, but I'm having much luck in figuring it out.

Share this post


Link to post
Share on other sites

I also dont know how to do something like that. sorry


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

Careca,

I had to push this aside for a bit, but now I'm back on this... I'm a little confused where to add this section of code, I have toyed around but didn't get it...

Func refresh()
WinActivate("Cisco Unified Computing System Manager - V123")
Send ("{F5}")
WinActivate("Cisco Unified Computing System Manager - V456")
Send ("{F5}")
WinActivate("Cisco Unified Computing System Manager - V789")
Send ("{F5}")
EndFunc
Do
Sleep (14400000) ;miliseconds, equivalent to 4h if math is right.
refresh()
Until $refresh = 1

Where do I add that my current structure is

while 1=1
;Code
Wend

Again thank for all your assistance

Share this post


Link to post
Share on other sites

Func refresh() [u];this is the function, gets executed every 14400 seconds (4 hours)[/u]
WinActivate("Cisco Unified Computing System Manager - V123")
Send ("{F5}")
WinActivate("Cisco Unified Computing System Manager - V456")
Send ("{F5}")
WinActivate("Cisco Unified Computing System Manager - V789")
Send ("{F5}")
EndFunc [u];This is the end of the function[/u]

Do [u];This is a loop[/u]
Sleep (14400000) ;miliseconds, equivalent to 4h if math is right.
refresh() [u];This means that after 14400 seconds, it jumps to the function again.[/u]
Until $refresh = 1 [u];Continues the loop until variable $refresh is equal to 1, 
this means never, because theres no code to set the variable to 1.[/u]

That said i dont understand why you would want to use "while" but anyway, as you can see on the help file...

While checks if an expression is true, if true, all under it gets executed, continues loop, if false, it doesnt.

Example from help file.

$i = 0 [u]; variable is 0[/u]
While $i <= 10 [u]; checks if is less or equal to 10, if so, continues...[/u]
    MsgBox(0, "Value of $i is:", $i) [u]; displays message of what the current variable number is[/u]
    $i = $i + 1 [u]; adds "1" to the variable number[/u]
WEnd [u]; loops. So, it keeps adding 1 and when the number on the variable is 10 or more, the loop stops/exits.[/u]

So, if you still wanna use it, set a number to the variable, then suit the code to your needs, say, if you need it to run 10 times, it is usefull, if you want it forever, use the "Do" posted before.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

Could be my lack of skill, I'm using this on large screen monitors to cycle through different informational displays...

while / wend was the easiest way I saw to do this... still very new to coding.

so my entire code is:

While 1=1
sleep(24000)
WinActivate("System Center Operations Manager","Lync")
sleep(24000)
WinActivate("System Center Operations Manager","Hyper")
sleep(24000)
WinActivate("System Center Operations Manager","Exchange")
sleep(24000)
WinActivate("Cisco Unified Computing System Manager - Vxxx")
WinActivate("Cisco Unified Computing System Manager - Vxxx")
sleep(24000)
WinActivate("Tampa, Florida")
send ("{F5}")
sleep(24000)
WinActivate("Forefront Dashboard")
sleep(24000)
WinActivate("Denver, Colorado")
send ("{F5}")
sleep(24000)
WinActivate("Security Summary")
sleep(24000)
WinActivate("PasswordDashboard")
sleep(24000)
WinActivate("AgingIncidentsDashboard")
sleep(24000)
WinActivate("AvayaCallsDashboard")
sleep(24000)
WinActivate("IncidentSatisfactionDashboard")
sleep(24000)
WinActivate("IncidentsChartDashboard")
WEnd

Which servs it's purpose for the most part, my goal is to continously cycle through these screens, my IE tabs / monitor program / cisco UCS information

should I not be using while / wend ? is it a bad approach?

I'm currently researching your last post, thanks again for all the assistance.

Share this post


Link to post
Share on other sites

I started another thread on retaining my window sizes, things are starting to come together on this, I really appreciate everyones input on this. It's my lack of skill with using AutoIT.

Thanks again for dealing with me.

Share this post


Link to post
Share on other sites

just for the record, using 'While $refresh = 1' and 'do...until $refresh = 1' mean the same thing. and if i were you id take a look at the help file on the window functions, such as WinGetPos()


[spoiler]My UDFs: Login UDF[/spoiler]

Share this post


Link to post
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
Sign in to follow this  
Followers 0