AutoHotkey Community

It is currently May 27th, 2012, 12:27 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: January 21st, 2009, 3:26 am 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
How can I use the Click command without moving the mouse


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 3:39 am 
Offline

Joined: November 2nd, 2004, 2:43 pm
Posts: 1019
Location: London, UK
AFAIK you can't but I am sure you can use sendmessage, assuming the program you are interacting with will accept it.

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 3:43 am 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
Its not a control, but thanks ill look into it


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 3:46 am 
Offline

Joined: November 2nd, 2004, 2:43 pm
Posts: 1019
Location: London, UK
It doesn't need to be a control, sendmessage can be sent to a window, and the mouse messages contain the coordinates of the mouse.

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 3:51 am 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
CAn you give me an example them? What i saw on sendmessage was control


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 6:29 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
From what MSDN says about WM_MOUSEMOVE you would have to specify the low order(x-coord) and high order(y-coord) words in lParam and I can't find any way to retrieve/set that information, from AHK anyway.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 1:47 pm 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
I dont want to move the mouse, just click at coordinates without the cursor being moved


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 1:40 pm 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
Bump


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 4:30 pm 
CLICK does not need the coordinates.

Or you could say,

Code:
MouseGetPos, X, Y
Click, %X%, %Y%


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 10:30 pm 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
Using click moves the mouse. I dont want it to


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2009, 10:32 pm 
Offline

Joined: June 4th, 2006, 2:04 pm
Posts: 176
Location: ::1
Fry wrote:
Using click moves the mouse. I dont want it to

ControlClick...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 23rd, 2009, 3:05 am 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
Its not a control...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 23rd, 2009, 3:20 am 
controlclick doesnt have to only click controls, it can click anywhere
please read help file for more information


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 23rd, 2009, 6:46 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
Sends a mouse button or mouse wheel event to a control.

Mode 1 (Position): Specify the X and Y coordinates relative to the target window's upper left corner. The X coordinate must precede the Y coordinate and there must be at least one space or tab between them. For example: X55 Y33. If there is a control at the specified coordinates, it will be sent the click-event at those exact coordinates. If there is no control, the target window itself will be sent the event (which might have no effect depending on the nature of the window).


I like the idea of using PostMessage / SendMessage to try to accomplish this but it doesn't appear that AHK currently allows for that command to have that kind of control by itself. There may be a solution using DllCall or COM but my limited knowledge of that type of AHK usage prevents me from digging into it.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 23rd, 2009, 8:50 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
Well, I was wrong about the difficulty of finding a value for lParam and PostMessage. I was able to send a click from PostMessage in two different programs without moving the mouse. Here are my two tested hotkeys:

Code:
#NoEnv
SetTitleMatchMode, 2
SendMode Input
SetWorkingDir %A_ScriptDir%


<====clicks a link at a specific location in Firefox===>
#IfWinActive ahk_class MozillaUIWindowClass
!x::
PostMessage, 0x201, 0x00000000, 0x0087035b, , ahk_id 0x15037a ; WM_LBUTTONDOWN at 859, 135
PostMessage, 0x202, 0x00000000, 0x0087035b, , ahk_id 0x15037a ; WM_LBUTTONUP at 859, 135
return

<====presses Play/Pause on Windows Media Player===>
#IfWinActive ahk_class WMPlayerApp
^x::
PostMessage, 0x201, 0x00000000, 0x023601a8, , ahk_id 0xb03d6 ; WM_LBUTTONDOWN at 424, 566
PostMessage, 0x202, 0x00000000, 0x023601a8, , ahk_id 0xb03d6 ; WM_LBUTTONUP at 424, 566
return



A big thanks goes to SKAN and his pictorial using WinSpector Spy to show me that I needed to adjust my options to show the message parameters on one line. You have to monitor the WM_LBUTTONUP messages to obtain the lParam and you can monitor the WM_LBUTTONDOWN messages to obtain the x/y coordinates you clicked at.

While it is an interesting proof of concept, I don't know how useful it is necessarily (to me anyway). Given that I retrieved several lParams for various clicks on the screen I can see that there is a logical alphanumeric naming convention for each x/y coordinate, I just can't pin down what that logic is so I can create the lParam myself. Granted, once you know the lParam for a specific coordinate it appears to be set in stone on your computer, but having to pull an lParam for some coordinate from messages every time you need it seems like a big waste of time.

For another thing, I was not able to make the click work using anything but the window handle (ahk_id %hwnd%). While that doesn't seem like a big deal, if you're a Firefox user, good luck. The window handle you need to send clicks to a webpage changes every time you go to a new page or even refresh your current page. Fortunately the window handle in IE7 is constant under each tab as far as my testing has shown.

In the minor annoyances category I also couldn't make the click work without specifying 0x00000000 in wParam.

I'm delighted to see that it works. The window handle issue will almost surely keep me from trying to use it with Firefox, but it may be useful in other applications with some testing. If someone can find a way to nail down the logic of the naming convention for lParam, that would make this a lot easier to utilize.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: chaosad, Exabot [Bot], Google Feedfetcher, jrav and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group