rossnixon Posted April 22, 2010 Share Posted April 22, 2010 I wish to schedule a compiled script to run each day at a certain time. This will bring a specifically named 'application' or 'process' (it appears in both places) to the foreground, assuming that it is running, so that I can automate several key presses on the dialog box. How would I do the test that it is running? How would I bring it to the foreground? I can do the keypress stuff OK. Thanks. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted April 22, 2010 Share Posted April 22, 2010 (edited) ProcessExists & WinActivate Edited April 22, 2010 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
omnomnom Posted April 22, 2010 Share Posted April 22, 2010 i guess this very simple (but untested) code would work... #RequireAdmin if ProcessExists("process.exe") Then winactivate("name of the window") EndIf however you could also use #RequireAdmin if winexists("name of the window") Then winactivate("name of the window") EndIf which would also probably work. Link to comment Share on other sites More sharing options...
rossnixon Posted April 23, 2010 Author Share Posted April 23, 2010 Thank you for that. Now I am stuck on getting the window to unminimise. The ProcessExists works (I used a MsgBox test)... but WinActivate doesn't work. I tried part of the text, then the full text from the top of the window. I also updated to version 3.3.6.1 to see if that would help, but no. (Using XP Home SP3) Link to comment Share on other sites More sharing options...
omnomnom Posted April 23, 2010 Share Posted April 23, 2010 (edited) Ok, try this... #RequireAdmin Opt("WinTitleMatchMode", 2) if ProcessExists("process.exe") Then winactivate("name of the window") EndIf It would also help if you could tell us the name of the window you are trying to activate. Thanks Edited April 23, 2010 by omnomnom Link to comment Share on other sites More sharing options...
rossnixon Posted April 26, 2010 Author Share Posted April 26, 2010 The window is called: Ross - Quickbooks Pro Timer (I double-checked using Au3Info) If the window is behind another window, it brings it to the foreground. If it is minimised, nothing happens. I did try the 'Opt' code too, (is that the default?), but no change. Link to comment Share on other sites More sharing options...
rossnixon Posted April 26, 2010 Author Share Posted April 26, 2010 Now I'm trying the following 3 lines, but I'm not sure what order to use them in. I tried a few orders but none of them worked. WinSetState ("QuickBooks Pro Timer", "", @SW_RESTORE) WinActivate("QuickBooks Pro Timer") WinSetOnTop("QuickBooks Pro Timer", "", 1) Link to comment Share on other sites More sharing options...
somdcomputerguy Posted April 26, 2010 Share Posted April 26, 2010 Function WinGetState - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
rossnixon Posted April 28, 2010 Author Share Posted April 28, 2010 I tried function WinGetState. It returns 7 (exists, visible, enabled) regardless of whether the interface dialog is minimised to the task bar, or visible in the middle of the screen, or hidden behind another window. This must not be a 'normal' window. It looks more like a dialog bix than a window, come to think of it. Is there a different function that will restore a minimised dialog box? Link to comment Share on other sites More sharing options...
omnomnom Posted April 28, 2010 Share Posted April 28, 2010 have you tried WinActive? http://www.autoitscript.com/autoit3/docs/functions/WinActive.htm Link to comment Share on other sites More sharing options...
rossnixon Posted April 29, 2010 Author Share Posted April 29, 2010 (edited) OK, tried WinActive. The windows is *not* active when minimized. I don't know how to make it active or restore it onto the screen. WinActivate(), WinSetOnTop() and WinSetState() won't do it, and after each of them I ran another WinActive(), but the window did not become 'active'. Does anyone want to try the application? I can send the 3 files for installing (4.3MB as a 7z archive) Edited April 29, 2010 by rossnixon Link to comment Share on other sites More sharing options...
omnomnom Posted May 2, 2010 Share Posted May 2, 2010 OK, tried WinActive.The windows is *not* active when minimized.I don't know how to make it active or restore it onto the screen.WinActivate(), WinSetOnTop() and WinSetState() won't do it, and after each of them I ran another WinActive(), but the window did not become 'active'.Does anyone want to try the application? I can send the 3 files for installing (4.3MB as a 7z archive)Sure send them, ill have a try. Link to comment Share on other sites More sharing options...
rossnixon Posted May 3, 2010 Author Share Posted May 3, 2010 (edited) Have tried using both the basic and the flash uploader. But get error messages with both. If the file actually got there (Files, Misc) it is called QuickBooks_Pro_Timer.zip Edited May 3, 2010 by rossnixon Link to comment Share on other sites More sharing options...
omnomnom Posted May 4, 2010 Share Posted May 4, 2010 Hmm, I am unsure if it is allowed in the forums however you can try uploading to a file sharing service and giving the the link (in code tags). I recommend http://mediafire.com I can then get it from the link you provide and continue helping you. if this is not allowed in these forums can somebody let me know? Thanks. Link to comment Share on other sites More sharing options...
rossnixon Posted May 5, 2010 Author Share Posted May 5, 2010 OK, have uploaded to the public area of mediafire, I think. (I didn't make an account). Link is http://www.mediafire.com/download.php?n0ic3z0gm2i Link to comment Share on other sites More sharing options...
herewasplato Posted May 5, 2010 Share Posted May 5, 2010 (edited) Opt("WinTitleMatchMode", 2) ; 2 = Match any substring in the title WinActivate("Timer")works for me using v3.3.6.1 and the zip that you uploaded on XP Pro SP3 The window changes titles. When it is minimized to the task bar - the title is "Timer". When it is not minimized, perhaps not in the foreground, the title is "1 - QuickBooks Pro Timer". Edited May 5, 2010 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
omnomnom Posted May 5, 2010 Share Posted May 5, 2010 Opt("WinTitleMatchMode", 2) ; 2 = Match any substring in the title WinActivate("Timer")works for me using v3.3.6.1 and the zip that you uploaded on XP Pro SP3 The window changes titles. When it is minimized to the task bar - the title is "Timer". When it is not minimized, perhaps not in the foreground, the title is "1 - QuickBooks Pro Timer". I also get this... The title always contains timer so set the winactivate to be "Timer" and it will always work. Link to comment Share on other sites More sharing options...
Neno Posted May 5, 2010 Share Posted May 5, 2010 (edited) I also get this... The title always contains timer so set the winactivate to be "Timer" and it will always work. Totally not tested as I don't have your program ;; Find a window and bring it to the foreground ;; HotKeySet("{F1}","Terminate") Opt("WinTitleMatchMode",2) While 1 If (WinActivate("Timer") <> 0) Or (WinActive("Timer") <> 0) Then WinSetState("Timer","",@SW_RESTORE) ToolTip("Activated",0,0) StuffToDo() ExitLoop Else ToolTip("Not Activated",0,0) EndIf Sleep(1000) WEnd Func StuffToDo() ToolTip("Doing Stuff",0,0) ;; put all your macros here ;-D Sleep(1000) EndFunc Func Terminate() Exit 0 EndFunc Edited May 5, 2010 by Neno Link to comment Share on other sites More sharing options...
rossnixon Posted May 5, 2010 Author Share Posted May 5, 2010 Ah!!! Thank you to all who helped. I had assumed - wrongly - that the Title was a 'fixed' thing that was just not all visible when minimised. 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