Leo1906

Differentiate between Mouseclick and Touch-Click

1 post in this topic

#1 ·  Posted (edited)

Hello there :D

I recently wanted to know how to differentiate between a mouse click and a touch click on controls in your GUI.
This can be interesting when using picture controls as buttons in combination with this UDF here.

No one could help me, so I tried my best to get it to work. And it works now! Unfortunately only for Windows 8 and above, as I had to use functions which are unavailable for older OS.
Additionally this was my first time writing DLLCalls myself. I hope (and think) that there are no mayor mistakes in it,

 

So here's the sample code:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

OnAutoItExitRegister("_exit")

$play = 'iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAAGz7rX1AAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o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kZHxPwG/MhIbSm+gSQdrKKFjO2L9MIPY'
$play &= 'UHqOy5kYnqZZ0gAAAAD//yIv65Kb/pD8H8jAwHCBgYGhg4GBgYcqZmKxZD6WaNzFwMCgTa4lxIavKwMDwxWohY8YGBiiaJu/IUXSUqiFvxkYGCZiK0UptQS9fMxDKnUPMjAwmFPbEnTAxcDAwEFtS/5D629JaH1nCvUNAzHVAT7wmoGBoQZatf8jNkyJAUcZGBgKGBgYzlArM0ZCK4WphFINsWbSpVgBDADB5DrGESuD0wAAAABJRU5ErkJggg=='
$play = Binary(_WinAPI_Base64Decode($play))


$Form1 = GUICreate("Form1", 444, 372, -1, -1)
$pic1 = GUICtrlCreatePic("", 184, 112, 65, 57)
$pic1_dummy = GUICtrlCreateDummy()

_GDIPlus_Startup()
Global $play1 = _GDIPlus_BitmapCreateFromMemory($play, True)
_WinAPI_DeleteObject(GUICtrlSendMsg($pic1, $STM_SETIMAGE, $IMAGE_BITMAP, $play1))

DllCall("User32.dll", "bool", "RegisterTouchHitTestingWindow", "HWND", $Form1, "ULONG", 1)  ; register your GUI for recieving commands relatet to WM_TOUCHHITTESTING
GUIRegisterMsg(0x024D, "WM_TOUCHHITTESTING")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $pic1_dummy
            MsgBox(0, 0, "touch-click")
        Case $Pic1
            MsgBox(0, 0, "Mouseclick")
    EndSwitch
WEnd

Func WM_TOUCHHITTESTING($hWnd, $iMsg, $wParam, $lParam)
    Local $send = 1
    Local $pic1_pos = _WinAPI_GetWindowRect(GUICtrlGetHandle($pic1))
    Local $struct = DllStructCreate("uint;long X;long Y")   ; first Parameter gives the accuracy of which this control is meant by a touch - second and third are the x/y points of the touch (not relative to GUI)

    DllCall("User32.dll", "bool", "EvaluateProximityToRect", "ptr", DllStructGetPtr($pic1_pos), "ptr", $lParam, "ptr", DllStructGetPtr($struct))
    If DllStructGetData($struct, 1) < 20 Then               ; if the proximity of the touch is near enough to the control (I chose 20, but you can vary yourself) then do something
        GUICtrlSendToDummy($pic1_dummy)                     ; you shouldn't do very intensive stuff inside the function itself. Outsource it to your main loop.
        $send = 0                                           ; no need to pass the command on to your GUI, as you take action yourself ..
    EndIf
    If $send Then _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc



Func _WinAPI_Base64Decode($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($bBuffer, 1)
EndFunc

Func _exit()
    _WinAPI_DeleteObject($play1)
    _GDIPlus_Shutdown()
EndFunc

The magic happens in the WM_TOUCHHITTESTING function.
The _WinAPI_Base64Decode is written by @UEZ (as well as the way to use PNG as button (from binary) - thanks for that!)

On Windows 7 there is the WM_TOUCH function which should handle touch events, but I couldn't get it to work on controls ..??
If you will get the x/y coordinates of a touch (even when you touch on controls) you could make the "EvaluateProximityToRect" check yourself - as this function is not available in Windows 7. Shouldn't be that hard.

Btw.: this here is the MSDN articel related to this topic: https://msdn.microsoft.com/en-us/library/windows/desktop/hh454931(v=vs.85).aspx

So thats it. Any questions and comments welcome! :)

greetz,

Leo

Edited by Leo1906
added msdn link
1 person likes this

Share this post


