LarryDalooza Posted August 1, 2008 Share Posted August 1, 2008 (edited) I had a need for this... so I whipped it up wit quickness... Thought I'd post it before I lose or delete it... expandcollapse popupMsgBox(4096,"","This clicks ""Cancel"" on my Run dialog") ; Invoke Run Dialog Send("#r") WinWait("Run") ; Wait 3 sec and tell you what I am about to do ToolTip("CLICKING RUN DIALOG CANCEL BUTTON") Sleep(3000) ; WinGetControlFromClientPosition( <Title>, <Text>, <Left of Control>, <Right>, <Width>, <Height> ) ; position info comes from Window Info Tool set to Options/Coord Mode/Client ; click the Control tab and use Position for left,right and Size for width,height $hwnd = WinGetControlFromClientPosition("Run","",174,114,75,23) ControlClick("","",$hwnd) Func WinGetControlFromClientPosition($title,$text,$left,$right,$width,$height) Local $control,$controls,$ctrl,$i,$pos Local $opt = Opt("PixelCoordMode",2) $controls = @LF & WinGetClassList($title,$text) While StringLen(StringReplace($controls,@LF,"")) $control = StringLeft($controls,StringInStr($controls,@LF,0,2)) $i = 0 While StringInStr($controls,$control) $i += 1 $ctrl = StringTrimRight(StringTrimLeft($control,1),1) & $i $pos = ControlGetPos($title,$text,$ctrl) If $pos[0] = $left And $pos[1] = $right And $pos[2] = $width And $pos[3] = $height Then Opt("PixelCoordMode",$opt) Return ControlGetHandle($title,$text,$ctrl) EndIf $controls = StringReplace($controls,$control,@LF,1) WEnd WEnd Opt("PixelCoordMode",$opt) EndFunc Lar. edit: Reset PixelCoord before returning. Edited August 2, 2008 by LarryDalooza AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 1, 2008 Share Posted August 1, 2008 That is like _ControlGetHandleByPos() with less code and more parameters. Good job Larry! .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
martin Posted August 2, 2008 Share Posted August 2, 2008 (edited) I had a need for this... so I whipped it up wit quickness... Thought I'd post it before I lose or delete it... Need to reset the PixelCoordMode before returning. expandcollapse popupMsgBox(4096,"","This clicks ""Cancel"" on my Run dialog") ; Invoke Run Dialog Send("#r") WinWait("Run") ; Wait 3 sec and tell you what I am about to do ToolTip("CLICKING RUN DIALOG CANCEL BUTTON") Sleep(3000) ; WinGetControlFromClientPosition( <Title>, <Text>, <Left of Control>, <Right>, <Width>, <Height> ) ; position info comes from Window Info Tool set to Options/Coord Mode/Client ; click the Control tab and use Position for left,right and Size for width,height $hwnd = WinGetControlFromClientPosition("Run","",174,114,75,23) ControlClick("","",$hwnd) Func WinGetControlFromClientPosition($title,$text,$left,$right,$width,$height) Local $control,$controls,$ctrl,$i,$pos Local $opt = Opt("PixelCoordMode",2) Local $Result = 0 $controls = @LF & WinGetClassList($title,$text) While StringLen(StringReplace($controls,@LF,"")) $control = StringLeft($controls,StringInStr($controls,@LF,0,2)) $i = 0 While StringInStr($controls,$control) $i += 1 $ctrl = StringTrimRight(StringTrimLeft($control,1),1) & $i $pos = ControlGetPos($title,$text,$ctrl) If $pos[0] = $left And $pos[1] = $right And $pos[2] = $width And $pos[3] = $height Then $Result = ControlGetHandle($title,$text,$ctrl) ExitLoop 2 EndIf $controls = StringReplace($controls,$control,@LF,1) WEnd WEnd Opt("PixelCoordMode",$opt) Return $Result EndFunc[/autoit] Lar. Edited August 2, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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