WhiteAngel Posted April 2, 2012 Share Posted April 2, 2012 Hello. I'm trying to automate flash application when browser is minimized. Flash is shown as control (e.g. "GeckoPluginWindow" for FireFox), so I'm using Control commands (ControlClick). Everything was working great, until I faced the situatuion when I need to do drag inside this control. So, I need: 1. Trigger LMB down at (x11, x21) 2. Move cursor to (x21, x22) 3. Trigger (release) LMB up at (x21, x22) I was trying to do this using "system32.dll"(PostMessage): it do works with the browset buttons, but it doesn't want to do any action inside flash window (control). Is there any way to do drag inside the control or to do drag in the flash when browser window is minimized? P.S. I would be appreciated if anyone can explain how ControlClick function works (what libraries does it use, e.t.c), so I can try to do drag myself. Link to comment Share on other sites More sharing options...
JohnOne Posted April 2, 2012 Share Posted April 2, 2012 There is no such Autoit functionality. Care to show your use of system32,dll to do a drag on a browser button? That would help a bit. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
WhiteAngel Posted April 3, 2012 Author Share Posted April 3, 2012 (edited) Here's the function I tried to do drag, using "system32.dll" expandcollapse popupFunc _PostMessage_ClickDrag($hWnd, $X1, $Y1, $X2, $Y2, $Button = "left", $Delay = 50) AutoItSetOption("WinDetectHiddenText", 1) AutoItSetOption("WinSearchChildren", 1) AutoItSetOption("WinTitleMatchMode", 2) Local $MK_LBUTTON = 0x0001 Local $WM_LBUTTONDOWN = 0x0201 Local $WM_LBUTTONUP = 0x0202 Local $MK_RBUTTON = 0x0002 Local $WM_RBUTTONDOWN = 0x0204 Local $WM_RBUTTONUP = 0x0205 Local $WM_MOUSEMOVE = 0x0200 ;Getting handler for window $Wns = WinList($hWnd) ;ControlClick($hWnd, "", "[CLASS:GeckoPluginWindow; INSTANCE:1]", "left", 1, $X1, $Y1) If Not IsHWnd($hWnd) And $hWnd <> "" Then $hWnd = WinGetHandle($hWnd) EndIf ConsoleWrite("Windows: " & $Wns[1][0] & @CRLF) ConsoleWrite("Handle: " & $hWnd & @CRLF) If Not IsHWnd($hWnd) Then Return SetError(1, "", False) EndIf If Not IsInt($X1) Or Not IsInt($Y1) Then Return SetError(2, "", False) EndIf If Not IsInt($X2) Or Not IsInt($Y2) Then Return SetError(3, "", False) EndIf If StringLower($Button) == "left" Then $Button = $WM_LBUTTONDOWN $Pressed = 1 ElseIf StringLower($Button) == "right" Then $Button = $WM_RBUTTONDOWN $Pressed = 2 ElseIf StringLower($Button) == "middle" Then $Button = $WM_MBUTTONDOWN $Pressed = 10 If $Delay == 10 Then $Delay = 100 EndIf $coord = PixelSearch( 0, 0, 1200, 900, 0x74691D ) If Not @error Then MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1]) EndIf $User32 = DllOpen("user32.dll") If @error Then Return SetError(4, "", False) #cs DllCall($User32, "bool", "PostMessage", "hwnd", $hWnd, "int", $MK_LBUTTON, "int", "0", "long", _MakeLong($X1, $Y1)) Sleep($Delay / 2) DllCall($User32, "bool", "PostMessage", "hwnd", $hWnd, "int", $Button+1, "int", "0", "long", _MakeLong($X1, $Y1)) #ce DllCall($User32, "bool", "PostMessage", "hwnd", $hWnd, "int", $Button, "int", "0", "long", _MakeLong($X1, $Y1)) If @error Then Return SetError(5, "", False) Sleep($Delay / 2) DllCall($User32, "bool", "PostMessage", "hwnd", $hWnd, "int", $WM_MOUSEMOVE, "int", $Pressed, "long", _MakeLong($X2, $Y2)) If @error Then Return SetError(6, "", False) Sleep($Delay / 2) DllCall($User32, "bool", "PostMessage", "hwnd", $hWnd, "int", $Button + 1, "int", "0", "long", _MakeLong($X2, $Y2)) If @error Then Return SetError(7, "", False) DllClose($User32) Return SetError(0, 0, True) EndFunc Func _MakeLong($LoWord,$HiWord) Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF)) EndFunc P.S. Sorry for formating, it was not me who wrote this code and I just only modified it a bit Edited April 3, 2012 by WhiteAngel Link to comment Share on other sites More sharing options...
WhiteAngel Posted April 4, 2012 Author Share Posted April 4, 2012 No ideas? Link to comment Share on other sites More sharing options...
BrewManNH Posted April 4, 2012 Share Posted April 4, 2012 MouseClickDrag ( "button", x1, y1, x2, y2 [, speed] ) look in the help file for how to use it, it might be what you're looking for. 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 Link to comment Share on other sites More sharing options...
WhiteAngel Posted April 4, 2012 Author Share Posted April 4, 2012 This is the workaround that I use now, but the problem is that it cannot be performed in background. My window has to be active in the moment of execution. I need a command for Control, like ControlClick e.t.c Link to comment Share on other sites More sharing options...
BrewManNH Posted April 4, 2012 Share Posted April 4, 2012 Have you tried using _SendMessage to the control? Sending a $WM_LBUTTONDOWN and then a $WM_MOUSEMOVE command to the window/control might work, I haven't tried it myself but it's worth a shot rather than trying to reinvent the wheel with the DLLCall. 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 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