Muyfa666 Posted December 4, 2012 Posted December 4, 2012 I've read up some on AutoIt and I know it works wonders many times. I was hoping to create a script that could launch Daemon tools, mount a specific .iso, activate a cloak device and then minimize the whole bunch. Seeing as this will take more than I can do, maybe I'd start with something easier. I'm trying to make the cloaker run, have the key C sent to the program windows (activates cloak) then minimize the window. So far I can't really make it work: ShellExecute("D:\Program\Alcohol 120\ACID.exe") AutoItSetOption("WinTitleMatchMode",2) ControlSend("A.C.I.D","","","{C}") I haven't even gotten to the minimize command yet. The above script starts the right program, I have no idea if it forces focus, and does not send the keypress C. What am I doing wrong here? I have tried my way in the help file, but it's very extensive, and some help on the beginners steps would be very nice...
Mat Posted December 4, 2012 Posted December 4, 2012 Welcome to the forums! You are very close, just a small change to make:With ControlSend, it does not matter whether the window is active (or even visible!), its one of the things that makes AutoIt powerful compared to simple macro tools.Your main problem is that you aren't waiting for the program to start. It may seem instantaneous to you (the time between running the program and a window showing up) but its actually quite a slow process. As a result, you are trying to send C to the window before it has been created, so it doesn't get sent.The solution is to use the WinWait function, which will do exactly what it says on the tin, wait for the window. AutoIt Project Listing
Muyfa666 Posted December 4, 2012 Author Posted December 4, 2012 Ok, so I try this: ShellExecute("D:ProgramAlcohol 120ACID.exe") AutoItSetOption("WinTitleMatchMode",2) WinWait("A.C.I.D","",3000) ControlSend("A.C.I.D","","","C") No error messages, but the C button is not sent like I hope. Nothing happens at all after the program opens. Am I sending the C wrong?
Mat Posted December 5, 2012 Posted December 5, 2012 I'm afraid that's about as much help as I can be without looking at the specifics of the program. This works fine for me: AutoItSetOption("WinTitleMatchMode",2) Run("notepad") WinWait("Notepad") ControlSend("Notepad", "", "", "C") What is the C key actually doing? Is it a hotkey, or typing into an edit? Could you provide a screenshot of the window perhaps, or more information about what sending the C key is actually supposed to do? AutoIt Project Listing
Muyfa666 Posted December 6, 2012 Author Posted December 6, 2012 If I press C at this window, the Cloak is activated. Is it perhaps a hotkey?
tp9191 Posted December 6, 2012 Posted December 6, 2012 (edited) try pasting the exact title (which can be retrieved from the au3 info tool), into the winwait and controlsend. also try sending spacebar or enter if 'cloak' is the default button. lastly, does the 'cloak' button have any class name or anything in th au3 info tool when you hover over it? Edited December 6, 2012 by tp9191
Mat Posted December 6, 2012 Posted December 6, 2012 Looks like Java (Swing or whatever that GUI toolkit is called). If so then you won't be able to find controls. I'd try the suggestions of tp9191 first, and then try to find the client coordinates of that button, and ControlClick the window at that location. Non-windows controls are always a pain. AutoIt Project Listing
Muyfa666 Posted December 6, 2012 Author Posted December 6, 2012 (edited) Still no go. ControlClick Coords is 34, 10. This seem to go way more advanced that I thought very fast... :-) Edited December 6, 2012 by Muyfa666
tp9191 Posted December 6, 2012 Posted December 6, 2012 It's actually quite easy and very similiar to ControlSend...
Muyfa666 Posted December 6, 2012 Author Posted December 6, 2012 ShellExecute("D:ProgramAlcohol 120ACID.exe") WinActive("A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - ") ControlClick("A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - ","",[CLASS:Button],left,1,34,10) Not working. So many symbols, I'm having ahrd time keeping them toghether...
tp9191 Posted December 6, 2012 Posted December 6, 2012 double quotes go around the [class:Button], and "left"ControlClick("A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - ","","[CLASS:Button]","left",1,34,10)
Mat Posted December 6, 2012 Posted December 6, 2012 ShellExecute("D:ProgramAlcohol 120ACID.exe") WinActive("A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - ") ControlClick("A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - ","",[CLASS:Button],left,1,34,10) Not working. So many symbols, I'm having ahrd time keeping them toghether... [CLASS:Button] should be a string I assume you are using SciTE, syntax highlighting is the best way to keep track of everything. Please can you post the output of the AutoIt window info tool when hovered over the button? The usual way to do this is to go to the Summary tab and copy everything. It's not all relevant but at least everyone is on the same page then. You should get something like: expandcollapse popup>>>> Window <<<< Title: Untitled - Notepad Class: Notepad Position: 398, 148 Size: 896, 675 Style: 0x14CF0000 ExStyle: 0x00000110 Handle: 0x00000000003D0F12 >>>> Control <<<< Class: Edit Instance: 1 ClassnameNN: Edit1 Name: Advanced (Class): [CLASS:Edit; INSTANCE:1] ID: 15 Text: Position: 0, 0 Size: 880, 617 ControlClick Coords: 225, 185 Style: 0x50300104 ExStyle: 0x00000200 Handle: 0x00000000003C0932 >>>> Mouse <<<< Position: 631, 383 Cursor ID: 0 Color: 0xFFFFFF >>>> StatusBar <<<< 1: 2: Ln 1, Col 1 >>>> ToolsBar <<<< >>>> Visible Text <<<< >>>> Hidden Text <<<< AutoIt Project Listing
Muyfa666 Posted December 6, 2012 Author Posted December 6, 2012 (edited) Thanks, now the script runs, but the button still does not get clicked. Can it not be done with every programs? Mat: >>>> Window <<<< Title: A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - Class: 20F004A5 Position: 660, 340 Size: 600, 400 Style: 0x14CF0000 ExStyle: 0x00040108 Handle: 0x00000000002C0928 >>>> Control <<<< Class: Button Instance: 1 ClassnameNN: Button1 Name: Advanced (Class): [CLASS:Button; INSTANCE:1] ID: Text: &Cloak Position: 416, 96 Size: 75, 25 ControlClick Coords: 37, 11 Style: 0x50010001 ExStyle: 0x00000000 Handle: 0x0000000000320548 >>>> Mouse <<<< Position: 1122, 485 Cursor ID: 2 Color: 0x000000 >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< &Cloak &Uncloak Safe&Disc 4.x Cloaking SafeDisc 4.x &Intelligent Cloaking &SecuROM 7.x Cloaking Cloaking Options: &Log >>>> Hidden Text <<<< Edited December 6, 2012 by Muyfa666
tp9191 Posted December 6, 2012 Posted December 6, 2012 just copy that entire class line as is: ControlClick("A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - ","","[CLASS:Button; INSTANCE:1]","left",1,34,10)
Mat Posted December 6, 2012 Posted December 6, 2012 From the window and control info, I can't see any reason why it doesn't work. The following should work. ShellExecute("D:ProgramAlcohol 120ACID.exe") WinWait("A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - ") ControlClick("A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - ", "", "[CLASS:Button; INSTANCE:1]", "left", 1, 34, 10) AutoIt Project Listing
Muyfa666 Posted December 6, 2012 Author Posted December 6, 2012 Still no go. Script runs, but the buttons is unpressed. These are the exact lines I use: ShellExecute("D:ProgramAlcohol 120ACID.exe") WinActive("A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - ") ControlClick("A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - ","","[CLASS:Button; INSTANCE:1]","left",1,34,10)
Mat Posted December 6, 2012 Posted December 6, 2012 You should be using WinWait rather than WinActive. WinActive just checks if a window is active, it doesn't do anything in your above code. AutoIt Project Listing
Muyfa666 Posted December 7, 2012 Author Posted December 7, 2012 Bout to give up now... ShellExecute("D:ProgramAlcohol 120ACID.exe") WinWait("A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - ",3000) ControlClick("A.C.I.D v1.2.12110 - Alcohol Soft Customer Release - ","","[CLASS:Button; INSTANCE:1]","left",1,34,10)
tp9191 Posted December 7, 2012 Posted December 7, 2012 haha how did that go unnoticed until now? by the way, are you able to press alt + c to activate the 'cloak' button?
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