Maurice Posted July 27, 2007 Share Posted July 27, 2007 I wanna have a program that opens every (music-)file in a folder, so I wrote the following:ShellExecute( "C:\Music\") winwaitactive( "Music" ) sleep(500) controlsend( "Music", "", WinGetHandle ( "Music"), "^a") controlsend( "Music", "", WinGetHandle ( "Music"), "{ENTER}") winclose( "Music" ) winwaitactive( "Windows Media Player" ) winsetstate( "Windows Media Player", "", @SW_MINIMIZE)I used 'controlsend' so I can use some extra-key on my keyboard to open it, even when I'm in a game.Now the problem is, it doesn't work.It doesn't send anything to the place where I'd like it to send it, though I used almost the same term for something else and it worked.Using "send("^a")" works fine, but even when I'm doing the @error check, it doesn't tell me that there went something wrong.Now what I guess is that it does send it, but not the the right item of the music window.Any ideas on how I could do that the right way?And can I prevent the music folder from popping over the game I'm currently in?Thank you. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 27, 2007 Share Posted July 27, 2007 I wanna have a program that opens every (music-)file in a folder, so I wrote the following: ShellExecute( "C:\Music\") winwaitactive( "Music" ) sleep(500) controlsend( "Music", "", WinGetHandle ( "Music"), "^a") controlsend( "Music", "", WinGetHandle ( "Music"), "{ENTER}") winclose( "Music" ) winwaitactive( "Windows Media Player" ) winsetstate( "Windows Media Player", "", @SW_MINIMIZE)I used 'controlsend' so I can use some extra-key on my keyboard to open it, even when I'm in a game. Now the problem is, it doesn't work. It doesn't send anything to the place where I'd like it to send it, though I used almost the same term for something else and it worked. Using "send("^a")" works fine, but even when I'm doing the @error check, it doesn't tell me that there went something wrong. Now what I guess is that it does send it, but not the the right item of the music window. Any ideas on how I could do that the right way? And can I prevent the music folder from popping over the game I'm currently in? Thank you. Unless you've changed WinTitleMatchMode elsewhere in your script, "Music" does not match "C:\Music" by default. Look more closely at the title of the window and what you are matching with. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Risso Posted July 27, 2007 Share Posted July 27, 2007 [... snipped] Any ideas on how I could do that the right way? And can I prevent the music folder from popping over the game I'm currently in? Thank you.To prevent the window from popping up use the parameter -- "showflag" Also I would assign some of the code to variables - especially when you need to use it over and over. This will make changes easier to manage as you troubleshoot. CODE ; This command: ; ShellExecute ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] ) ; Becomes: ShellExecute( "C:\Music\","","","",@SW_HIDE) $wintitle = "Music" $hwnd = WinGetHandle ( "Music") ; The handle you are using is probably incorrect as PsaltyDS has already noted. controlsend( $wintitle, "", $hwnd, "^a") controlsend( $wintitle, "", $hwnd, "{ENTER}") Link to comment Share on other sites More sharing options...
Maurice Posted July 27, 2007 Author Share Posted July 27, 2007 (edited) Thank you! Fixed it with the 'WinGetHandle ("C:\Music")' thing Edit: Oh, is there a method to stop WMP from popping over stuff when opening media files? Edited July 27, 2007 by Maurice 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