Expansion Posted February 12, 2011 Share Posted February 12, 2011 Hi, I need some help to get started with AutoIT. I'm looking to develop a script that would automate a Win32 app. I want it to retrieve specific subitems from ListViews, close tabs, click on ListView's headers, etc. I looked for a tutorial, but each time I found only ones that taught me how to create a GUI that had those elements (ListViews, tabs, etc). Can you point me out some quick start tutorials for GUI Automation with AutoIT? The one that shows how to start the Notepad, is not enough. I need something that covers areas like, handlers, messages, notifications, etc. For example, in Perl, I found this tutorial as a starting point http://www.piotrkaluski.com/files/winguitest/docs/ch02s04.html and I've written a few scripts, but I hit a dead end with sending a LVN_COLUMNCLICK notification under Win7 x64. I could not make it work at all, even though it worked fine under WinXP x86 and x64. So, I've decided that I have to try something else, too. Link to comment Share on other sites More sharing options...
guinness Posted February 12, 2011 Share Posted February 12, 2011 (edited) Welcome to the Forum! I would suggest looking at the Help File for >> ControlCommand() (you might have done this from what you said) & then Search the Forum using ControlCommand() as the keyword, there are a lot of Examples. Trust me I never use AutoIt for Automtaion but ControlGetHandle() might help and ControlGetText() too. Good Luck! Plus, ControlListView() might be of some use. Edited February 12, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
sdraw107 Posted February 13, 2011 Share Posted February 13, 2011 As guinness suggested, the helpfile is an excellent place to learn what you need to know. If you go to the contents, you'll see a folder named "Window Management". That contains a sub-folder named "Controls". Pretty much everything you've asked about is covered by a function within that folder. Additionally, you can use the AutoIt Window Info tool to figure out what type of controls are on any given Win32 application, as well as information you can use to identify and target those controls (assuming they are standard WinAPI controls). Link to comment Share on other sites More sharing options...
Expansion Posted February 13, 2011 Author Share Posted February 13, 2011 Thank you, guys. I've managed to get things started. ..but I've stopped here: $return=_GUICtrlToolbar_ClickButton($hWnd, $iCommandID) $return=_GUICtrlToolbar_ClickIndex($hWnd, $iIndex) Neither of these commands does click on a specific button from a ToolbarWindow32 pointed by $hWnd. For $iIndex and $iCommandID identification I used KaFu's script: Any ideas? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 13, 2011 Moderators Share Posted February 13, 2011 (edited) Thank you, guys.I've managed to get things started...but I've stopped here:$return=_GUICtrlToolbar_ClickButton($hWnd, $iCommandID)$return=_GUICtrlToolbar_ClickIndex($hWnd, $iIndex)Neither of these commands does click on a specific button from a ToolbarWindow32 pointed by $hWnd.For $iIndex and $iCommandID identification I used KaFu's script:Any ideas?You ask "Any Ideas", yet so many specifics are left out, specifically what app you're trying to automate ( not as important though as some type of actual runnable/recreation code ).Here's an "educated guess". Your $hWnd is either A.) Not a handle or B.) Not the handle to the toolbar ( eg. the param explanation: Handle to the control ).More interesting than not though, is how this skipped from a listview issue to a toolbar one. Edited February 13, 2011 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Expansion Posted February 13, 2011 Author Share Posted February 13, 2011 (edited) In order to have a listview, I have to press some buttons, and fill some fields. I'll get to the listview, too. Here's the code, I've tried it on 3 different apps that contained ToolbarWindow32 resources. I've pasted the handle manually. You can try it on WordPad(didn't work for me), if there are no mistakes in my code. Btw, I need a function like FindWindowEx, is there a similar thing in AutoIT? I need to work with handles, children windows, parent windows, controlID's, etc because there are many windows that have the same title. #include <GUIConstantsEx.au3> #Include <GuiToolBar.au3> Opt('MustDeclareVars', 1) Example() Func Example() dim $hWnd=HWnd(0x003D09C2) dim $iIndex=1 dim $return=_GUICtrlToolbar_ClickIndex($hWnd, $iIndex) MsgBox(4096, "return is", $return) EndFunc Edited February 13, 2011 by Expansion Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 13, 2011 Moderators Share Posted February 13, 2011 (edited) Btw, I need a function like FindWindowEx, is there a similar thing in AutoIT?I need to work with handles, children windows, parent windows, controlID's, etc because there are many windows that have the same title.WinGetHandle()ControlGetHandle()?Edit:I'm using Win7 since I assume that's where you had problems.Opening WordPad, I don't see where it has ToolbarWindow32 ( I see a ribbon type control )? Edited February 13, 2011 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Expansion Posted February 13, 2011 Author Share Posted February 13, 2011 (edited) The idea is to be able to search for child windows, when you specify the handle for the parent window. Can I do that with those functions? I'm asking because help shows the following: WinGetHandle ( "title" [, "text"] ) ControlGetHandle ( "title", "text", controlID ) LE: It seems that I can specify handles as titles, so, yes these are what I was looking for. Thank you. Btw, I've tried this code for sorting a listview according to a header column, but it did not work, either. #Include <GuiListView.au3> Example() Func Example() $hWnd=0x000608D8 $iCol=2 _GUICtrlListView_SortItems($hWnd, $iCol) EndFunc I forgot to mention that I am working in a VM at the moment, in WinXP x86, and WordPad has ToolbarWindow32 resources. New, Save, Print, etc. Edited February 13, 2011 by Expansion Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 13, 2011 Moderators Share Posted February 13, 2011 Expansion,From the Help file page for _GUICtrlListView_SortItems:"For use only in conjunction with _GUICtrlListView_RegisterSortCallBack"Did you use that function in your script? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Expansion Posted February 13, 2011 Author Share Posted February 13, 2011 I've tried this, and it did not work: #Include <GuiListView.au3> Example() Func Example() $hWnd=0x000608D8 $iCol=2 _GUICtrlListView_RegisterSortCallBack($hWnd) _GUICtrlListView_SortItems($hWnd, $iCol) _GUICtrlListView_UnRegisterSortCallBack($hWnd) EndFunc Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 13, 2011 Moderators Share Posted February 13, 2011 I used Win 7's Explorer ( first thing I saw with a toolbarwindow32 ). If you open up an explorers window in Win 7, and go to the libraries dir, the below worked for me. #include <GUIConstantsEx.au3> #include <GUIToolbar.au3> ; Open an explorer window in the in the libraries dir Global $gh_wnd = WinGetHandle("[CLASS:CabinetWClass;TITLE:Libraries]") If Not $gh_wnd Then MsgBox(16 + 262144, "Error", "Window does not exist") Exit EndIf WinActivate($gh_wnd) ; A pause so you can see it happen Sleep(2000) Global $gh_toolbar_url = ControlGetHandle($gh_wnd, "", "[CLASS:ToolbarWindow32; INSTANCE:2]") If Not $gh_toolbar_url Then MsgBox(16 + 262144, "Error", "Toolbar does not exist") Exit EndIf _GUICtrlToolbar_ClickIndex($gh_toolbar_url, 0) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 13, 2011 Moderators Share Posted February 13, 2011 (edited) I've tried this, and it did not work: #Include <GuiListView.au3> Example() Func Example() $hWnd=0x000608D8 $iCol=2 _GUICtrlListView_RegisterSortCallBack($hWnd) _GUICtrlListView_SortItems($hWnd, $iCol) _GUICtrlListView_UnRegisterSortCallBack($hWnd) EndFunc Remember these control functions take the "Controls" ( Child Window ) handle, not the parent. Also, you're passing an integer not an hwnd, I'm not 100% sure if that affects it, but I'm always careful to pass what is required. Edited February 13, 2011 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Expansion Posted February 13, 2011 Author Share Posted February 13, 2011 There is a SysListView32, that has a SysHeader32 that has a number of columns/items. I want to sort the listview according to one of those columns. Which handle should I use for _GUICtrlListView_SortItems($hWnd, $iCol) ? The handle of the SysListView or the handle of the SysHeader? I can't get any information about the header's items using Window Info. Link to comment Share on other sites More sharing options...
Expansion Posted February 13, 2011 Author Share Posted February 13, 2011 With this code and the handle for the listview: #Include <GuiListView.au3> Example() Func Example() $hWnd=HWnd(0x000608D8) $iCol=1 _GUICtrlListView_RegisterSortCallBack($hWnd) _GUICtrlListView_SortItems($hWnd, $iCol) _GUICtrlListView_UnRegisterSortCallBack($hWnd) EndFunc This is what it happens[instead of sorting by Size, it shows that greyed arrow, and it keeps the Filename arrow]: 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