Link to post
Share on other sites



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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • Dequality
      Need help mouseclick/control click.
      By Dequality
      I'm currently wondering if there is somehow to actually make autoit click inside a minimized program? & sent keystrokes ? 
      2nd question, how can i make it do a mouse click at e.g. x200,y200 while the are at like x354,y313 (This is purely an example.) would love to be able to do other shizz on my pc while the script is running if possible.
      If this ISNT possible can u recommend a language / other scripting program which are able to do this ? willing to start over learning a new coding/scripting language.
       
      -Dequality.
    • DiveHigh
      Using GetMousePos for calculating a MouseClick
      By DiveHigh
      Hello There!  
      I've encountered a small issue i just cant seem to program my way out of...

      What im doing is:        ;or rather, what im trying to do is
      Pixelsearch for a color, within a part of my screen,
      If color is present, i will rightclick it, for a menu to appear,
      in which i want to Leftclick an option. Simplicity itself.   

      The issue is that because this menu appears in different parts of my screen, its complicated to select the option i want to click.
      There is no special color to it, and i cannot define the area in which to click, because the menu appears different places.
      The only thing that is in common for the menu is that the Leftclick needs to be (lets say) 30pixels below the rightclick
      .

      What can be done,  but seemingly not by me, is to get the coordinates of the rightclick, and use them as the "starting point" from where the coordinates for the leftclick will be.
      (Not sure if that makes sence, but maybe the code below will help you understand)

      You guys like example codes, so therefore i will give it my best shot, and hope it proves usefull

      $pos = Pixelsearch(200, 400, 200, 400, 0xFFFFFF)        ;This color is what i need to rightclick to bring up the menu
      If not @Error then                                                               ;If the color is present
      (Mouseclick("Right", $pos[0], $pos[1], 1, 1)                   ;Rightclick it, to bring up menu
      ;Here comes the part i cannot get to work
      $x = MousegetPos(X)                                                          ;To get the Coordinate "X", so we can calculated with it for the position of the leftclick
      $y = MousegetPos(Y)                                                           ; To get the Coordinate "Y", so that can be calculated with for the position of the leftclick

      MouseClick("Left", $x[0], $y-30[1], 1, 1)                         ;This was supposed to give me a leftclick that is 30pixels below the rightclick.
      (The MouseGetPos(X), may seem as a waste of space in this example, but in my script i will need both. 
              Im only using one in the example, mainly so that i wont confuse myself, but also to make it easier to digest for you guys)


      I have not been able to find any topic that covers this, but my apologies if such a topic already exist in the forums. 

      Maybe while im at it, can i ask,   what good does the [0] and [1] do, when using a "$variable" as coordinate?   


      Thanks in advance
      - DiveHigh
    • Ikedor
      ControlClick Command
      By Ikedor
      I’m trying to click the “assign a playlist” url in this application (see info.png)
      I don’t know if it is flash or not.
       
      The control ID changes on every launch.
      I can’t use mouseclick because it needs to be scheduled at night on a server.
      So just ControlClick is left as an option.
      I can find the handle to the window but not to the control, be it through text or classname, clas or advanced mode.
      The mouse cursor doesn't even move after these commands. 
       
      $handle = WinGetHandle("[ACTIVE]")
      ControlClick($handle, "", "[CLASS:TFlickerFreePaintBox.UnicodeClass; INSTANCE:1]",'left', 1, 54, 138)
      ControlFocus("Q-MATIC Monitor™ 3", "", "[TFlickerFreePaintBox.UnicodeClass1]")
      Controlclick("Q-MATIC Monitor™ 3", "",", "primary", 1, 54, 55)
      ControlClick($handle, "", "", "Left", 1, 54, 55)
      ControlClick("Q-MATIC Monitor™ 3", "", "[TEXT:Assign to playlist]")
      ControlFocus ( "Q-MATIC Monitor™ 3", "", "TFlickerFreePaintBox.UnicodeClass")
       
      What other parameters are possible for this?
       


    • mitchelwb
      MouseClick doesn't seem to always be in the right place
      By mitchelwb
      I've got a simple little script that is trying to step through data in a datagrid.  I have written and rewritten this thing to try and keep it running, but it just keeps coming up with values I just don't think it can get.  I've played with the timing and it seems to run a little better when slowed down, but setting my $delay higher and higher gets me less and less improvement, but starts to really drag the process to a crawl.  Removing the sleeps entirely isn't even that bad. 
      Every time I send a ^C to copy a value, I verify it, and then when I'm done with it, I reset the Clipboard with a known value that will never show in my data and reverify the clipboard.  So either my reset/verification is not doing it's job or my mouse double click is not getting the coordinates updated.  Neither of these options are great because I'm running out of ideas how to make sure I get what I want.  About all I can do at this point is attempt my copy, then validate that the clipboard isn't my reset string, isn't zero length, and THEN match it to a date REGEX to see if it's the data from the correct column.  That would be triple checking something that shouldn't need to be checked once.  Scrip and output below:
       
      $desiredDate = "2/9/2015" $yCoord = 290 $yStep = 15 $recDisplay = 9 ;number of rows to read before starting to scroll $totalRec = 0 $PONList = "" $delay = 250 $dcDelay = 12 $count = 0 $clipReset = "chicken" $oCoastal = WinActivate("Find FOC") WinWaitActive($oCoastal) if @error Then msgBox(1, "winactivate error", @error) Exit endif AutoItSetOption("MouseCoordMode", 0) AutoItSetOption("SendKeyDownDelay", 100) ClipPut("") While 1 ;get date ;MouseMove(284, $yCoord, 1) MouseClick("left", 284, $yCoord, 2, $dcDelay) Sleep($delay) while 1 MouseClick("left", 284, $yCoord, 2, $dcDelay) ;Sleep($delay) Send("^c") ;Sleep($delay) $thisDate = clipGet() if StringCompare($thisDate, $clipReset) <> 0 and StringLen($thisDate) > 0 Then resetClip($clipReset) ExitLoop EndIf WEnd ConsoleWrite($count & ": Date: " & $thisDate) ;check date matches what we want ;if not StringCompare($desiredDate, $thisDate) = 0 Then ;with some date functions, this could be improved to a date range if StringRegExp($thisDate, $desiredDate) = 0 Then ;just check to see if the desired date exists inside what was copied ;we have reached the end of our records MsgBox(1, "Found " & $totalRec & " total records", $PONList) Exit ;or exitloop endif ;get pon ;MouseMove(81, $yCoord, 1) MouseClick("left", 81, $yCoord, 2, $dcDelay) Sleep($delay) While 1 MouseClick("left", 81, $yCoord, 2, $dcDelay) ;Sleep($delay) Send("^c") ;Sleep($delay) $thisPON = clipGet() if StringCompare($thisPON, $clipReset) <> 0 and StringLen($thisPON) > 0 Then resetClip($clipReset) ExitLoop EndIf WEnd ConsoleWrite(" PON:" & $thisPON & @CRLF) ;Check if we want this record if StringCompare(StringMid($thisPON, 10, 1), "D") = 0 Then ;We want this record! $totalRec += 1 $PONList = $PONList & ", " & $thisPon EndIf if $recDisplay >= 1 Then ;still in the first 10 records and need to move the mouseclick position down by a record $yCoord += $yStep $recDisplay -= 1 Else ;reached the bottom of the data grid and need to click the down arrow in the bottom right of the grid to advance one record MouseClick("left", 650, 438,1) ;Sleep($delay) endIf ;consolewrite($recDisplay & @CRLF) $count += 1 Wend func resetClip($val = "") Do ClipPut($val) Until StringCompare(ClipGet(), $val) = 0 EndFunc And here's a sample output. Everything looks great until the last row.  This was not the last row in the data and should not have stopped here, but you can see the PON is either still on the clipboard, or the mouse click did not update the coordinates and copied the MouseClick commands didn't move to the coordinates:
      0: Date: 2/9/2015 PON:173714357INN0001 1: Date: 2/9/2015 PON:173708683DID0001 2: Date: 2/9/2015 PON:173708683DID0003 3: Date: 2/9/2015 PON:173546121INN0001 4: Date: 2/9/2015 PON:173701848INN0001 5: Date: 2/9/2015 PON:173454114INN0001 6: Date: 2/9/2015 PON:173708683DID0002 7: Date: 2/9/2015 PON:173714373DID0001 8: Date: 2/9/2015 PON:173709684INN0001 9: Date: 2/9/2015 PON:173621964INN0001 10: Date: 2/9/2015 PON:173710242CHC0001 11: Date: 2/9/2015 PON:855440C 12: Date: 2/9/2015 PON:173531625INN0001 13: Date: 2/9/2015 PON:173717963DID0001 14: Date: 2/9/2015 PON:173717560DID0001 15: Date: 2/9/2015 PON:173713978DID0001 16: Date: 2/9/2015 PON:173710221INN0001 17: Date: 2/9/2015 PON:173713002INN0001 18: Date: 2/9/2015 PON:173456352RGN0001 19: Date: 2/9/2015 PON:173712598DID0001 20: Date: 2/9/2015 PON:173709807DID0001 21: Date: 2/9/2015 PON:173616984INN0001 22: Date: 2/9/2015 PON:173646606INN0001 23: Date: 2/9/2015 PON:173649988INN0002 24: Date: 2/9/2015 PON:173712524INR0001 25: Date: 2/9/2015 PON:173710904DID0001 26: Date: 2/9/2015 PON:173717004INN0001 27: Date: 2/9/2015 PON:173712871INN0001 28: Date: 2/9/2015 PON:173426776RGN0001 29: Date: 2/9/2015 PON:173418924RGN0001 30: Date: 2/9/2015 PON:173712465INR0001 31: Date: 2/9/2015 PON:173712465INR0002 32: Date: 2/9/2015 PON:173712524INR0002 33: Date: 2/9/2015 PON:173710788INR0001 34: Date: 2/9/2015 PON:173710788INR0002 35: Date: 2/9/2015 PON:173712737DID0001 36: Date: 2/9/2015 PON:173717129INN0001 37: Date: 2/9/2015 PON:173718061DID0001 38: Date: 2/9/2015 PON:173717663INN0001 39: Date: 2/9/2015 PON:173718181DID0001 40: Date: 2/9/2015 PON:173714071DID0001 41: Date: 2/9/2015 PON:173692375INN0002 42: Date: 173692375INN0002  
    • K3STROS
      Is this done correctly?
      By K3STROS
      What i have done is set Coordinates in xyBox1, xyBox2 and xyBox5 (with MouseGetPos() - The rest of my code works 100%)
      And instead of going out every time and entering every single box coordinate i figured i would come up with this "Formula" to calculate all the boxes locations by itself from what i have entered for my 3 Variables
      Everytime i run, it clicks on box 1, 2, 5, 6 and the crashes, skips box 3 and 4
      Any Clue?
      Func FourxSeven() ; 0 Returns the X1 co-ordinate as an integer. ; 1 Returns the Y1 co-ordinate as an integer. Local $xSD = ($xyBox1[1] - $xyBox2[1]) ; (Box1 y - Box2 y) = xAxis - Sideways difference Local $yDD = ($xyBox1[0] - $xyBox5[0]) ; (Box1 x - Box5 x) = yAxis - Downwards Difference MouseClick("Left", $xyBox1[0], $xyBox1[1]) ;#1 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox2[0], $xyBox1[1]) ;#2 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + $xSD), $xyBox1[1]) ;#3 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + ($xSD * 2)), $xyBox1[1]) ;#4 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox1[0], $xyBox5[1]) ;#5 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox2[0], $xyBox5[1]) ;#6 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + $xSD)[0], $xyBox5[1]) ;#7 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + ($xSD * 2))[0], $xyBox5[1]) ;#8 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox1[0], ($xyBox5[1] + $yDD)[1]) ;#9 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox2[0], ($xyBox5[1] + $yDD))[1]) ;#10 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + $xSD)[0], ($xyBox5[1] + $yDD)[1]) ;#11 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + ($xSD * 2))[0], ($xyBox5[1] + $yDD)[1]) ;#12 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox1[0], ($xyBox5[1] + ($yDD * 2))[1]) ;#13 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox2[0], ($xyBox5[1] + ($yDD * 2))[1]) ;#14 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + $xSD)[0], ($xyBox5[1] + ($yDD * 2))[1]) ;#15 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + ($xSD * 2))[0], ($xyBox5[1] + ($yDD * 2))[1]) ;#16 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox1[0], ($xyBox5[1] + ($yDD * 3))[1]) ;#17 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox2[0], ($xyBox5[1] + ($yDD * 3))[1]) ;#18 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + $xSD)[0], ($xyBox5[1] + ($yDD * 3))[1]) ;#19 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + ($xSD * 2)[0], ($xyBox5[1] + ($yDD * 3))[1]) ;#20 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox1[0], ($xyBox5[1] + ($yDD * 4))[1]) ;#21 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox2[0], ($xyBox5[1] + ($yDD * 4))[1]) ;#22 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + $xSD)[0], ($xyBox5[1] + ($yDD * 4))[1]) ;#23 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + ($xSD * 2)[0], ($xyBox5[1] + ($yDD * 4))[1]) ;#24 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox1[0], ($xyBox5[1] + ($yDD * 5))[1]) ;#25 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", $xyBox2[0], ($xyBox5[1] + ($yDD * 5))[1]) ;#26 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + $xSD)[0], ($xyBox5[1] + ($yDD * 5))[1]) ;#27 Box Locations Sleep(Random(590,1390,1)) MouseClick("Left", ($xyBox2[0] + ($xSD * 2))[0], ($xyBox5[1] + ($yDD * 5))[1]) ;#28 Box Locations Sleep(Random(590,1390,1)) Sleep(Random(990, 1990, 1)) EndFunc