Jump to content

bmitchell

Members
  • Posts

    13
  • Joined

  • Last visited

bmitchell's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Haha I know, I can only 'see' that its not focused the page when I reconnect to the session and see firefox in the background behind other windows. It has been working as expected now for a good few scheduled attempts, which is great! Thanks once again for all the help everyone. I will certainly be looking at other solutions and maybe IE is the way i'll go... but I'm stubbourn and have a I've started so i'll finish attitude.! i'm slowly learing the different commands so will be trying them out soon.
  2. Thanks for all the help once again.. I now think it's working with the code below. What was making things worse is that I was trying to run the scheduled task with a user account which I only really connect to over RDP. When I disconnected from my session (even though the user was still logged in - I could see the account in task manager still logged on from the other account logged on at the console) the task would run as scheduled but for some reason the script opened firefox but couldn't bring it into focus?!? Even if it worked OK if I was still connected to the session. You'll notice I have left a sleep in too after WinWaitActive - no idea why but sometimes (1 in 10) it was missing a {tab} which caused issues. This seems to fix though. $ConfigWindowTitle = "[CLASS:MozillaUIWindowClass]" ; or ; $ConfigWindowTitle = "Mozilla Firefox" Run("C:\Program Files (x86)\Mozilla Firefox\firefox.exe") ;Run firefox remove include x86 for 64bit system WinWait($ConfigWindowTitle) ;Sleep(15000) ;$var = WinActivate($ConfigWindowTitle) ;ConsoleWrite($var) ; or ;MsgBox(0, "", $var) WinWaitActive($ConfigWindowTitle) ; Wait for it to be active before sending keystrokes. sleep(2000) Send("{TAB 7}") ;focus address bar Send("http://192.168.1.1/setup.cgi?next_file=Status.htm{ENTER}") ;send url WinWaitActive("Authentication Required") ; wait for password box Send("{ENTER}") WinWaitActive("Modem Router Status") ;wait for modem window Send("{TAB 11}{ENTER}") ;select disconnect ; WinClose($ConfigWindowTitle) Now I'll wait until the morning to see if my router d/c's as expected at 2am...
  3. Thanks for the reply, This is what I had to begin with: Run("C:\Program Files (x86)\Mozilla Firefox\firefox.exe") WinActivate($ConfigWindowTitle) WinWaitActive($ConfigWindowTitle) but it doesn't work 100% because sometimes the Run has not loaded firefox up quickly enough so the script misses the WinActivate line out (it can't find the window because its not fully loaded yet) It works without fail if I do the following Run("C:\Program Files (x86)\Mozilla Firefox\firefox.exe") Sleep(5000) WinActivate($ConfigWindowTitle) WinWaitActive($ConfigWindowTitle) but as pointed out above this isn't ideal really.
  4. OK so i've tried this.. arrangement - no luck WinWaitActive($ConfigWindowTitle) WinActivate($ConfigWindowTitle) Then WinWaitActive($ConfigWindowTitle) also tried WinWaitExists - also doesn't work as expected. i'm just guessing now though! Sleep may have to do for now ? - although not ideal
  5. I agree it seems to leave room for error! So do you mean use WaitWinActive($ConfigWindowTitle) before WinActivate($ConfigWindowTitle)? Do I then need it again after? So WinWaitActive($ConfigWindowTitle) WinActivate($ConfigWindowTitle) Then WinWaitActive($ConfigWindowTitle) again?
  6. Aha! I added a sleep(5000) in after the Run firefox and it seemed to work! I was then also able to change back to WinWaitActive($ConfigWindowTitle)and run successfully. Maybe when I was fiddling first time it just so happened that my machine was fast enough to get the process up and running before winactivate kicked in? When I scheduled it to run my machine would have been busy doing other things too. Does this sound like a logical explanation? what kind of Sleep time is generally used? i'm guessing 5000 should be enough before I think about changing my machine!
  7. Hmmm - it didn't run as scheduled last night?! even though I am sure it worked when I last posted! (I scheduled it to run whilst I was watching it, and ran it manually in task scheduler and i'm sure it worked!) now for some reason it just doesn't - its back to only working off a double click of the .exe
  8. Thanks so much Dani! with your help it's fixed! I just started from scratch with your pointers so was left with the code below.. For some strange reason it doesn't like WinWaitActive($ConfigWindowTitle) and continued without waiting. Swapping for the actual title worked though. @jacobraccuia - Great tip - Thanks it looks neater at least!! $ConfigWindowTitle = "[CLASS:MozillaUIWindowClass]" ; or ; $ConfigWindowTitle = "Mozilla Firefox" Run("C:\Program Files (x86)\Mozilla Firefox\firefox.exe") ;Run firefox remove include x86 for 64bit system $var = WinActivate($ConfigWindowTitle) ;ConsoleWrite($var) ; or ;MsgBox(0, "", $var) WinWaitActive("Mozilla Firefox Start Page - Mozilla Firefox") ; Wait for it to be active before sending keystrokes. Send("{TAB 7}") ;focus address bar Send("http://192.168.1.1/setup.cgi?next_file=Status.htm{ENTER}") ;send url WinWaitActive("Authentication Required") ; wait for password box Send("{ENTER}") WinWaitActive("Modem Router Status") ;wait for modem window Send("{TAB 11}{ENTER}") ;select disconnect ;WinClose($ConfigWindowTitle)
  9. :s hmmm neither of those work on mine.. How do you know the CLASS? where do I find this info? Maybe I'll have to try setting one of the other matching modes to see how that goes?
  10. Thanks again for your help on this - I put this into my code after where winactive is used and sure enough I get a 0 pop up in a msg box - have I got the code right? -i've not used this bit before? $var = WinActivate($ConfigWindowTitle) ConsoleWrite($var) ; or MsgBox(0, "", $var) The actual text in the title bar is "Mozilla Firefox Start Page - Mozilla Firefox" without quotes. EDIT: I see why you ask now - When I entered it in the code directly it was correct. I just couldn't remeber the actual text when writing the post! How do I resolve?
  11. This is what I tried to use first time round. It has the same outcome unfortunately. I've just tried again - no luck I also tried just putting winactivate("Mozilla Firefox - start page") - still the same..
  12. Thanks for the reply - That is what I currently have in the code above - and it does suit my needs when running it straight from the .exe but when scheduling to run in Win7x64 It doesn't bring the window into focus. (this is my problem)
  13. Hi - I'm extremely new to all this, but can't believe I haven't found it before! I seem to be having an issue with Firefox being brought into focus in some cases. which in turn means the rest of my script cannot run. Basically I want a simple script to do the following: open firefox go to my routers status page login (firefox fills out the password box) press disconnect on that page. What I have below works OK on both 32 and 64 bit when clicked directly from the .exe the problem is when I use Windows Task scheduler to run it on the 64bit system (Win7). It opens firefox (I can see it on the taskbar) but doesn't then bring it into focus. When i click on Firefox on the taskbar the script continues. I have tried various methods below (commented out at the moment) but none makes any difference. I have triple checked the Task scheduler settings and all are exactly the same. It seems to be related to 64bit windows. I have tried compiling for both 32 and 64 and although both work from a double clicking the .exe neither work from scheduled. Any help would be greatly appreciated! ;-----Configuration----- Dim $ConfigWindowTitle = "Mozilla Firefox Start Page - Mozilla Firefox" Dim $appName = "Mozilla Firefox Start Page" $appHandle = WinGetHandle($appName, "") ;-----End of configuration---- Run("C:\Program Files (x86)\Mozilla Firefox\firefox.exe") ;Run firefox remove include x86 for 64bit system WinActivate($appHandle);firefox in focus ;WinSetOnTop($appHandle, "", 1) ;WinSetState($appHandle, "", @SW_SHOW) WinWaitActive($ConfigWindowTitle) ;Wait for it to be active before sending keystrokes. Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}") ;focus address bar Send("http://192.168.1.1/setup.cgi?next_file=Status.htm{ENTER}") ;send url WinWaitActive("Authentication Required") ; wait for password box Send("{ENTER}") WinWaitActive("Modem Router Status") ;wait for modem window ;Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}") ;select disconnect ;WinClose($ConfigWindowTitle)
×
×
  • Create New...