Jump to content

Search the Community

Showing results for tags 'controls'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Member Title




Found 19 results

  1. I'm trying to have a left side edit control display line numbers (line numbers control) for a right side edit control (edit control). The issue is when resizing the edit control having the line numbers control resize properly in height. (NOT a keeping the controls in sync Q.) Hold down the left mouse button and resize vertically and horizontally and you'll see the effect (the line number control height changes differently than the edit control). Then when you release the mouse button the program does the resizing. I thought setting the GUICtrlSetResizing would do it, but it does not. I've had to resort to checking the edit control height and then using ControlMove to adjust the line numbers control height (_ResizeLN()) in the While 1 loop. I've tried putting the _ResizeLN() in the Func WM_SIZE but it does not seem to be working properly (plus I probably am doing something dumb). My questions are: Q1) Is there a way to get the line numbers control to height resize just like the edit control using GUICtrlSetResizing? Q2) If not Q1) then is there a way using Func WM_SIZE? The reason I ask is because I hate to check every time in the While 1 loop for a possible height adjustment of the line numbers control. #AutoIt3Wrapper_run_debug_mode=Y ;use this to debug in console window <--- LOOK ; Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration ;v3ai - trying to add line numbers on left #include <Debug.au3> ;for _DebugArrayDisplay #include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <GuiStatusBar.au3> ;for status bar #include <WindowsConstants.au3> Global $g_hGUI, $g_hStatus Global $g_iOldLineNum = 0, $g_iLineNum = 1 ;init values Global $g_hEdit, $g_aPos_hEdit Global $g_hLNEdit, $g_aPos_hLNEdit Global $iBorderWidth = 4 _SetUpWindows() ;set up GUI, Edit, and StatusBar ;has GUISetState(@SW_SHOW, $g_hGUI) _MAINLoop() ;main loop Exit Func _SetUpWindows() $g_hGUI = GUICreate("My GUI", 800, 570, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX), BitOR($WS_EX_CLIENTEDGE, $WS_EX_ACCEPTFILES)) ;handle GUISetBkColor(0x00f000, $g_hGUI) ;window background green 0x00f000 so see individual controls ;--- Create status bar and Set parts Local $aParts[3] = [150, 300, -1] ;right edge of 1st part at 75, 2nd at 150, 3rd = -1 meaning right edge extends to the border of the window ;v2gq need more room for Line: xxxxxx / yyyyyy $g_hStatus = _GUICtrlStatusBar_Create($g_hGUI) _GUICtrlStatusBar_SetParts($g_hStatus, $aParts) _GUICtrlStatusBar_SetText($g_hStatus, "Line: xx", 0) ;& _GUICtrlEdit_LineFromChar($g_hEdit, -1) + 1) ;+1 as Zero based _GUICtrlStatusBar_SetText($g_hStatus, "Part 2", 1) ;"Part 2", 1) _GUICtrlStatusBar_SetText($g_hStatus, "Part 3", 2) ;"Part 3", 2) ;--- Create Edit Control in rest of window area Local $aClientSize = WinGetClientSize($g_hGUI) ;[0] = Width of window's client area ;[1] = Height of window's client area Local $iStatusBarHeight = _GUICtrlStatusBar_GetHeight($g_hStatus) ;get actual height in case changed above ;Pause("$iStatusBarHeight = '" & $iStatusBarHeight & "'") ;we get 17 which is not correct - need to account for border on status bar also $iStatusBarHeight = $iStatusBarHeight +1 ;<-- border touches +2 ;<-- leaves a border 1 pixel Local $iMFF = 5 ;manual fudge factor Local $iWE = $aClientSize[0]-(2*$iBorderWidth) ;Width of Edit Local $iHE = ($aClientSize[1]-(2*$iBorderWidth)) - $iStatusBarHeight - $iMFF ;Height of Edit ;Manual Fudge Factor $g_hEdit = GUICtrlCreateEdit("", $iBorderWidth + 100, $iBorderWidth, $iWE - 100, $iHE, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_NOHIDESEL)) ;control ID GUICtrlSetResizing($g_hEdit, $GUI_DOCKBORDERS) ;control will grow as the window GUICtrlSetBkColor($g_hEdit,0xFFFFFF) ;0xFCD299 ;0xB9700A ;0xFDB44E ;0xffa500) GUICtrlSetColor($g_hEdit,0x000000) ;text color GUICtrlSetFont($g_hEdit, 10, 400, 0, "Courier New") ;monospace font _GUICtrlEdit_SetLimitText($g_hEdit, -1) ;now Set parts in status bar Local $sMsg = "Line: " & (_GUICtrlEdit_LineFromChar($g_hEdit, -1) + 1) & " / " & _GUICtrlEdit_GetLineCount($g_hEdit) ;+1 as Zero based _GUICtrlStatusBar_SetText($g_hStatus, $sMsg, 0) ;+1 as Zero based ;Part 0 to show Line: ;looks like I need to dynamically scale the height on resizing? - do in While 1 loop Global $g_hLNEdit = GUICtrlCreateEdit("1234567", $iBorderWidth, $iBorderWidth, 70, $iHE, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN)) ;control ID ;works GUICtrlSetResizing($g_hLNEdit, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKWIDTH)) GUICtrlSetBkColor($g_hLNEdit,0xFCD299) GUICtrlSetColor($g_hLNEdit,0x0000ff) ;text color GUICtrlSetFont($g_hLNEdit, 10, 400, 0, "Courier New") ;change default font _GUICtrlEdit_SetLimitText($g_hLNEdit, -1) Local $i, $sMsg = "", $sI For $i = 1 To 2345 ;build up a string for testing $sI = StringRight(" " & $i, 7) $sMsg = $sMsg & $sI&@CRLF ;need right justified, since monospace prefix with spaces " " Next _GUICtrlEdit_SetText($g_hLNEdit, $sMsg) ;display GUISetState(@SW_SHOW, $g_hGUI) ;--- Let's show our creation GUIRegisterMsg($WM_SIZE, "WM_SIZE") EndFunc ;Func _SetUpWindows() Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) ;Resize the status bar when GUI size changes ;_ResizeLN() ;resize $g_hLNEdit based on $g_hEdit ;does not always fully adjust so keep in While1 loop _GUICtrlStatusBar_Resize($g_hStatus) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func _ResizeLN() ;Local $dHRatio ;decimal Height ratio Local $aPos_hEdit = ControlGetPos("", "", $g_hEdit) ;$a[0] = X position, $a[1] = Y position, $a[2] = Width, $a[3] = Height ;_DebugArrayDisplay($aPos_hEdit, "$aPos_hEdit") Local $aPos_hLNEdit = ControlGetPos("", "", $g_hLNEdit) ;_DebugArrayDisplay($aPos_hLNEdit, "$aPos_hLNEdit") ;$dHRatio = $aPos_hEdit[3] / $aPos_hLNEdit[3] ;Pause("$dHRatio = '" & $dHRatio & "'") ;this is all very interesting but we want them the same height so redraw $g_hLNEdit if needed if $aPos_hLNEdit[3] <> $aPos_hEdit[3] Then ;redraw/move ;recall Global $g_hLNEdit = GUICtrlCreateEdit("1234567", $iBorderWidth, $iBorderWidth, 70, $iHE, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN)) ;control ID ;works ;GUICtrlCreateEdit ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] ) ;show what we're doing Local $sStatus = "Edit Window height = '" & $aPos_hEdit[3] & "'" & @CRLF & _ "Line Window height = '" & $aPos_hLNEdit[3] & "'" & @CRLF ControlSetText("", "", $g_hEdit, $sStatus ) ;show status - use handle to directly address it ;~ Pause("Click to adjust.") ;GUICtrlSetPos($aPos_hLNEdit, $iBorderWidth, $iBorderWidth, 70, $aPos_hEdit[3]) ;does not seems to resize vertically ControlMove("", "", $g_hLNEdit, Default, Default, 70, $aPos_hEdit[3]) ;WORKS! EndIf EndFunc ;Func _ResizeLN() Func _MAINLoop() Local $nMsg, $aMsg, $iReturn, $sMsg ;MAIN loop START While 1 ;Do everything inside this loop while the program is running. $aMsg = GUIGetMsg(1) ;Check what's happening in the GUI $nMsg = $aMsg[0] ;now I know that there is just 1 GUI so I can just use [0] ;skip checking if no event If $nMsg <> 0 Then ;we have a message so Switch $nMsg ;Check for GUI events Case $GUI_EVENT_CLOSE Exit ;program Case Else ;Pause("$nMsg = '" & $nMsg & "'") ;do nothing as some negative values used for other purposes EndSwitch ;End running through GUI events. EndIf ;---- do these always ---- ;Sleep(20) ;Not really needed since GUIGetMsg() has a built-in delay. ;possibly update Line: $g_iLineNum = _GUICtrlEdit_LineFromChar($g_hEdit, -1) ;get current line, Zero based If $g_iOldLineNum <> $g_iLineNum Then ;it's changed $g_iOldLineNum = $g_iLineNum ;so update $sMsg = "Line: " & $g_iLineNum + 1 & " / " & _GUICtrlEdit_GetLineCount($g_hEdit) ;+1 as Zero based _GUICtrlStatusBar_SetText($g_hStatus, $sMsg, 0) ;Part 0 to show Line: EndIf ;check to see if resizing occurred for possible dynamic adjustment of Line Number Edit box ;probably need to learn to do this in Func WM_SIZE _ResizeLN() WEnd ;End main body loop ;MAIN loop END EndFunc ;Func _MAINLoop() Func Pause($text="") ;__scrolltext("Debug: Paused " & $text & @CRLF) MsgBox(262144, "DEBUG", "Paused: " & $text) EndFunc ;Func Pause($text="")
  2. Hi all, The more projects I work on, the harder it is to find old scripts I created with certain techniques in them. I'd like to leave this here for others to get an idea from and it will be available now by keyword searching in this forum. This project needed an evenly distributed button grid setup on a touch screen with half decent sized buttons and spacing so the user would be less likely to press the key beside it. Here is one quick example to give anyone an idea of a way to handle it. #include <GUIConstants.au3> GUICreate("Button Grid", 1080, 100) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box ;--Create and Position Controls Dim $btnActivated[1][2] ;Col 1 is button id, Col 2 is True/False used in 1 example as depressed Dim $btnArray[100][2] ;Col 1 is button id, Col 2 is True/False used in 1 example as depressed $num = 0 $btnActivated[0][0] = GUICtrlCreateButton("Activated", 0, 0, 100, 100) ;x,y,w,h $btnActivated[0][1] = True GUICtrlSetBkColor(-1,0x00ff00) GUICtrlSetColor(-1,0x005500) GUICtrlSetFont(-1,14) For $Y = 0 To 1 For $X = 0 To 7 ConsoleWrite( ($X * 100) + ($X*20) + 120 & @CRLF) If $Y=0 Then $btnArray[$num][0] = GUICtrlCreateButton($num + 1, ($X * 100) + ($X*20) + 120, 0, 100, 40) ;x,y,w,h Else $btnArray[$num][0] = GUICtrlCreateButton($num + 1, ($X * 100) + ($X*20) + 120, ($Y * 40) + $Y*20, 100, 40) ;x,y,w,h EndIf GUICtrlSetBkColor($btnArray[$num][0], 0xFFFFFF) $num += 1 Next Next ;--Set Button Names GUICtrlSetData($btnArray[0][0],"Autoit") GUICtrlSetData($btnArray[1][0],"Is") GUICtrlSetData($btnArray[2][0],"Cool") ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $btnActivated[0][0] $btnActivated[0][1] = NOT $btnActivated[0][1] If $btnActivated[0][1] Then GUICtrlSetBkColor($btnActivated[0][0],0x00ff00) GUICtrlSetColor($btnActivated[0][0],0x005500) GUICtrlSetData($btnActivated[0][0],"Activated") GUICtrlSetFont($btnActivated[0][0],14) Else GUICtrlSetBkColor($btnActivated[0][0],0xFF9999) GUICtrlSetColor($btnActivated[0][0],0x550000) GUICtrlSetData($btnActivated[0][0],"DeActivated") GUICtrlSetFont($btnActivated[0][0],13) EndIf Case $btnArray[0][0] If $btnActivated[0][1] Then MsgBox(0,"Notice","Btn1",1) EndIf Case $btnArray[1][0] If $btnActivated[0][1] Then MsgBox(0,"Notice","Btn2",1) EndIf Case $btnArray[2][0] If $btnActivated[0][1] Then MsgBox(0,"Notice","Btn3",1) EndIf EndSwitch WEnd I couldn't find one of my old projects that broke the button array into more columns that included the actual button name in the field. Feel free to share your own or share a more flexible version of this simple example.
  3. Hello, I'm trying to write a script to allow pause / resume of Dropbox syncing; so that Dropbox syncing can be scheduled. So the idea is that the script will emulate what a user would normally do by clicking on Dropbox on the System Tray and then the script will toggle the sync operation If Dropbox currently syncing, will pause If syncing currently paused, will resume I'm writing this script for Windows 10 I am able to open Dropbox from the System Tray, but I can't figure out how to enumerate the controls. I would have been happy with the "simple" approach of using the Autoit Window Info tool to manually identify the values for the control. But unfortunately as soon as I click on the Finder Tool the Dropbox window closes. I then tried enumerating the controls with my script. I have experimented with a couple of scripts that others have shared, which while they don't error; don't return any values for the Controls. So at the moment I'm stuck and I'm after some ideas Is there a way to use a Windows Viewer tool with an app like Dropbox that doesn't remain visible? (I had a quick look but could not find a solution) If I need to enumerate the controls myself, here is my current script. I'm using _EnumChildWindows from here #include <Array.au3> #include <GuiToolBar.au3> #include <_EnumChildWindows.au3> Local $hSysTray_Handle Local $hWnd="",$hControl=0,$sTitle=0,$sClass=0,$aEnumList Local $hNumber1Button=-1,$hNumber4Button=-1,$hPlusButton=-1,$hEqualButton=-1 $sSearchtext='Dropbox' $iButton=Get_SysTray_IconText($sSearchtext) _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iButton, "left", False, 1) ; MsgBox (64,'Searched Button','Button: '&$iButton&@CRLF&'Instance: '&@extended) If WinActivate($hSysTray_Handle, "") Then ; MsgBox($MB_SYSTEMMODAL, "", "Dropbox Window activated") ; Check Dropbox status - Either: ; 'Up to date' (i.e. syncing) ; 'Syncing paused' (paused) $hWnd = $hSysTray_Handle ; Important to wait for the window to fully 'create' itself before getting child windows! ; Note that other processes that become activated somewhere between WinWait and this will cause WinWaitActive() to wait for manual activation ;WinWaitActive($hWnd) ; bad idea in busy environment Sleep(3000) WinActivate($hWnd) ; this seems to be a better alternative, the window seems fully created after this is called in my tests ; Parameters to function ;$hControl=HWnd(0x########) ;$sTitle="^(\d|\+|=)$" ; PCRE - gets controls with numbers, + or = sign only (problem: no instance #'s!) ;$sClass="Button" $aEnumList=_EnumChildWindows($hWnd,$hControl,$sTitle,$sClass) ;,2) for RegExp Title If @Error Then Exit ; Find specific items [Certain versions of Calc won't return any text] For $i=1 to $aEnumList[0][0] Switch $aEnumList[$i][4] Case "1" $hNumber1Button=$aEnumList[$i][0] ConsoleWrite("'1' Advanced Mode Name (in current state): [CLASS:Button; INSTANCE:"&$aEnumList[$i][3]&"]"&@CRLF) Case "4" $hNumber4Button=$aEnumList[$i][0] ConsoleWrite("'4' Advanced Mode Name (in current state): [CLASS:Button; INSTANCE:"&$aEnumList[$i][3]&"]"&@CRLF) Case "+" $hPlusButton=$aEnumList[$i][0] ConsoleWrite("'+' Advanced Mode Name (in current state): [CLASS:Button; INSTANCE:"&$aEnumList[$i][3]&"]"&@CRLF) Case "=" $hEqualButton=$aEnumList[$i][0] ConsoleWrite("'=' Advanced Mode Name (in current state): [CLASS:Button; INSTANCE:"&$aEnumList[$i][3]&"]"&@CRLF) EndSwitch Next ; Add Headers $aEnumList[0][0]="Handle" $aEnumList[0][1]="Classname" $aEnumList[0][2]="Control ID" $aEnumList[0][3]="Iteration" $aEnumList[0][4]="Title/Text" ; Bring the window forward WinActivate($hWnd) ; Perform a simple calculation to show interaction If $hNumber1Button<>-1 Then ControlClick($hWnd,"",$hNumber1Button,"primary",3) ControlClick($hWnd,"",$hNumber4Button) Sleep(1000) ControlClick($hWnd,"",$hPlusButton) Sleep(1000) ControlClick($hWnd,"",$hNumber4Button,"primary",2) ; double click, but that's fine Sleep(1000) ControlClick($hWnd,"",$hEqualButton) EndIf ; And Display ALL Enumerated Windows _ArrayDisplay($aEnumList,"Enumerated controls for App") Else MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "Error", "Dropbox Window not activated") EndIf Func Get_SysTray_IconText($sSearch) For $i = 1 To 99 ; Find systray handles $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:' & $i & ']') ; ConsoleWrite ("Handle: " & $hSysTray_Handle & @CRLF) If @error Then ;MsgBox(16, "Error", "System tray not found") ExitLoop EndIf ; Get systray item count Local $iSysTray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) ConsoleWrite("iSysTray_ButCount: " & $iSysTray_ButCount & @CRLF ) If $iSysTray_ButCount = 0 Then ;MsgBox(16, "Error", "No items found in system tray") ContinueLoop EndIf Local $aSysTray_ButtonText[$iSysTray_ButCount] ; Look for wanted tooltip For $iSysTray_ButtonNumber = 0 To $iSysTray_ButCount - 1 ConsoleWrite("iSysTray_ButtonNumber: " & $iSysTray_ButtonNumber & " Button_Text: " & _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSysTray_ButtonNumber) & @CRLF ) If $sSearch= StringLeft(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSysTray_ButtonNumber),StringLen($sSearch)) Then ConsoleWrite("Button Text: " & $sSearch & " Handle: " & $hSysTray_Handle & " Button Number: " & $iSysTray_ButtonNumber & @CRLF) Return SetError(0, $i, $iSysTray_ButtonNumber) EndIf Next Next Return SetError(1, -1, -1) EndFunc ;==>Get_SysTray_IconText Thanks, VW
  4. hello sirs, i've created a tool to the blind users, this tool helps the blind to listen to a audio effect when moving between the GUIs controls on they computers where this tool can get the class for the current focus control and play a sound from a folder i've added all the knowne classes, but i found some problems i hope any one can help me. this is the code that i created #include <WinAPISys.au3> Global $h_CurrentHWNDFocus = "", $h_CurrentControlHWNDFocus = "" AdlibRegister("WindowAudioFocus", 50) Func WindowAudioFocus() Local $h_NewHWNDFocus = WinGetHandle("[active]", "") Local $h_NewControlHWNDFocus = ControlGetFocus($h_NewHWNDFocus, "") If ($h_NewHWNDFocus = $h_CurrentHWNDFocus) And ($h_NewControlHWNDFocus = $h_CurrentControlHWNDFocus) Then Return 0 AdlibUnRegister("WindowAudioFocus") If Not ($h_NewHWNDFocus = $h_CurrentHWNDFocus) Then SoundPlay(@ScriptDir & "\focus_Audio\WindowChanged.wav") Else Switch _WinAPI_GetClassName(ControlGetHandle($h_NewHWNDFocus, "", $h_NewControlHWNDFocus)) Case "Button", "Start", "TrayButton", "TrayShowDesktopButtonWClass", "sbutton", "CirrussButton", "ODbcButton", "ThunderRTCommandButton", "ThunderSSOption", "ThunderSSCommand", "ThunderCommandButton", "ThunderRT6CommandButton", "ThunderRT5CommandButton", "TButton", "TBitBtn", "TAdvGlowButton", "ButtonWndClass", "afx:0:376:baa946", "_AOL_Button" If _IsCheckBox(ControlGetHandle($h_NewHWNDFocus, "", $h_NewControlHWNDFocus)) Then SoundPlay(@ScriptDir & "\focus_Audio\checkBox.wav") ElseIf _IsRadio(ControlGetHandle($h_NewHWNDFocus, "", $h_NewControlHWNDFocus)) Then SoundPlay(@ScriptDir & "\focus_Audio\radio.wav") Else SoundPlay(@ScriptDir & "\focus_Audio\button.wav") EndIf Case "ComboBox", "ComboBoxEx32", "MSOBALLOONREComboBox20W", "REComboBox20W", "ThunderComboBox", "ThunderDriveListBox", "ThunderRT6ComboBox", "TORComboEdit", "TCombobox", "TComboBoxEx", "TORComboBox", "TColorBox", "TNFComboBox", "Internet Explorer_TridentCmbobx", "ComboWndClass", "_AOL_ComboBox", "ThunderRT5ComboBox", "ComboLBox" SoundPlay(@ScriptDir & "\focus_Audio\list.wav") Case "Edit", "SearchBox", "TChatRichEdit", "_WwN", "_WwO", "RichEdit20A", "RichEdit20WPT", "RICHEDIT60W", "OKttbx", "RichEditA", "ThunderTextBox", "ThunderRT6TextBox", "ThunderRT5TextBox", "TEdit", "TRichEdit", "TRichEditViewer", "TMemo", "TInplaceEditList", "TLabeledEdit", "TMaskEdit", "TDateTimePicker", "TRichEdit", "TCaptionMemo", "TAddictRichEdit", "TCaptionEdit", "RichTextWndClass", "TextWndClass", "PasswordWndClass", "TextAreaWndClass", "MSWorksDoc", "_AOL_Edit", "SysDateTimePick32" SoundPlay(@ScriptDir & "\focus_Audio\edit.wav") Case "ListBox", "ComboLBox", "REListBox20W", "SUPERGRID", "OUTEXVLB", "WMSUIVLB", "SchdmapiVLB", "VLBClass", "ThunderDirListBox", "ThunderFileListBox", "ThunderListBox", "ThunderRT6ListBox", "ThunderRT5ListBox", "TListbox", "TValueListEditor", "TORCalendar", "TColorListBox", "TCheckListBox", "Internet Explorer_TridentLstBox", "ListBoxWndClass", "ListWndClass", "hh_kwd_vlist", "afx:8:376:0:946", "_AOL_ListBox", "_AOL_Tree", "" SoundPlay(@ScriptDir & "\focus_Audio\List.wav") Case "SysListView32", "OpenListView", "wuDuiListView", "ListView20WndClass", "TcxGridSite", "TListView", "TSystemListView", "ListViewWndClass", "" SoundPlay(@ScriptDir & "\focus_Audio\ListView.wav") Case "SysTreeView32", "SearchTreeList", "FeatureTree", "TreeView20WndClass", "TSystemTreeView", "TTreeView", "" SoundPlay(@ScriptDir & "\focus_Audio\TreeView.wav") Case Else SoundPlay(@ScriptDir & "\focus_Audio\focus.wav") EndSwitch EndIf $h_CurrentHWNDFocus = $h_NewHWNDFocus $h_CurrentControlHWNDFocus = $h_NewControlHWNDFocus AdlibRegister("WindowAudioFocus", 50) Return 1 EndFunc ;==>WindowAudioFocus Func _IsCheckBox($ctrl_hwnd) $Style = _WinAPI_GetWindowLong($ctrl_hwnd, $GWL_STYLE) Return BitAND($Style, $BS_CHECKBOX) = $BS_CHECKBOX EndFunc ;==>_IsCheckBox Func _IsRadio($ctrl_hwnd) $Style = _WinAPI_GetWindowLong($ctrl_hwnd, $GWL_STYLE) Return BitAND($Style, $BS_AUTORADIOBUTTON) = $BS_AUTORADIOBUTTON EndFunc ;==>_IsRadio what i need from you is : play a sound when a menu item focus, that sound named menu.wav play a sound named items.wav when the users move on list box items or list view or treeview items or a combobox items please if can any one help me i'll very happy thanks on advance
  5. I have the impression that the traditional method for processing responses to a GUI is to assign variables to each GUICreateButton (or Pic) and then use Switch/Case/Endswitch to detect when any Control is clicked. In the tutorials I've seen about Koda it appears to use this method, too. While 1 Global $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Pic2 Call("verizon") Case $Pic3 Call("skype") Case $PicExit Exit EndSwitch WEnd But in a few examples I've seen a script use a different method. The script always includes the following option near the top: Opt("GUIOnEventMode", 1) ...and then, later, after creating each Control for the GUI, there's the function, GUICtrlSetOnEvent. In these cases a very simple While/WEnd loop is used to wait for the user to respond. I happened to employ this second method in a recent script where I used "canned" controls (checkbox and buttons). Later in the same script I used the GuiCreatePic and Switch/Case/EndSwitch method because my GUI was all custom images. (I'm not sure if that's necessary, but it's what I've deduced.) The second GUI failed to respond to any mouse clicks, but eventually I figured out the cause was the GUIOnEvenMode being enabled at the top of the script. This is when I realized I don't understand the reasoning behind choosing between these two methods. And I'm having no luck phrasing an appropriate search criterion. Is there an overview somewhere that explains the two methods and -- most importantly -- describes when each is appropriate?
  6. Hi! I have a button where I need to close it! I was doing through clicking same position in screen but there are some id's that have different sizes. What are the possible ways to click this closable button? Is there a way to close it through id? Is there a way to get it's position through it's ID? Thanks in advance!
  7. Ahoy Autoit Community! After many trials and errors I am unable to solve a problem I am facing and would appreciate any kind of input or better yet a solution The Premise: An embeded slideshow viewer that runs after double-clicking an item in a ListView (each item will generate a different slideshow images). The Setup: GUI with a ListView Control and a simple exit button. The Issue: Once double clicked the slide plays however the GUI "locks"/non responsive until the slide is over. Same thing if I click on the "Test" button. The Culprit: I believe since it's in the images loop it can't accept any other commands until that loop is over. The Wish: I want to be able to use the GUI functions (selecting other items, clicking on button etc.) while the slideshow plays. The Code (stripped and simplified as much as I could): #include <GuiListView.au3> #include <File.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) HotKeySet("{Esc}", "_Exit") Global $c=0 Global $ssGDI[3], $ssGraphic[2], $ssImage Global Const $bg_color = "000000" Global Const $ssW = 480, $ssH = 320 Global $aFiles = _FileListToArrayRec("d:\testStage\", "*.jpg;*.png;*.bmp;*.gif;*.JPG;*.PNG;*.BMP;*.GIF", $FLTAR_FILES, $FLTAR_NORECUR ,$FLTAR_SORT ,$FLTAR_FULLPATH ) $guiW = 1200 $guiH = 726 $mainWindow = GUICreate("Slideshow Viewer", $guiW, $guiH, -1, -1, $WS_POPUP) $Button1 = GUICtrlCreateButton("Exit", 0, 0, 50, 50) GUICtrlSetOnEvent($Button1, "_Exit") $Button1 = GUICtrlCreateButton("Test", 60, 0, 50, 50) GUICtrlSetOnEvent($Button1, "Test") Global $ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280) _GUICtrlListView_SetColumnWidth ($ListView, 0, 100) _GUICtrlListView_SetColumnWidth ($ListView, 1, 100) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlCreateListViewItem("Name 1|Category 1", $ListView) GUICtrlCreateListViewItem("Name 2|Category 2", $ListView) screenshotWidgetInit($ssW,$ssH, 690, 100) GUISetState(@SW_SHOW, $mainWindow) GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Exit() EndSwitch WEnd Func Test() For $k = 1 To UBound($aFiles) - 1 screenshotWidgetTransition($aFiles[$k]) Next EndFunc Func ListView_Click() ConsoleWrite("Left Click") EndFunc Func ListView_DoubleClick() ConsoleWrite("Double Left Click") Test() EndFunc Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $ListView Select Case $event = $NM_CLICK ListView_Click () Case $event = $NM_DBLCLK ListView_DoubleClick () EndSelect EndSelect Return $GUI_RUNDEFMSG EndFunc Func screenshotWidgetTransition($image, $delay = 0, $speed = 1, $sleep = 2000) Local $a, $d = $c, $iX, $iY $ssImage = _GDIPlus_ImageLoadFromFile($image) $iX = _GDIPlus_ImageGetWidth($ssImage) $iY = _GDIPlus_ImageGetHeight($ssImage) $FDesktop=$ssH/$ssW $Fact =1 If $iX > $ssW And $FDesktop > ($iY/$iX) Then $Fact=$ssW/$iX ElseIf $iY > $ssH Then $Fact=$ssH/$iY EndIf $H1 = Round(($Fact * $iY),0) $W1 = Round(($Fact * $iX),0) _GDIPlus_GraphicsDrawImageRect($ssGraphic[$d], $ssImage,($ssW - $W1)/2, ($ssH - $H1) / 2,$W1,$H1) WinSetTrans($ssGDI[$d], "", 0) WinSetOnTop($ssGDI[$d], "", 1) For $a = 0 To 254 Step $speed WinSetTrans($ssGDI[$d], "", $a) Sleep($delay) Next WinSetTrans($ssGDI[$d], "", 254) WinSetOnTop($ssGDI[Not ($d)], "", 0) WinSetTrans($ssGDI[Not ($d)], "", 0) _GDIPlus_GraphicsClear($ssGraphic[Not ($d)]) $c = 1 - $d _GDIPlus_ImageDispose ($ssImage) ; very important to realease the pics Sleep($sleep) EndFunc ;==>screenshotWidgetTransition Func screenshotWidgetInit($ssW,$ssH,$ssX,$ssY) $ssGDI[2] = GUICreate("", $ssW, $ssH, $ssX, $ssY, $WS_POPUP, $WS_EX_MDICHILD, $mainWindow) $ssGDI[0] = GUICreate("", $ssW, $ssH, 3, 3, $WS_POPUP, $WS_EX_MDICHILD, $ssGDI[2]) $ssGDI[1] = GUICreate("", $ssW, $ssH, 3, 3, $WS_POPUP, $WS_EX_MDICHILD, $ssGDI[2]) ; GUISetBkColor("0x" & $bg_color, $ssGDI[2]) GUISetState(@SW_SHOW, $ssGDI[2]) GUISetState(@SW_SHOW, $ssGDI[0]) GUISetState(@SW_SHOW, $ssGDI[1]) WinSetTrans($ssGDI[0], "", 0) WinSetTrans($ssGDI[1], "", 0) _GDIPlus_Startup() $ssGraphic[0] = _GDIPlus_GraphicsCreateFromHWND($ssGDI[0]) $ssGraphic[1] = _GDIPlus_GraphicsCreateFromHWND($ssGDI[1]) _GDIPlus_GraphicsClear($ssGraphic[0], "0xFF" & $bg_color) _GDIPlus_GraphicsClear($ssGraphic[1], "0xFF" & $bg_color) EndFunc ;==>screenshotWidgetInit Func _Exit() _GDIPlus_ImageDispose($ssImage) _GDIPlus_GraphicsDispose($ssGraphic[0]) _GDIPlus_GraphicsDispose($ssGraphic[1]) GUIDelete($ssGDI[0]) GUIDelete($ssGDI[1]) GUIDelete($ssGDI[2]) _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit I hope someone can shed light on this; perhaps a different approach is needed? Thank you in advance! P.S. The script is patched from different scripts of different users in the forum - thank you again users!
  8. I have a super simple login screen I'm trying to access that is written in java. My java testing tools can't access the login screen because it's a modal window. So I figured I'd see if AutoIt can manipulate 'something' on it. I can enter text within the text boxes for user name and password. But I can't see to click on the login button. I've tried just tabbing to it and hitting the enter key (as I really wouldn't have to be completely interacting with the frame). But that didn't work. I was hoping to throw it some coordinates and just double click in that relative area, but when I get the whole " ==> Subscript used on non-accessible variable.:" when I attempt to use ControlGetPos() I'm assuming because it can't truly interact with the Java frame. So I'm kind of stuck here...can't use AutoIt, can't use a Java automation testing tool to do this due to the modal issues. Does anyone have any ideas? My code is below though I think it's less to do with code and more what AutoIt can and can't do. #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Local $hWnd = WinActivate("[CLASS:sunawtframe]", "Login") Local $aPos = ControlGetPos($hWnd, "[CLASS:SUNAWTFRAME]", "Login") Local $myXPos = $aPos[0] + 420 Local $myYPos = $aPos[1] + 270 Send("guest") Send("{TAB}") Send("guest") Send("{TAB}") ;Tried Control Click it failed ControlClick($hWnd, "", "Login") ;Tried Mouse Click and that failed MouseClick("Left", $myXPos, $myYPos, 2) Thanks for any help!
  9. Hi all, i was currently working with html when i got myself the question if there is a windows control that acts like a html container e.g. a div with the hidden attribute. The benfeit is obvious. You can put code in this container and at the moment it is hidden it doesnt take room but when i got visible it uses the room it needs. Is there something i can use with windows forms? Normally one have to recalculate the position of all controls and adjust them manually.
  10. Hi all, This code is from an IronPython project. self._button1.Click += self.Button1_Click self._button1.MouseHover += self.Button1_MouseHover def Button1_Click(self, sender, e): System.Windows.Forms.MessageBox.Show("Hi you clicked me ?") pass def Button1_MouseHover(self, sender, e): sender.Text = "Mouse Entered" pass How easy to connect any event function to any control. I know AutoIt can do this with GUICtrlSetOnEvent function. But this function only takes control ID and function name as parameters. We can't tell AutoIt to act on which event. And for some events, we needs to use GUIRegisterMsg in order to respond some specific messages. My question is --- Is it possible to do this IronPython way in AutoIt ?
  11. Hi all, I have a form with 15 textboxes. I need to set all of them disabled when i press a button. So i decided to use a loop. But how can i do it. Any idea ?
  12. #include <Array.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> ; Proof of concept for using the control id as an index item for an array. I created back on 8th April 2013. Example() Func Example() ; Create the GUI. Local $iHeight = 400, $iWidth = 400 Local $hGUI = GUICreate('', $iWidth, $iHeight) GUISetState(@SW_SHOW, $hGUI) ; Declare variables to be used throughout the example. Local Const $BUTTON_ROWS_COLUMNS = 8 Local Enum $eCTRL_HWND, $eCTRL_VALUE, $eCTRL_MAX Local $aMsg[1][$eCTRL_MAX], _ $iButtonHeight = $iHeight / $BUTTON_ROWS_COLUMNS, _ $iButtonWidth = $iWidth / $BUTTON_ROWS_COLUMNS, _ $iControlID = 0 For $i = 0 To $BUTTON_ROWS_COLUMNS - 1 For $j = 0 To $BUTTON_ROWS_COLUMNS - 1 $iControlID = GUICtrlCreateButton($i & ',' & $j, $i * $iButtonWidth, $j * $iButtonHeight, $iButtonWidth, $iButtonHeight, $BS_CENTER) ; Increase the size of the array if the control id is greater than or equal to the total size of the array. If $iControlID >= UBound($aMsg) Then ReDim $aMsg[Ceiling($iControlID * 1.3)][$eCTRL_MAX] EndIf ; Add to the array. $aMsg[$iControlID][$eCTRL_HWND] = GUICtrlGetHandle($iControlID) $aMsg[$iControlID][$eCTRL_VALUE] = 'Sample string for the control id: ' & $iControlID Next Next ; Clear empty items after the last created control id. ReDim $aMsg[$iControlID + 1][$eCTRL_MAX] ; Display the array created. _ArrayDisplay($aMsg) Local $iMsg = 0 While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $aMsg[$eCTRL_HWND][$eCTRL_HWND] To UBound($aMsg) ; If $iMsg is greater than 0 and between the 0th index of $aMsg and the last item then display in the console. If $iMsg > 0 Then ConsoleWrite('Control Hwnd: ' & $aMsg[$iMsg][$eCTRL_HWND] & ', ' & $aMsg[$iMsg][$eCTRL_VALUE] & @CRLF) EndIf EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example
  13. Hello, recently I have started writing up automation scripts in visual studio. These scripts require me to know the (name) field in the properties of controls written in vb6. My idea here is to open up the screen in vb6, I won't have the code checked out so i wont have to worry about altering it. Some how cycle through the screen and record the (name) property for each control. The controls are named in a way that I should know if i need them or not. (ex. fraFrame1 wouldn't be needed because its a frame while txtTextbox1 will be needed for me to enter data into it) Once I have all the fields I will be testing, I would want autoit to use those (name)'s to put in as much of the script as possible on my Visual Studio test files. After the mindless part of the testfile is done then I can do the small specifics on my own. So the main issue I have right now is just starting out, I can't think of a way to actually select the controls in vb6 and pull out what is marked in the (name) field. On top of that I have another idea but getting the name is priority 1. If that was figured out I could maybe figure out how to also check for additional properties. Any help on this would be great... i know it sounds more confusing than it actually is since I am not great at explaining things. Edit: Might have found a way around checking the actual screen for controls then looking at the Properties section of the screen. It seems I could just open the .ctl file as a text file and run through the document looking for keywords. Not 100% how that will work, I would probably want to search the whole document for any (name) properties starting with wte/txt/cbo/wde/mle then save those names into an array? So when I want to dump the data into a new document I could just do a For Each for the items that make up the array. Let me know if this sounds like something that might work.
  14. Looking to build a TreeView dynamically from an Array (Array built from excel sheet) Have not made the excel sheet yet, so I'm open to suggestions on layout so as to make it easiest as possible to get it into a treeview. Thinking each row could be a item to add with the columns defining the placement in the trees, Like: Cells(1,1) = "Level 1 Parent Name" Cells(1,2) = "Level 2 Parent Name" Cells(1,3) = "Level 3 Parent Name" Cells(1,4) = "Add this item" Cells(1,5) = "" When value = "" then Create entire branch or any part of it that doesn't already exist. advance to next row For processing speed I'd probably want to work with an array, like: $aExcelData = _ExcelReadSheetToArray($oExcel,2,1,$LastUsedRow,$LastUsedCol) Can someone help me with the loop? or maybe point to tool that may do this?
  15. r2dak


    Version beta


    Gives you Power controls on taskbar in window 8 ____r2dak (Frustrated Window 8 User)
  16. Hi Folks, maybe this is a stupid question, but anyway here it goes. I have a Script in GUI mode running on event mode. I also have a variable number of buttons the user may press. This is an example of how I'm doing it right now: Dim $aButtons[4] Opt("GUIOnEventMode", 1) GUICreate("MyGUI", 800, 600, -1, -1, BitOr($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME, $WS_MAXIMIZEBOX)) GuiSetOnEvent($GUI_EVENT_CLOSE, "ClickClose") _CreateButtons(4) GUISetState(@SW_SHOW) While 1 Sleep(1000) WEnd Func _CreateButtons($iAmount) Local $x, $y For $i = 1 To $iAmount $aButtons[$i] = GUICtrlCreateButton("Button " & $i, 10 + $i * 50, 30 + $y, 40, 40) GuiCtrlSetOnEvent(-1, "ClickButton" & $i) If $i >= $iAmount / 2 Then $y = 70 Next EndFunc Func ClickClose() Exit EndFunc Func ClickButton1() _ClickedButton(1) EndFunc Func ClickButton2() _ClickedButton(2) EndFunc Func ClickButton3() _ClickedButton(3) EndFunc Func ClickButton4() _ClickedButton(4) EndFunc Func _clickedButton($id) ConsoleWrite("Well, now you've clicked on " & $id & @CRLF) EndFunc The "problem" is that I need to create a function for each button, which I believe is suboptimal. The amount of available buttons is configurable over an ini file, so it's not hard-coded as in the example. Any hint is appreciated.
  17. So I'm making this gui with an embedded IE object. It all goes well until I add some functionality, one in particular and it's a big one, the window will be in the same place and same size as you left it when you last exited the program. No big deal until I found that when I resize the window programmatically the controls below the IE Object seemingly disappear. Look a little closer and I find that they're not invisible, just white. I messed around and found out that it has something to do with having the style $WS_CLIPCHILDREN on the gui. I take it off and the controls show up no problem, but then the whole IE object freezes so that's definitely not the solution I'm looking for. I've tried searching the forums, the internet, and the help file, but I can't find the answer to this evil problem. One thing I noticed was that if I resized the window just the slightest with the mouse all the controls would reappear, or if I hovered on them they parts of the control would reappear piece by piece. So I tried using some window redraw / repaint functions, I've tried several different winmove functions, and I even went so far as to try to emulate resizing the window through the mouse by using the _SendMessage function to send the individual WM_ENTERSIZEMOVE, WM_SIZING, WM_SIZE, and WM_EXITSIZEMOVE messages to the window, but to no avail. However if I set a certain size of window with the WM_SIZE message that wasn't the window size it would show up in the window with a bunch of whitespace because it wasn't taking up the whole window, but that isn't germane and I digress. If anyone knows any rerendering messages I could send the the window please post them here! I'm willing to try anything at the moment. I assume there's a message I'm missing in the resizing emulation since it isn't coming out right. Oh, another thing that would be helpful is if someone knew how to monitor all the messages going to my gui, instead of just specific individual messages defined by the GUIRegisterMsg function. Below is a far shortened example of my code along with the screen shot of it with a few citations. #include <IE.au3> #include <Array.au3> #include <WinAPI.au3> #include <Constants.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $name = @UserName $opts = " |Me ("&$name&")" $oIE = _IECreateEmbedded() $Main = GUICreate("Example of Frustration", 795, 610, 192, 124, BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX,$WS_THICKFRAME,$WS_CLIPCHILDREN)) $ObjectIE = GUICtrlCreateObj($oIE, 8, 8, 777, 561) GUICtrlSetResizing(-1, $GUI_DOCKTOP+$GUI_DOCKRIGHT+$GUI_DOCKBOTTOM+$GUI_DOCKLEFT) GUICtrlCreateLabel("Follow", 8, 580, 34, 17, $WS_CLIPSIBLINGS) GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKBOTTOM+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $ComboFollow = GUICtrlCreateCombo("", 48, 578, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL,$WS_CLIPSIBLINGS)) $default = " " GUICtrlSetData(-1, $opts, $default) GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKBOTTOM+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $SliderOpacity = GUICtrlCreateSlider(280, 576, 150, 25) GUICtrlSetLimit(-1, 255, 55) GUICtrlSetData(-1, 255) GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKBOTTOM+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $ButtonFullscreen = GUICtrlCreateButton("Faux Fullscreen", 680, 576, 107, 25, $WS_CLIPSIBLINGS) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT+$GUI_DOCKBOTTOM+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) _IENavigate($oIE, "http://google.com") GUISetState(@SW_SHOW) _WinAPI_MoveWindow($Main, 100, 100, 450, 350) While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd Thanks for your time! -Brian
  18. I'm trying to automate some things utilizing both firefox and chrome and a flash website. I would like to know the best and fastest way to correctly identify the flash control (and instance) for both browsers. Here is the code that I use now. I had to remove the instance checking because it wasn't identifying anything. Called in every loop of the main program: Func CheckHWnd($HWnd, $Call) Local $size = WinGetPos($HWnd) Select Case (Not IsArray($size) Or Not IsDeclared($size[3])) Or $HWnd = "" Call($Call) Return Case Else If ($size[2] <> 1024 Or $size[3] <> 820) Then Call($Call) EndSelect EndFunc ;==>CheckHWnd The above function will call either of these functions: Func GetFireFox() Local $classlist = StringSplit(WinGetClassList($Title_Firefox, ""), @LF, 2) Local $PluginWindows = _ArrayFindAll($classlist, "GeckoPluginWindow") For $flash = 0 To (UBound($PluginWindows) - 1) Local $str = "[CLASS:GeckoPluginWindow]" Local $FFC = ControlGetHandle($Title_Firefox, "", $str) Local $posi = WinGetPos($FFC, "") If ($posi[2] = 1024) Then $FF_Pos = $posi $FireFoxCtrl = $FFC Return $FFC EndIf Next Return $FireFoxCtrl EndFunc ;==>GetFireFox Func GetChrome() Local $classlist = StringSplit(WinGetClassList($Title_Chrome, ""), @LF, 2) Local $PluginWindows = _ArrayFindAll($classlist, "NativeWindowClass") For $flash = 0 To (UBound($PluginWindows) - 1) Local $str = "[CLASS:NativeWindowClass]" Local $CHC = ControlGetHandle($Title_Chrome, "", $str) Local $posi = WinGetPos($CHC, "") If ($posi[2] = 1024) Then $CH_Pos = $posi $ChromeCtrl = $CHC Return $CHC EndIf Next Return $ChromeCtrl EndFunc ;==>GetChrome I use the returned HWnd pointer in both direct drawing and in these functions: Func FirefoxClick($x, $y) ControlClick("", "", $FireFoxCtrl, "primary", 1, $x, $y) EndFunc ;==>FirefoxClick Func ChromeClick($x, $y) ControlClick("", "", $ChromeCtrl, "primary", 1, $x, $y) EndFunc ;==>ChromeClick The direct drawing (a cross and text, found in these forums) and the clicking work correctly, when the pointer is valid. But, say, when the window in chrome is refreshed and the flash plugin instance is incremented. It doesn't return the correct pointer at all. If you know of any ways to optimize this code, or correctly identify the instance number, I would much appreciate it.
  19. _EnumChildWindows Enumerate controls/children of a Window This code enumerates all controls/children of a given Window and returns them in an array. Example code is included. *small change 9/15/2010: removed a #include line from the example code posted here (not required)*update 3/28/2010:Control ID is now retrieved. Unfortunately the indexing was reworked (sorry). But at least now I believe all the relevant information needed is retrieved.Parameters to the function now have a slightly different meaning. Basically, this was done to allow searching for controls with an empty-string for a Title. All defaults are now 0, so a call can be made like this to find all Controls with a 'Button' classname: _EnumChildWindows($hWnd,0,0,"Button") #include <_EnumChildWindows.au3> ; =============================================================================================================================== ; <TestEnumChildWindows.au3> ; ; Test for _EnumChildWindows UDF. ; ; Author: Ascend4nt ; =============================================================================================================================== ; =================================================================================================================== ; TEST ; =================================================================================================================== #include <Array.au3> Local $hWnd="",$hControl="",$sTitle="",$sClass="",$aEnumList Local $iCalcPID,$hNumber1Button=-1,$hNumber4Button=-1,$hPlusButton=-1,$hEqualButton=-1 $iCalcPID=Run("calc.exe") If @error Then Exit $hWnd=WinWait("Calculator") If $hWnd=0 Then Exit ProcessClose($iCalcPID) ; Important to wait for the window to fully 'create' itself before getting child windows! ; Note that other processes that become activated somewhere between _WinWaitEx and this will cause WinWaitActive() to wait for manual activation ;WinWaitActive($hWnd) ; bad idea in busy environment WinActivate($hWnd) ; this seems to be a better alternative, the window seems fully created after this is called in my tests ; Parameters to function ;$hControl=HWnd(0x########) ;$sTitle="^(\d|\+|=){:content:}quot; ;$sClass="Button" $aEnumList=_EnumChildWindows($hWnd,$hControl,$sTitle,$sClass) ;,2) for RegExp Title If @Error Then Exit ProcessClose($iCalcPID) ; Find specific items [Certain versions of Calc won't return any text] For $i=1 to $aEnumList[0][0] Switch $aEnumList[$i][3] Case "1" $hNumber1Button=$aEnumList[$i][0] ConsoleWrite("'1' Advanced Mode Name (in current state): [CLASS:Button; INSTANCE:"&$aEnumList[$i][2]&"]"&@CRLF) Case "4" $hNumber4Button=$aEnumList[$i][0] ConsoleWrite("'4' Advanced Mode Name (in current state): [CLASS:Button; INSTANCE:"&$aEnumList[$i][2]&"]"&@CRLF) Case "+" $hPlusButton=$aEnumList[$i][0] ConsoleWrite("'+' Advanced Mode Name (in current state): [CLASS:Button; INSTANCE:"&$aEnumList[$i][2]&"]"&@CRLF) Case "=" $hEqualButton=$aEnumList[$i][0] ConsoleWrite("'=' Advanced Mode Name (in current state): [CLASS:Button; INSTANCE:"&$aEnumList[$i][2]&"]"&@CRLF) EndSwitch Next ; Add Headers $aEnumList[0][0]="Handle" $aEnumList[0][1]="Classname" $aEnumList[0][2]="Iteration" $aEnumList[0][3]="Title/Text" ; Bring the window forward WinActivate($hWnd) ; Perform a simple calculation to show interaction If $hNumber1Button<>-1 Then ControlClick($hWnd,"",$hNumber1Button,"primary",3) ControlClick($hWnd,"",$hNumber4Button) Sleep(1000) ControlClick($hWnd,"",$hPlusButton) Sleep(1000) ControlClick($hWnd,"",$hNumber4Button,"primary",2) ; double click, but that's fine Sleep(1000) ControlClick($hWnd,"",$hEqualButton) EndIf ; And Display ALL Enumerated Windows _ArrayDisplay($aEnumList,"Enumerated controls for 'Calculator'") ProcessClose($iCalcPID)Download the ZIP from my site Ascend4nt's AutoIT Code License agreement: While I provide this source code freely, if you do use the code in your projects, all I ask is that: If you provide source, keep the header as I have put it, OR, if you expand it, then at least acknowledge me as the original author, and any other authors I creditIf the program is released, acknowledge me in your credits (it doesn't have to state which functions came from me, though again if the source is provided - see #1)The source on it's own (as opposed to part of a project) can not be posted unless a link to the page(s) where the code were retrieved from is provided and a message stating that the latest updates will be available on the page(s) linked to.Pieces of the code can however be discussed on the threads where Ascend4nt has posted the code without worrying about further linking.
  • Create New...