Olson Posted February 4, 2014 Posted February 4, 2014 So I'm very new to AutoIt so I'm sure this will be a silly question. In my program that I'd like to automate, when I press ALT-I, this window pops up: What I'd like to do is change whichever is smaller, Width or Height, to 4000. And then I want to change Resolution to 100. How would I go about doing something like this?
Moderators JLogan3o13 Posted February 4, 2014 Moderators Posted February 4, 2014 Hi, Olsen, welcome to the forum. I would suggest beginning with the AutoIt Window Info Tool (Au3Info or Au3Info_X64, in the same directory where you installed AutoIt). This will tell you more about the window and its controls. Hover over the different areas, such as where it is showing the Width and Height, and see if they return Control information on the Control tab. If so, you can then grab that information using the Control commands in the help file (ControlGetText, ControlSetText, etc.). See what you can work out on your own. If you get stuck, feel free to post what you have (even if it isn't working quite right) and we'll do our best to assist. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Olson Posted February 4, 2014 Author Posted February 4, 2014 I was unable to use Help. I'm using Scite as an editor. So far I have: Send("!I") send("z") And then using the cool "Info" program, I learned that: The window title is "Resize" ClassnameNN for Width is AfxWnd421 ClassnameNN for Height is AfxWnd421 So then to find out if I'm on the right track, I tried: HotKeySet("+{F8}","size") Func size() Send("!I") send("z") x=ControlGetText("AfxWnd421") MsgBox(x) EndFunc And then I found out that I'm not providing enough info for ControlGetText, and not sure how to proceed.
AoRaToS Posted February 5, 2014 Posted February 5, 2014 You will need the correct control information. Check what is shown in the "Advanced Mode" section of the Window Info Tool. [autoit]]HotKeySet("+{F8}","size") Func size() Send("!I") $width = ControlGetText("Resize", "", "height");reads the current height, change height with the correct control $height = ControlGetText("Resize", "", "width");reads the current width, change width with the correct control $resolution = ControlGetText("Resize", "", "resolution");reads the current resolution, change resolution with the correct control If $width > $height Then; compare the 2 ControlSetText("Resize", "", "height", "4000");set the height control, change height with the correct control Else ControlSetText("Resize", "", "width", "4000");set the width control, change width with the correct control EndIf If $resolution <> "100.000" Then ControlSetText("Resize", "", "resolution", "100");set the resolution control, change resolution with the correct control ;add other actions "to click ok" etc EndFunc[/autoit] s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3
Olson Posted February 5, 2014 Author Posted February 5, 2014 I don't see an "Advanced Mode" option in the Window Info Tool.
AoRaToS Posted February 5, 2014 Posted February 5, 2014 did you choose the "Control" tab at the bottom? s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3
Olson Posted February 5, 2014 Author Posted February 5, 2014 Ah, there it is. So for Width it is [CLASS:AfxWnd42; INSTANCE:1] and Height is [CLASS:AfxWnd42; INSTANCE:2]
AoRaToS Posted February 5, 2014 Posted February 5, 2014 use those in the code above also get the one for resolution then try it out s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3
AoRaToS Posted February 5, 2014 Posted February 5, 2014 if it works, keep in mind that nothing will happen if both dimensions are the same the way it is now, this can easily be changed. also, from what i see in the screenshot, the dimensions are locked due to the "aspect ratio" being checked i guess, make sure you're able to change the values manually before you try it s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3
Olson Posted February 5, 2014 Author Posted February 5, 2014 In your code it looked like you had an extra bracket in "[autoit]]" So I have it like this: [autoit] HotKeySet("+{F8}","size") Func size() Send("!I") $width = ControlGetText("Resize", "[CLASS:AfxWnd42; INSTANCE:1]", "height");reads the current height, change height with the correct control $height = ControlGetText("Resize", "[CLASS:AfxWnd42; INSTANCE:2]", "width");reads the current width, change width with the correct control $resolution = ControlGetText("Resize", "", "resolution");reads the current resolution, change resolution with the correct control If $width > $height Then; compare the 2 ControlSetText("Resize", "[CLASS:AfxWnd42; INSTANCE:1]", "height", "4000");set the height control, change height with the correct control Else ControlSetText("Resize", "[CLASS:AfxWnd42; INSTANCE:2]", "width", "4000");set the width control, change width with the correct control EndIf If $resolution <> "100.000" Then ControlSetText("Resize", "[CLASS:AfxWnd42; INSTANCE:5]", "resolution", "100");set the resolution control, change resolution with the correct control ;add other actions "to click ok" etc EndFunc [/autoit] And I'm getting the following error: >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Photo Resell\size.au3" C:\Photo Resell\size.au3 (1) : ==> Missing separator character after keyword.: [autoit] [autoit^ ERROR >Exit code: 1 Time: 0.235 I just took out the autoit tags and it compiles but when I try to run the exe it never shows up on my taskbar like all the other scripts.
AoRaToS Posted February 5, 2014 Posted February 5, 2014 put the control info you got where it says "height", "width", "resolution". leave the second parameter as "" like it was... Try to run the script instead of compiling it s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3
AoRaToS Posted February 5, 2014 Posted February 5, 2014 if it still doesn't stay in the taskbar, add this to the bottom of the code While 1 Sleep(100) WEnd s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3
Olson Posted February 5, 2014 Author Posted February 5, 2014 Still won't run. Current code is: ;;[autoit] HotKeySet("{F9}","size") Func size() Send("!I") Send("z") $width = ControlGetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:1]");reads the current height, change height with the correct control $height = ControlGetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:2]");reads the current width, change width with the correct control $resolution = ControlGetText("Resize", "", "resolution");reads the current resolution, change resolution with the correct control If $width > $height Then; compare the 2 ControlSetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:1]", "4000");set the height control, change height with the correct control Else ControlSetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:2]", "4000");set the width control, change width with the correct control EndIf If $resolution <> "100.000" Then ControlSetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:5]", "100");set the resolution control, change resolution with the correct control ;add other actions "to click ok" etc EndFunc ;;[/autoit]
LongBowNZ Posted February 5, 2014 Posted February 5, 2014 (edited) $resolution = ControlGetText("Resize", "", "resolution");reads the current resolution, change resolution with the correct control ------------------------------------------------^ You probably need to get the class and instance instead of "resolution". Just like you did with the other two. Edited February 5, 2014 by LongBowNZ
Olson Posted February 5, 2014 Author Posted February 5, 2014 I thought I set resolution to "[CLASS:AfxWnd42; INSTANCE:5]" in my above code.
AoRaToS Posted February 5, 2014 Posted February 5, 2014 try adding the while loop at the end, check my previous post! also, in the ControlSetText commands the controls are in the wrong order, let me explain: you want to change whichever is smaller so if width is bigger than height you want to change height so it would be [CLASS:AfxWnd42; INSTANCE:2] and the other one should be instance 1. or you can change > to < s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3
LongBowNZ Posted February 5, 2014 Posted February 5, 2014 I thought I set resolution to "[CLASS:AfxWnd42; INSTANCE:5]" in my above code. You did on line 15 but not on the ControlGetText function on what looks like line 9.
Olson Posted February 5, 2014 Author Posted February 5, 2014 Getting so close. Height and Resolution are correct but Width is still null. Current code: ;;[autoit] HotKeySet("{F9}","size") Func size() Send("!I") Send("z") $width = ControlGetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:1]");reads the current height, change height with the correct control msgbox("tvt","Hello",$width) $height = ControlGetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:2]");reads the current width, change width with the correct control msgbox("tvt","Hello",$height) $resolution = ControlGetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:5]");reads the current resolution, change resolution with the correct control msgbox("tvt","Hello",$resolution) If $width > $height Then; compare the 2 ControlSetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:1]", "4000");set the height control, change height with the correct control Else ControlSetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:2]", "4000");set the width control, change width with the correct control EndIf If $resolution <> "100.000" Then ControlSetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:5]", "100");set the resolution control, change resolution with the correct control ;add other actions "to click ok" etc EndFunc ;;[/autoit] While 1 Sleep(100) WEnd Thank you so much for holding my hand through this.
BrewManNH Posted February 5, 2014 Posted February 5, 2014 Do you have height and width backwards? The comments after the 1st $width line say "reads the current height", and the comments after $height say width. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
LongBowNZ Posted February 5, 2014 Posted February 5, 2014 (edited) ;;[autoit] HotKeySet("{F9}","size") Func size() Send("!I") Send("z") $width = ControlGetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:1]");reads the current width, change width with the correct control msgbox("tvt","Hello",$width) $height = ControlGetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:2]");reads the current height, change height with the correct control msgbox("tvt","Hello",$height) $resolution = ControlGetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:5]");reads the current resolution, change resolution with the correct control msgbox("tvt","Hello",$resolution) If $width < $height Then; compare the 2 ControlSetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:1]", "4000");set the width control, change width with the correct control Else ControlSetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:2]", "4000");set the height control, change height with the correct control EndIf If $resolution <> "100.000" Then ControlSetText("Resize", "", "[CLASS:AfxWnd42; INSTANCE:5]", "100");set the resolution control, change resolution with the correct control ;add other actions "to click ok" etc EndFunc ;;[/autoit] While 1 Sleep(100) WEnd I changed the comparison from > to < and made the comments match the code. See if this works. EDIT: Do you need to send "z" after "alt+i", if not, you should get rid of Send("z") Edited February 5, 2014 by LongBowNZ
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