Jump to content

Hotkeying click-and-drag actions: looking for clean x/y mouseclick locations?


Fohsap
 Share

Recommended Posts

I'm trying to create a series of similar actions via 3 different hotkeys. This is a rough, general description of the actions. All click actions are left-click actions:

1) Click in 2 fixed, unique areas, then click and drag from point A to point B.

2) Click in 5 fixed, unique areas, then click and drag from point C to point D.

3) Click in 2 fixed, unique areas, then click and drag from point E to point F.

The issue that I'm having is that the readouts from Au3Info.exe seem to be off. There are coordinates like -2, 738, and when I try to get my MouseClickDrag() action into place, x1,y1 = x2,y2. They're in different locations, though. They shouldn't be equal. I feel like the best way to go about getting the click locations is to use absolute locations for the entire screen. I don't have a lot of experience with this, though.

So, basically my code so far is testable, but I don't want to have clicks landing in random locations. I'm afraid I'll set off a chain reaction of bad events. Can somebody please tell me how to get pure location values?

Link to comment
Share on other sites

Just in case anyone bumps in looking for help: what I'm currently trying to do is use a screenshot of my desktop to get coordinates out of an image mapping program (GIMP). I'm hoping the pixel positions correspond with the positions autoit processes.

Link to comment
Share on other sites

this is a little developer help program that i made to help in this situations.

hope it helps

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinApI.au3>
#include <ScreenCapture.au3>
#NoTrayIcon
$collor=1
$a=10
$b=20
$d=105
$e=50
$setupGui = GUICreate("", 100, 160, 2, 2, $ws_popup,$ws_ex_topmost)
$cr=GUICtrlCreateRadio("color Gui",5,5)
$zr=GUICtrlCreateRadio("zoom Gui",5,25)
$nr=GUICtrlCreateRadio("no Gui",5,45)
GUICtrlSetState(-1,1)
$hc=GUICtrlCreateCheckbox("hex Color",5,65)
$nc=GUICtrlCreateCheckbox("no Color",5,85)
$tt=GUICtrlCreateCheckbox("Tool Tip",5,105)
$button=GUICtrlCreateButton("exit",5,130,90,20)

$colorGui = GUICreate("", 200, 200, 200, 200, BitAND($ws_popup,$ws_border),$ws_ex_topmost)
$cl=GUICtrlCreateLabel("",10,10,100,25)
   GUICtrlSetBkColor($cl,0x000000)
   GUICtrlSetFont($cl,14)
   GUICtrlSetColor($cl,0xffffff)
_GDIPlus_Startup()
While 1
Sleep(1)
$p=MouseGetPos()
$c=PixelGetColor($p[0],$p[1])
$hex=String("0x" & hex($c,6))
if GUICtrlRead($tt)=$GUI_CHECKED Then
if $p[0]>=@DesktopWidth-$d-$a and $p[1]<@DesktopHeight-$e-$b then Tipex(@DesktopWidth-$d,$p[1]+$b)
if $p[0]<@DesktopWidth-$d-$a and $p[1]<@DesktopHeight-$e-$b then Tipex($p[0]+$a,$p[1]+$b)
if $p[0]<@DesktopWidth-$d-$a and $p[1]>=@DesktopHeight-$e-$b then Tipex($p[0]+$a,@DesktopHeight-$e)
if $p[0]>=@DesktopWidth-$d-$a and $p[1]>=@DesktopHeight-$e-$b then Tipex(@DesktopWidth-$d,@DesktopHeight-$e-$b-30)
EndIf
if $p[0]=0 And $p[1]=0 then
GUISetState(@SW_SHOW,$setupGui)
While 1
  $p=MouseGetPos()
  if $p[0]>200 Then ExitLoop
  if $p[1]>200 Then ExitLoop
  Tipex($p[0]+$a,$p[1]+$b,1)
  if GUIGetMsg()=$button then Exit
WEnd
$tool=ToolTip("")
GUISetState(@SW_HIDE,$setupGui)
Else
EndIf
if GUICtrlRead($nr)=$GUI_CHECKED then
GUISetState(@SW_HIDE,$colorGui)
Else
if GUICtrlRead($zr)=$GUI_CHECKED Then
  GUISetState(@SW_SHOW,$colorGui)
  $scr = _ScreenCapture_Capture("")
  $secscr = _GDIPlus_BitmapCreateFromHBITMAP($scr)
  $palete = _GDIPlus_GraphicsCreateFromHWND($colorGui)
  _GDIPlus_GraphicsDrawImageRectRect($palete, $secscr,$p[0]-50, $p[1]-50, 100, 100, 0, 0, 200, 200)
  _GDIPlus_GraphicsDispose($palete)
  _GDIPlus_ImageDispose($secscr)
  _WinAPI_DeleteObject($scr)
EndIf
If GUICtrlRead($cr)=$GUI_CHECKED Then
   If GUICtrlRead($hc)=$GUI_CHECKED then
    If $hex<>$collor Then
     GUISetBkColor($hex,$colorGui)
     GUICtrlSetData($cl,$hex)
     $collor=$hex
    EndIf
   Else
    If $hex<>$collor Then
     GUISetBkColor($hex,$colorGui)
     GUICtrlSetData($cl,$c)
     $collor=$hex
    EndIf
   EndIf
  GUISetState(@SW_SHOW,$colorGui)
EndIf
EndIf
WEnd
_GDIPlus_Shutdown()
Func tipex($x,$y,$var=0)
if $var=0 Then
If GUICtrlRead($nc)=$GUI_CHECKED Then
  $tool=ToolTip($p[0] & "," & $p[1], $x,$y)
Else
  if GUICtrlRead($hc)=$GUI_CHECKED then
   $tool=ToolTip($p[0] & "," & $p[1] & "--" & $hex , $x,$y)
  Else
   $tool=ToolTip($p[0] & "," & $p[1] & "--" & $c , $x,$y)
  EndIf
EndIf
EndIf
if $var=1 then $tool=ToolTip("Setup", $x,$y)
EndFunc
Func quit()
Exit
EndFunc

just run the script and move mouse to upper left corner and select tooltip checkbox

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...