sgebbie Posted December 18, 2009 Posted December 18, 2009 When using the ControlSend command, is it possible to still use it without knowing the window title first? If so, how would you go about doing that? If not, is there any workaround that you could use if the window titles you are going to be working with are random? Say I have computer A locked and computer B locked. I want to send commands to windows behind the lock but I won't know what those windows specifically are or what the window titles are. I have already written the code to determine what is running by checking services, although I won't be able to tell how many of what type. I'm not too familiar with the Control commands yet so there may be soemthing I'm missing here.
spudw2k Posted December 18, 2009 Posted December 18, 2009 (edited) Use WinList() to obtain a list of Window Names, and Use WinGetClassList() to retrieve controls. edit: I'm not sure how well the Win commands work though when running on a locked desktop. Edited December 18, 2009 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
PsaltyDS Posted December 18, 2009 Posted December 18, 2009 ControlSend() works fine on the locked desktop, provided you don't need any window to be in the "ACTIVE" state. For example WinGetTitle() will work, but WinWaitActive() will not. You can specify the window by any of the advanced methods in help file under "Window Titles and Text (Advanced)". 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
sgebbie Posted December 18, 2009 Author Posted December 18, 2009 Thanks for the quick replies. I was doing some testing with the examples for some of the commands in the AutoIt Help. I got it to where it appears to be working but I'm not really understanding the output or how to get what I'm looking to get. Does there always have to be an active window? Here is what I was messing with. I used this somewhat off of the example that was listed in help. $title = WinGetTitle("[active]") WinGetTitle(["active"]) MsgBox(0, "Full title read was:", $title) I'm not sure if I'm using the command correctly but it returns a value of "Program Manager". I feel kinda dumb I don't know what that is.. I'm thinking that my best course of action for this would be to tie in a WinList to provide a list of windows that match a classname and possibly go from there? On a side note I was trying to fiddle with a basic function to ControlSend to a Word doc and it failed to send. It worked fine in the notepad example but failed to write any text to Word. Sorry for the amount of questions. I am reguarly searching the forums and the web for Q/A to this stuff before I post. Seems I'm a bit further behind than most that have questions about stuff
PsaltyDS Posted December 18, 2009 Posted December 18, 2009 With the desktop locked you get "" (null title) for "[ACTIVE]". "Program Manager" indicates the unlocked desktop has focus. 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
sgebbie Posted December 18, 2009 Author Posted December 18, 2009 With the desktop locked you get "" (null title) for "[ACTIVE]". "Program Manager" indicates the unlocked desktop has focus. Ahhh that makes plenty of sense. Thanks for that. Can you by chance explain this piece of code in really simple terms? I'm having some trouble understanding what does what. I understand parts and other parts I'm complely lost as to what it's actually doing. This might help me understand other things a little better as well. $var = WinList() For $i = 1 to $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1]) EndIf Next Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc I understand the basics with comment boxes, variables, Func, some of the If statements, and parts of the message box. Mostly the words such as Details,Title and Handle. The code inbetween has me a little lost as to why this or that works and what makes it work. Hopefully if you can break this piece down for me it will make the other stuff I'm trying to learn make more sense.
PsaltyDS Posted December 18, 2009 Posted December 18, 2009 Because no title or advanced specification is passed to WinList(), it returns an array of ALL windows. The loop walks through the array and tests each window to see if it has a title and is visible. That visible test is done by the IsVisible() function, which gets the window handle passed to it and tests the Visible bit in the windows state (bit 1 set = 2). For more help, you need to ask more specific questions. 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
sgebbie Posted December 18, 2009 Author Posted December 18, 2009 Because no title or advanced specification is passed to WinList(), it returns an array of ALL windows. The loop walks through the array and tests each window to see if it has a title and is visible. That visible test is done by the IsVisible() function, which gets the window handle passed to it and tests the Visible bit in the windows state (bit 1 set = 2). For more help, you need to ask more specific questions. I think I'm starting to get some of this finally. So this starts with WinList() without an additional specification here --> () and as you said returns the array of All windows. Next the For... to ... Next - It looks to me like this part is using the For $i = 1 to $var[0][0] to use the $i variable for the count, starting the initial variable value of $i to 1, then using $var[0][0] as the number of windows returned and the For loop will end once it reaches the stop threshold which should equal the $var[0][0] which is the total number of windows generated by the array from WinList? Am I on the right track now? If that's not correct can you please tell me where I'm off? Thanks for your continued help with this.
PsaltyDS Posted December 19, 2009 Posted December 19, 2009 Read the help file entry for those functions, especially WinList(). Add #include <Array.au3> to the top of your script and put _ArrayDisplay($var, "WinList") right below the the WinList(). That will show you what you're working 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
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