chachew Posted August 21, 2011 Share Posted August 21, 2011 Im trying to do something simple but need some help as i am new to AutoIT I am wanting to create a script that will display 1 of 2 open apps every 7 seconds. I will have a we app open in IE and a remote desktop session open through XP's remote desktop. Before the script is run i will open IE and login to the correct part of the web app, i will also do the same for my remote session. Ill then want to run the script, i want the script to first display IE (maximizing IE if it is not already), wait 7 seconds, then show the second opened app (maximizing IE if it is not already), wait 7 seconds and then back to IE. It would loop through this process until i either kill the script or possibly by some type of keyboard command. Maybe when pressing Ctrl-PrtScn or something to that effect Anyone have an idea how to go about this? Link to comment Share on other sites More sharing options...
FireFox Posted August 21, 2011 Share Posted August 21, 2011 (edited) Maximizing a window -> WinSetState with @SW_MAXIMIZE in flag Activating a window -> WinActivate Waiting x seconds -> Sleep (*1000 because it's in ms) KeyBoard command -> Send Before asking something else like this, look at the help file which contains all autoit functions. (F1 in SciTE) Br, FireFox. Edited August 21, 2011 by FireFox Link to comment Share on other sites More sharing options...
chachew Posted August 22, 2011 Author Share Posted August 22, 2011 Ok i think i have it figured out so far, just a few questions. My while statement is "While 1..." what does the "1" signify? The only thing i see so far looking at the help file is that for my HotKeySet, Success=1 and Failure=0 but how would my While statement know that? Second question is i currently have this setup for IE and notepad to alternate but ultimately i want it to be IE and a remote desktop connection window. The question is how do i find the "[CLASS:~~]" of various applications? HotKeySet("{ESC}", "Terminate") While 1 WinSetState("[CLASS:Notepad]", "", @SW_MAXIMIZE) WinActivate("[CLASS:Notepad]", "") sleep(3000) WinSetState("", "Windows Internet Explorer", @SW_MAXIMIZE) WinActivate("[CLASS:IEFrame]", "") sleep(3000) WEnd Func Terminate() WinSetState("[CLASS:Notepad]", "", @SW_MINIMIZE) WinSetState("", "Windows Internet Explorer", @SW_MINIMIZE) Exit EndFunc Link to comment Share on other sites More sharing options...
dannyict Posted August 22, 2011 Share Posted August 22, 2011 you can use AutoIt Window Info (in the autoit folder) to get info about the window Link to comment Share on other sites More sharing options...
FireFox Posted August 22, 2011 Share Posted August 22, 2011 My while statement is "While 1..." what does the "1" signify? It's like "While True" which means that it will loop forever. You can put a condition for example "While $myvar < 5" etc. The only thing i see so far looking at the help file is that for my HotKeySet, Success=1 and Failure=0 but how would my While statement know that? In order to get the return values, you have to handle your function with a variable. For example : $myhk = HotKeySet("{F1}", "_Help") While 1 WEnd Func _Help() ;it will always return 1 because the function has been called by the hotkey which worked. MsgBox(64, "Return value:", $myhk) $mystr = StringLeft("Hello World !", 5) MsgBox(64, "Return value:", $mystr) Return 1 ;if you call this function it will return the value 1 EndFunc Every function has it own return values/erros. Br, FireFox. Link to comment Share on other sites More sharing options...
chachew Posted August 23, 2011 Author Share Posted August 23, 2011 I am now trying to get the seconds that are input into the filed to be multiplied by 1000 to get the miliseconds of sleep time. What am i missing? I was trying the help file but i must be looking for the wrong thing.. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Screen", 272, 142, 196, 127) $MenuItem2 = GUICtrlCreateMenu("&File") $MenuItem1 = GUICtrlCreateMenu("&Settings") $Group1 = GUICtrlCreateGroup("Interval", 8, 8, 161, 65) $secondsIN = GUICtrlCreateInput("", 24, 32, 57, 21) $Label1 = GUICtrlCreateLabel("seconds", 96, 32, 44, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Label2 = GUICtrlCreateLabel("Status:", 184, 16, 37, 17) $status = GUICtrlCreateLabel("", 180, 40, 4, 4) $runBtn = GUICtrlCreateButton("Run", 8, 88, 75, 25) $StopBtn = GUICtrlCreateButton("Stop", 96, 88, 75, 25) GUISetState(@SW_SHOW) HotKeySet("{ESC}", "Terminate") Func Terminate() WinSetState("[CLASS:Notepad]", "", @SW_MINIMIZE) WinSetState("", "Windows Internet Explorer", @SW_MINIMIZE) Exit EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $runBtn While 1 $seconds = $secondsIN * 1000 WinSetState("[CLASS:Notepad]", "", @SW_MAXIMIZE) WinActivate("[CLASS:Notepad]", "") sleep($seconds) WinSetState("", "Windows Internet Explorer", @SW_MAXIMIZE) WinActivate("[CLASS:IEFrame]", "") sleep($seconds) WEnd EndSwitch WEnd Link to comment Share on other sites More sharing options...
FireFox Posted August 25, 2011 Share Posted August 25, 2011 I am now trying to get the seconds that are input into the filed to be multiplied by 1000 to get the miliseconds of sleep time. What am i missing? I was trying the help file but i must be looking for the wrong thing. You have to use the function GuiCtrlRead to get the input data : $input = GuiCtrlCreateInput("bla", .... $read = GuiCtrlRead($input) ConsoleWrite($read & @CrLF) Br, FireFox. 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