Petrask24 Posted September 7, 2020 Share Posted September 7, 2020 I am currently trying to use _MouseClickPlus on a window that does not use any controls, therefore I am having a hard time using the function to click. I have tried several different versions of code, all listed below. Original based off of hendrikhe expandcollapse popup#include <Array.au3> AutoItSetOption("MouseCoordMode", 0) ;=============================================================================== ; ; Function Name: _MouseClickPlus() ; Version added: 0.1 ; Description: Sends a click to window, not entirely accurate, but works ; minimized. ; Parameter(s): $Window = Title of the window to send click to ; $Button = "left" or "right" mouse button ; $X = X coordinate ; $Y = Y coordinate ; $Clicks = Number of clicks to send ; Remarks: You MUST be in "MouseCoordMode" 0 to use this without bugs. ; Author(s): Insolence <insolence_9@yahoo.com> ; ;=============================================================================== Main() Func Main() $Window = "My Window" ;Changed for privacy $ControlID = WinGetHandle($Window,"") _MouseClickPlus($ControlID, "right", 0, 0, 1) EndFunc Func _MouseClickPlus($Window, $Button = "left", $X = "", $Y = "", $Clicks = 1) 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 Local $i = 0 Select Case $Button = "left" $Button = $MK_LBUTTON $ButtonDown = $WM_LBUTTONDOWN $ButtonUp = $WM_LBUTTONUP Case $Button = "right" $Button = $MK_RBUTTON $ButtonDown = $WM_RBUTTONDOWN $ButtonUp = $WM_RBUTTONUP EndSelect If $X = "" OR $Y = "" Then $MouseCoord = MouseGetPos() $X = $MouseCoord[0] $Y = $MouseCoord[1] EndIf For $i = 1 to $Clicks DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle( $Window ), _ "int", $WM_MOUSEMOVE, _ "int", 0, _ "long", _MakeLong($X, $Y)) DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle( $Window ), _ "int", $ButtonDown, _ "int", $Button, _ "long", _MakeLong($X, $Y)) DllCall("user32.dll", "int", "SendMessage", _ "hwnd", WinGetHandle( $Window ), _ "int", $ButtonUp, _ "int", $Button, _ "long", _MakeLong($X, $Y)) Next EndFunc Func _MakeLong($LoWord,$HiWord) Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF)) EndFunc A recent version by Nine expandcollapse popup#include <Constants.au3> #include <WinAPISysWin.au3> #include <WinAPIError.au3> #include <WinAPIConv.au3> _Main () Func _Main () Local $ctrl_handle $Window = "My Window" ;Changed for privacy Local $hWnd = WinGetHandle($Window,"") Local $tPoint = DllStructCreate($tagPOINT) DllStructSetData($tPoint, "X", 500) DllStructSetData($tPoint, "Y", 500) _WinAPI_ScreenToClient ($hWnd, $tPoint) MsgBox (0,"Test",DllStructgetData($tPoint, "X") & "/" & DllStructGetData($tPoint, "Y")) Local $thWnd = $hWnd While True $ctrl_handle = _WinAPI_ChildWindowFromPointEx ($hWnd, $tPOINT) if not $ctrl_handle then MsgBox (0,"Error","Failure in finding the child window") Exit endif if $ctrl_handle = $thWnd then ExitLoop $thWnd = $ctrl_handle Wend MsgBox (0,"Handle", $thWnd) _MouseClickPlus($thWnd, "left", DllStructgetData($tPoint, "X"), DllStructGetData($tPoint, "Y"), 1) $tPoint = 0 EndFunc Func _MouseClickPlus($hWnd, $sButton = 'left', $vX = '', $vY = '', $iClicks = 1) 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 If $sButton = 'left' Then $Button = $MK_LBUTTON $ButtonDown = $WM_LBUTTONDOWN $ButtonUp = $WM_LBUTTONUP ElseIf $sButton = 'right' Then $Button = $MK_RBUTTON $ButtonDown = $WM_RBUTTONDOWN $ButtonUp = $WM_RBUTTONUP EndIf If $vX = "" Or $vY = "" Then $MouseCoord = MouseGetPos() $vX = $MouseCoord[0] $vY = $MouseCoord[1] EndIf Local $stPoint = _MakeLong($vX, $vY) Local $i = 0 For $i = 1 To $iClicks _PostMessage($hWnd, $WM_MOUSEMOVE, 0, $stPoint) _PostMessage($hWnd, $ButtonDown, $Button, $stPoint) _PostMessage($hWnd, $ButtonUp, $Button, $stPoint) Next EndFunc Func _MakeLong($LoWord,$HiWord) Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF)) EndFunc Func _PostMessage($hWnd, $iMsg, $iwParam, $ilParam) Local $aResult, $err $aResult = DllCall("User32.dll", "bool", "PostMessageA", "hwnd", $hWnd, "int", $iMsg, "int", $iwParam, "int", $ilParam) $err = _WinAPI_GetLastError () if $err or not $aResult[0] then MsgBox (0,"Error","Access denied in post message with error " & $err) Exit endif Return $aResult[0] EndFunc Any help/suggestions on this would be greatly appreciated! Link to comment Share on other sites More sharing options...
Petrask24 Posted September 7, 2020 Author Share Posted September 7, 2020 Here is another post that could be helpful. Same issue but with MouseClick. I've read through the comments and can't find a solution, hoping someone else can determine the issue I'm having at this point. Link to comment Share on other sites More sharing options...
Developers Jos Posted September 7, 2020 Developers Share Posted September 7, 2020 @Petrask24, Why did you simply start a new topic without first finishing the other thread in which I asked you a question and told you to be patient? Quote I have merged your crossposted topic here so we have one place to discuss your question... so please stick to one place for the future. Also be patient..... people will reply when they have time and feel like helping, but do not try bumping your issue within 24 hours. In the mean time, why not explain what exactly is the purpose of this script? Why is this multiple image search at the same time required? Please answer me now first before doing anything else in our forums! @Everybody else: Please stay out of this thread until it is cleared. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Petrask24 Posted September 7, 2020 Author Share Posted September 7, 2020 (edited) 18 hours ago, Jos said: @Petrask24, Why did you simply start a new topic without first finishing the other thread in which I asked you a question and told you to be patient? Please answer me now first before doing anything else in our forums! @Everybody else: Please stay out of this thread until it is cleared. My apologies, I didn't think posting two things about two different topics would be so overkill. To be honest, I sort of gave up on the other issue with hope of coming back to it in a day or two. In the meantime, I found a fix that will work for now. Now I'm onto this issue, which I again can't proceed unless I settle for a less than adequate solution. Edited September 8, 2020 by Petrask24 Removed cocky remark :o Link to comment Share on other sites More sharing options...
Developers Jos Posted September 7, 2020 Developers Share Posted September 7, 2020 Funny.... You totally avoid to address my questions ...wondering why? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Petrask24 Posted September 11, 2020 Author Share Posted September 11, 2020 (edited) I've decided to give up on this issue. Could a moderator delete this thread? Thanks! Edited September 11, 2020 by Petrask24 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