 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
doggy4s
Joined: 22 Jan 2007 Posts: 16
|
Posted: Thu Apr 09, 2009 7:16 pm Post subject: LButton click if do, else LButton normal |
|
|
Hi All
Been trying to manipulate a clickable graphical button that changes color according to its action (similar to a play/stop button)
Using a hotkey all works well. Problem arrises when I try to use the mouse in the rest of the window as normally.
Tried various ways (even with a SetTimer) but this is the closest i got to make it work properly be it that i can not drag anything in de window ( like sliders)
All other ways I tried basically 'clicked' on the button again before it could change state. Dont feel like putting in a sleep state or alike as not to mess with the other actions of the program running
any hints please
| Code: |
LButton::
MouseGetPos, ,,,pos
if pos = BitmapButton
{
Goto,test
}
Click LButton
return
$^Z::
test:
ColorA := 0x5D5D5D
ColorB := 0xACACAC
IfWinActive,WinTitle
{
ControlGetPos, x, y, w, h,BitmapButton, WinTitle
x:=x+14
y:=y+11
PixelGetColor, color, %X%, %Y%,RGB
ifEqual, color, %ColorA%
{
SetControlDelay -1
ControlClick,BitmapButton,WinTitle
}
else ifEqual, color, %ColorB%
{
Do Something Extra
SetControlDelay -1
ControlClick,BitmapButton,WinTitle
}
return
}
|
Thanks much |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
Posted: Thu Apr 09, 2009 7:41 pm Post subject: |
|
|
So, if I understand correctly, you want the left mouse button to behave differently when the mouse is over a certain control (BitmapButton) ?
Just going off your code...
| Code: | $LButton::
MouseGetPos, ,,,pos
if pos = BitmapButton
{
Goto,test
}
Click L Down
Keywait, LButton
Click L Up
return
;... etcetera... |
 _________________ Ternary (a ? b : c) guide TSV Table Manipulation Library
Post code inside [code][/code] tags! |
|
| Back to top |
|
 |
doggy4s
Joined: 22 Jan 2007 Posts: 16
|
Posted: Thu Apr 09, 2009 8:07 pm Post subject: |
|
|
| Quote: | | left mouse button to behave differently when the mouse is over a certain control |
Correct.
Thanks , it works
| Quote: | Click L Down
Keywait, LButton
Click L Up |
Mind explaining the logic please ? |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 3254 Location: Simi Valley, CA
|
Posted: Thu Apr 09, 2009 8:14 pm Post subject: |
|
|
no problem,
the $ sign in front of the hotkey tells the script to use the Mouse Hook to implement the hotkey... I'm not sure what the difference is exactly, but it probably helps.
The Click commands should be obvious, "click left down" and "click left up" are self-explanatory.
The KeyWait command waits for the user to physically release the mouse button before allowing the script to proceed, hence enabling the left mouse button to be 'down' for however long the user holds it. _________________ Ternary (a ? b : c) guide TSV Table Manipulation Library
Post code inside [code][/code] tags! |
|
| Back to top |
|
 |
doggy4s
Joined: 22 Jan 2007 Posts: 16
|
Posted: Thu Apr 09, 2009 8:22 pm Post subject: |
|
|
hmm
I did try it before with Keywait but from what i see one has to 'repeat' the Lbutton first again .
Although when the key is then released one has to give the instruction to force the state (U/D) ? |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|