Jump to content

ControlClickDrag And ControlGetColor?


Recommended Posts

Link to comment
Share on other sites

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

  • Moderators

Func _ControlGetColor($hWndMain, $sText, $sClassName, $nX, $nY)
    Local $hWndCtrl = ControlGetHandle($hWndMain, "", $sClassName)
    If $hWndMain = "" Then Return SetError(1, 0, "")
    Local $tStruct = DllStructCreate("int;int")
    DllStructSetData($tStruct, 1, $nX)
    DllStructSetData($tStruct, 2, $nY)
    Local $aSCoords = DllCall('User32.dll', 'int', 'ClientToScreen', _
        'hwnd', $hWndCtrl, 'ptr', DllStructGetPtr($tStruct))
    If IsArray($aSCoords) = 0 Then Return SetError(2, 0, "")
    Local $OptPCM = Opt("PixelCoordMode", 1)
    Local $nPGC = PixelGetColor(DllStructGetData($tStruct, 1), DllStructGetData($tStruct, 2))
    Opt("PixelCoordMode", $OptPCM)
    Return $nPGC
EndFunc

I was able to do the ControlClickDrag as well, but unfortunately not without moving the mouse. Don't have time to keep playing with it.

I did also notice that on some controls, the coords were off a bit, but this is how I saw the ControlGetColor working.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Func _ControlGetColor($hWndMain, $sText, $sClassName, $nX, $nY)
    Local $hWndCtrl = ControlGetHandle($hWndMain, "", $sClassName)
    If $hWndMain = "" Then Return SetError(1, 0, "")
    Local $tStruct = DllStructCreate("int;int")
    DllStructSetData($tStruct, 1, $nX)
    DllStructSetData($tStruct, 2, $nY)
    Local $aSCoords = DllCall('User32.dll', 'int', 'ClientToScreen', _
        'hwnd', $hWndCtrl, 'ptr', DllStructGetPtr($tStruct))
    If IsArray($aSCoords) = 0 Then Return SetError(2, 0, "")
    Local $OptPCM = Opt("PixelCoordMode", 1)
    Local $nPGC = PixelGetColor(DllStructGetData($tStruct, 1), DllStructGetData($tStruct, 2))
    Opt("PixelCoordMode", $OptPCM)
    Return $nPGC
EndFunc

I was able to do the ControlClickDrag as well, but unfortunately not without moving the mouse. Don't have time to keep playing with it.

I did also notice that on some controls, the coords were off a bit, but this is how I saw the ControlGetColor working.

Thanks but I don't think the ControlGetColor returns the correct color? and the controlClickdrag would be great.

do you think these two should be a standard function?

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

  • Moderators

Thanks but I don't think the ControlGetColor returns the correct color?

I said I found on some controls the coords were off a bit, but it did work on most controls I used it on.

and the controlClickdrag would be great.

Done any work on this yourself? ... Just takes you opening up your editor and putting in some code and keep trying until you can get something to work... then move on to the next step.

do you think these two should be a standard function?

Why?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I said I found on some controls the coords were off a bit, but it did work on most controls I used it on.Done any work on this yourself? ... Just takes you opening up your editor and putting in some code and keep trying until you can get something to work... then move on to the next step.

Why?

Why? Because these could be useful.

And I don't know how to pull a ControlClickDrag out of my ass. there ControlClick, but that doesn't help me much.

and as for the color coods, I'm trying to get the color of the mspaint canvas. and it must be way off, because theres only white, gray, and black, and I'm getting colors way off of that.

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

  • Moderators

Why? Because these could be useful.

And I don't know how to pull a ControlClickDrag out of my ass. there ControlClick, but that doesn't help me much.

and as for the color coods, I'm trying to get the color of the mspaint canvas. and it must be way off, because theres only white, gray, and black, and I'm getting colors way off of that.

1. MSDN << (PostMessage should be all you need with the current control functions available) No need to pull it out of your rear... just do some home work. (Might have a look at the old source to get some ideas)

2. Useful to whom? I mean, functions like insert should be used by masses, not just because they can be done, and a few would benefit, remember that everything that is added as a standard function bloats the current executable size output.

3. Sounds like you have the wrong control if the colors are off that bad... try to do any debugging? If so, what did you find?

4. Your signature makes the screen extend further out, making someone have to scroll to read your posts (Kind of ridiculous).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

I something similar I had written that would work for the GetColor(). This should be more accurate:

Func _ControlGetColor($hWnd, $sText, $sClassName, $nX, $nY)
    Local $aWPos = WinGetPos($hWnd, $sText)
    If IsArray($aWPos) = 0 Then Return SetError(1, 0, "")
    Local $aCSize = WinGetClientSize($hWnd, $sText)
    If IsArray($aCSize) = 0 Then Return SetError(2, 0, "")
    Local $aCPos = ControlGetPos($hWnd, $sText, $sClassName)
    If IsArray($aCPos) = 0 Then Return SetError(3, 0, "")
    Local $nXCoord = ($nX + $aCPos[0] + $aWPos[0]) + (($aWPos[2] - $aCSize[0]) / 2)
    Local $nYCoord = ($nY + $aCPos[1] + $aWPos[1]) + _
        (($aWPos[3] - $aCSize[1]) - (($aWPos[2] - $aCSize[0]) / 2))
    Local $OptPCM = Opt("PixelCoordMode", 1)
    Local $nPGC = PixelGetColor($nXCoord, $nYCoord)
    Opt("PixelCoordMode", $OptPCM)
    Return $nPGC
EndFunc
Note, that 0, 0 would be the left/top of the control itself.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks guys, I was just frustrated, I'm trying to make a nice paint udf set but I'm having troubles.

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

  • 8 years later...

You are being deliberately lazy. There's an example IN THIS VERY THREAD showing you what you want. Stop pretending you've actually done ANY searching.

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 Gude
How 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

  • 4 months later...
On 12/2/2016 at 9:59 AM, BrewManNH said:

You are being deliberately lazy. There's an example IN THIS VERY THREAD showing you what you want. Stop pretending you've actually done ANY searching.

I want an example ControlClickDrag

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...