
vmicchia
Members-
Posts
10 -
Joined
-
Last visited
Everything posted by vmicchia
-
Help with a delay in the program.
vmicchia replied to vmicchia's topic in AutoIt General Help and Support
Well I forgot to take that second one out. It was just a test. I just want to somehow have the program continie checking what it is and not see the effects of the delay. If the IE windows is changing quickly and is not the Element window it gets caught in the delay and does not switch to the eterm window till that delay is done. -
Help with a delay in the program.
vmicchia replied to vmicchia's topic in AutoIt General Help and Support
The loop is supposed to stay active until the stop button is pressed. Anyway I tried your code and it just continually switched between the eterm and IE windows. The loop is supposed to be infinite until the stop button is pressed. The Program works as expected the only issue is that there is that 5 second delay which accounts for the load times of that particular window. My issue I guess is there a way to insulate that delay so that the rest of the program keeps running as expected? -
Ok I have a program that keeps a certain window in focus(Eterm). However it does check ffor the title of the IE window in case of a certain sitation. Sometimes that site takes some time to load but in the other cases it's pretty fast. But otherwise I need the Eterm window to be in focus. So with the delay how I currently have it it will take some time to bring the eterm window back in focus. If anyone could help me I would be very appreciaive. Here's the code: #comments-start This program is meant to be used with a dual monitor setup at the sales desks. It sends screen commands to the active window which should be IE. At the current time it is only set to work with IE. #comments-end #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <StaticConstants.au3> ;Sets the opion to not use an exact match on titles Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase $Form1 = GUICreate("DMFocusKeeper", 156, 253, 890, 203) $Label1 = GUICtrlCreateLabel("Eterm Focus Keeper", 24, 8, 100, 21) $Button1 = GUICtrlCreateButton("Start", 32, 40, 81, 25) $Button2 = GUICtrlCreateButton("Close", 32, 80, 81, 25) $Group1 = GUICtrlCreateGroup("Move IE Window", 16, 128, 121, 105) $Button3 = GUICtrlCreateButton("Switch Monitor", 32, 160, 81, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) If Not IsDeclared("screen") Then Global $screen = 0 EndIf If Not IsDeclared("start") Then $start = 0 EndIf $var = 0 GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $gui_event_close Exit Case $msg = $Button2 Exit Case $msg = $Button1 MsgBox(0, "Program Notification", "Please do not manually open, close or move the Internet Explorer window while this program is open.") CheckActive() Case $msg = $Button3 If $var = 0 Then $var = 1 $start = 1 EndIf CheckActive() SwitchMonitor() Case Else Sleep(10) EndSelect WEnd ;Our constant function to check screens Func CheckActive() If $var = 1 Then GUICtrlSetData($Button1, "Start") $var = 0 Else GUICtrlSetData($Button1, "Stop") $var = 1 EndIf While $var = 1 $msg = GUIGetMsg() Select Case $msg = $gui_event_close Exit Case $msg = $Button2 Exit Case $msg = $Button1 CheckActive() Case $msg = $Button3 SwitchMonitor() Case Else ;check to see if IE is the active window If WinActive("[CLASS:IEFrame]") Then WinActivate("Eterm") ;pause for 5 seconds to cope for slow loading Sleep(5000) WinActivate("Eterm") ;get the title of the IE window $title = WinGetTitle("[CLASS:IEFrame]", "") ;This if statement checks against the title of the IE window and then takes different actions based on the given state of the program. If $title == "Element - Windows Internet Explorer" And $screen <> 1 Then ;checks to see if the IE window is active and if not it activates the window so that it gets the command. If Not WinActive("[CLASS:IEFrame]") Then WinActivate("[CLASS:IEFrame]") EndIf $screen = 1 Send("#+{RIGHT}") ;MsgBox(1, "Ths is the screen variable", $screen) ElseIf $title <> "Element - Windows Internet Explorer" And $screen == 1 Then ;checks to see if the IE window is active and if not it activates the window so that it gets the command. If Not WinActive("[CLASS:IEFrame]") Then WinActivate("[CLASS:IEFrame]") EndIf $screen = 0 Send("#+{LEFT}") ;MsgBox(1, "Ths is the screen variable", $screen) WinActivate("Eterm") ElseIf $title <> "Element - Windows Internet Explorer" And $screen <> 1 Then WinActivate("Eterm") $screen = 0 ElseIf $title <> "Element - Windows Internet Explorer" And $screen == 1 Then $screen = 1 EndIf EndIf EndSelect WEnd EndFunc ;==>CheckActive Func SwitchMonitor() $stop = 1 While $stop = 1 If Not WinActive("[CLASS:IEFrame]") Then WinActivate("[CLASS:IEFrame]") EndIf Send("#+{RIGHT}") $stop = 0 if $screen = 1 Then $screen = 0 Else $screen = 1 EndIf WEnd EndFunc ;==>SwitchMonitor
-
I figured it out. I needed to add a Sleep() before checking the page title. It was taking a second or so to load so it was getting the old title. Also thank you for the tip BrewManNH.
-
ALright, I've been playing around with the code all day. I've almost got it but I seem to be having one last problem. When I run the program for some reason I have to activate it twice to get this line to fire : If $title == "MyWindow - Windows Internet Explorer" And $screen <> 1 Then All the rest of the code works fine. But that being the most important line dosen't work for some reason. Here is the whole code: #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase $Form1 = GUICreate("DMFocusKeeper", 117, 191, 192, 124, 0x00000008) $Button1 = GUICtrlCreateButton("Start", 20, 72, 75, 25) $Button3 = GUICtrlCreateButton("Close", 20, 116, 75, 25) $Label1 = GUICtrlCreateLabel("Eterm Focus Keeper", 8, 32, 100, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) If Not IsDeclared("screen") Then $screen = 0 EndIf $var = 0 GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $gui_event_close Exit Case $msg = $Button3 Exit Case $msg = $Button1 CheckActive() Case Else Sleep(10) EndSelect WEnd Func CheckActive() If $var = 1 Then GUICtrlSetData($Button1, "Start") $var = 0 Else GUICtrlSetData($Button1, "Stop") $var = 1 EndIf While $var = 1 $msg = GUIGetMsg() Select Case $msg = $gui_event_close Exit Case $msg = $Button3 Exit Case $msg = $Button1 CheckActive() Case Else If WinActive("[CLASS:IEFrame]") Then $title = WinGetTitle("[CLASS:IEFrame]", "") If $title == "MyWindow - Windows Internet Explorer" And $screen <> 1 Then $screen = 1 Send("#+{RIGHT}") ;MsgBox(1, "Ths is the screen variable", $screen) ElseIf $title <> "MyWindow- Windows Internet Explorer" And $screen == 1 Then $screen = 0 Send("#+{LEFT}") ;MsgBox(1, "Ths is the screen variable", $screen) WinActivate("Eterm") ElseIf $title <> "MyWindow - Windows Internet Explorer" And $screen <> 1 Then WinActivate("Eterm") $screen = 0 ElseIf $title <> "MyWindow - Windows Internet Explorer" And $screen == 1 Then $screen = 1 EndIf EndIf EndSelect WEnd EndFunc ;==>CheckActive
-
Ok I've changed my code a bit. I know the switch statements are odd but I was having some issues with the if else statements for some reason. Anyway my problem now is that I want the program running constatly to check for these things but if I leave IE as the active window it runs this code constantly Send("!d") Send("^c") $link = ClipGet() I for some reason can't think of a way to loop that to fix the problem and I can't find a function to check a change in active window or anything like that. Any help would be much appreciated. Here's the whole code now: #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase $Form1 = GUICreate("DMFocusKeeper", 117, 191, 192, 124, 0x00000008) $Button1 = GUICtrlCreateButton("Start", 20, 72, 75, 25) $Button3 = GUICtrlCreateButton("Close", 20, 116, 75, 25) $Label1 = GUICtrlCreateLabel("Eterm Focus Keeper", 8, 32, 100, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE)) If Not IsDeclared("screen") Then $screen = 0 EndIf $var = 0 GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $gui_event_close Exit Case $msg = $Button3 Exit Case $msg = $Button1 CheckActive() Case Else Sleep(10) EndSelect WEnd Func CheckActive() If $var = 1 Then GUICtrlSetData($Button1, "Start") $var = 0 Else GUICtrlSetData($Button1, "Stop") $var = 1 EndIf While $var = 1 $msg = GUIGetMsg() Select Case $msg = $gui_event_close Exit Case $msg = $Button3 Exit Case $msg = $Button1 CheckActive() Case Else Sleep(10) If WinActive("[CLASS:IEFrame]") Then Send("!d") Send("^c") $link = ClipGet() Switch $link Case [url="http://www.google.com"]http://www.google.com[/url] Switch $screen Case 0 Send("#+{RIGHT}") $screen = 1 EndSwitch Case Else Switch $screen Case 1 Send("#+{LEFT}") $screen = 0 WinActivate("Eterm") EndSwitch EndSwitch EndIf EndSelect WEnd EndFunc ;==>CheckActive
-
I was looking at those. I'm not sure that they would help though. I am opening the IE tabs from the Eterm program that my program sets to active not from the program I wrote. I may have missed some thing but those only seem to work when opened from the autoit program.
-
Hi there. I have this programand what I want for it to do is if there is an IE window open it will check the URL and then if it is a specific URL it will move the window to the opposite monitor and allow it to remain the focus. If the URL changes it sends it back to the second monitor and makes another program the focus and otherwise just makes the second program the focus. The problem is that if I chage IE windows I have to activate the window twice before it checks the URL again. The program that is usally in focus is what changes the IE windows. Here's the code: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase $Form1 = GUICreate("DMFocusKeeper", 117, 191, 192, 124,0x00000008) $Button1 = GUICtrlCreateButton("Start", 20, 72, 75, 25) $Button3 = GUICtrlCreateButton("Close", 20, 116, 75, 25) $Label1 = GUICtrlCreateLabel("Eterm Focus Keeper", 8, 32, 100, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE)) $var=0 $screen = 0 GUISetState(@SW_SHOW) While 1 $msg=GUIGetMsg() Select Case $msg=$gui_event_close Exit Case $msg=$Button3 Exit Case $msg=$Button1 CheckActive() Case Else Sleep(10) EndSelect WEnd Func CheckActive() If $var=1 Then GUICtrlSetData($Button1,"Start") $var=0 Else GUICtrlSetData($Button1,"Stop") $var=1 EndIf While $var = 1 $msg=GUIGetMsg() Select Case $msg=$gui_event_close Exit Case $msg=$Button3 Exit Case $msg=$Button1 CheckActive() Case Else Sleep(10) IF WinActive("[CLASS:IEFrame]") Then Sleep(10) send ("!d") send ("^c") $link = ClipGet() IF $link == "http://www.google.com/" AND $screen <> 1 Then send ("#+{RIGHT}") $screen = 1 ElseIf $link <> "http://www.google.com/" AND $screen == 1 Then send ("#+{LEFT}") $screen = 0; WinActivate ("Eterm") Else WinActivate ("Eterm") EndIf EndIf EndSelect WEnd EndFunc
-
Help with a simple function.
vmicchia replied to vmicchia's topic in AutoIt General Help and Support
Hey guys thank you so much for the help. That code works just perfect Blinky, and I will keep those tips in mind I think the WinTitleMatch function will be very useful. I really appreciate how great this forum is. -
Hi, just started with autoit as it seems like a pretty powerful tool and I'm always happy to have those. Anyway I started on my first script and I am having some issues. What I am trying to do is write a script that once started checks if a certain program (notepad in this case) is the active window, and if it is not make it so, and continue doing this till the stop button is pressed. My script doesn't seem to be working and I would very much appreciate being pointed in the right direction. Here's what I have so far: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\vmicchia\Downloads\Forms\FMEFK.kxf $Form1 = GUICreate("DMFocusKeeper", 117, 191, 192, 124) $Button1 = GUICtrlCreateButton("Start", 16, 72, 75, 25) $Button2 = GUICtrlCreateButton("Stop", 16, 104, 75, 25) $Button3 = GUICtrlCreateButton("Close", 16, 136, 75, 25) $Label1 = GUICtrlCreateLabel("Eterm Focus Keeper", 8, 32, 100, 20, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Button3 Exit Case $Button1 $var = 1 Call("CheckActive") Case $Button2 $var = 0 Call("CheckActive") EndSwitch WEnd Func CheckActive($var) While $var == 1 If NOT WinActive("Notepad") Then WinActivate("Notepad") WEnd EndFunc