Phate4219 Posted August 17, 2011 Share Posted August 17, 2011 So here's the general outline of my project: I'm trying to create a simple autoit script to grab the current song playing on my pandora player and put it into my vent comment. The player in question has the ability to paste the current song info with a hotkey, in this case, I have it sent to CTRL+`, and when I hit that in the comment box, it pastes in the song, for example "The Eagles - Hotel California". Here's the code I have so far: Func TitleUpdate() $hwndvent = (HWND(0x000201E6)) ControlClick($hwndvent, 'Comment", 1060) sleep(500) ControlSend( "Comment - Advanced", "", 1062, "^`") sleep(500) ControlClick("Comment - Advanced", "OK", 1) sleep(4000) EndFunc This is the problem I'm having: When I replaced "^`" with "test", it wrote test in my comment just fine. The problem seems to lie in the interaction between autoit and the hotkey from the pandora player. How do I get it to execute the hotkey, or input the keys as if they were being typed on a keyboard? I've tried using ControlFocus and then using plain Send commands, I've tried using {CTRLDOWN}, `, and {CTRLUP} all in seperate Sends or ControlSends, to no avail. Also, it's worth noting that I've only been using autoit for about 3 hours, and this code was a modification of a script I found off google for grabbing the title of a last.fm window and putting it into a vent comment. Any help would be greatly appreciated, Phate Link to comment Share on other sites More sharing options...
JohnOne Posted August 17, 2011 Share Posted August 17, 2011 (edited) If the hotkey conflicts with one from your application, it may cause problems. I'm assuming you have more code than that, and the problem may lie in it., not that function. EDIT: Func TitleUpdate() $hwndvent = (HWND(0x000201E6));how certain are you that this will be the handle to the window? ControlClick($hwndvent, 'Comment", 1060) sleep(500) ControlSend( "Comment - Advanced", "", 1062, "^`");how sure are you that this is the ID of the control sleep(500) ControlClick("Comment - Advanced", "OK", 1) sleep(4000) EndFunc Edited August 17, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Phate4219 Posted August 17, 2011 Author Share Posted August 17, 2011 If the hotkey conflicts with one from your application, it may cause problems. I'm assuming you have more code than that, and the problem may lie in it., not that function. EDIT: Func TitleUpdate() $hwndvent = (HWND(0x000201E6));how certain are you that this will be the handle to the window? ControlClick($hwndvent, 'Comment", 1060) sleep(500) ControlSend( "Comment - Advanced", "", 1062, "^`");how sure are you that this is the ID of the control sleep(500) ControlClick("Comment - Advanced", "OK", 1) sleep(4000) EndFunc First of all, here's the complete code I'm working with: Global $previous, $Paused, $hwndvent Func TitleUpdate() $hwndvent = (HWND(0x000201E6)) ControlClick($hwndvent, "Comment", 1060) sleep(500) ControlFocus( "Comment - Advanced", "", 1062) ControlSend( "Comment - Advanced", "", 1062, "{CTRLDOWN}`{CTRLUP}") sleep(500) ControlClick("Comment - Advanced", "OK", 1) sleep(4000) EndFunc While 1 TitleUpdate() sleep(10000) wend Second of all, as per your notes in my code, I am not completely certain that that is the handle of the window, I didn't know how to find it so I searched for other scripts that referenced hex codes, couldn't find any, and used AutoIt Info to hover over the Ventrilo window, and found a hex code that seemed to be right, put it in, and it worked, at least for opening the comment dialog and putting in text, though obviously not for transmitting hotkeys. As per your second note, I am fairly certain that is the correct ControlID, I again used AutoIt Info and hovered over the box where I wanted the command to be typed, and took down the ControlID from the info page. What do you mean the hotkey conflicts with my application? I guess it's possible you assumed I was doing some sort of hotkey to start the program, this is to be a completely automated program, I want to just turn it on, and leave it to run forever on my computer ;D Thanks for the response. Link to comment Share on other sites More sharing options...
Phate4219 Posted August 17, 2011 Author Share Posted August 17, 2011 Problem Solved. I changed ControlSend and instead did: ControlFocus (not sure if that was neccessary) SendKeepActive Send CTRLDOWN Send ` Send CTRLUP obviously I left the syntax out, but you get the idea. I figured that the pandora player I was using might be commanding focus temporarily to execute the hotkey. Whatever this did, it worked!!! Thanks for your your help. Link to comment Share on other sites More sharing options...
JohnOne Posted August 17, 2011 Share Posted August 17, 2011 For the record $hwndvent = WinActivate("Your Window Title") Should return the handle to your window. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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