AutoHotkey Community

It is currently May 26th, 2012, 3:54 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: April 9th, 2009, 8:16 pm 
Offline

Joined: January 22nd, 2007, 6:19 pm
Posts: 16
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2009, 8:41 pm 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3329
Location: Simi Valley, CA
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2009, 9:07 pm 
Offline

Joined: January 22nd, 2007, 6:19 pm
Posts: 16
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 ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2009, 9:14 pm 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3329
Location: Simi Valley, CA
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2009, 9:22 pm 
Offline

Joined: January 22nd, 2007, 6:19 pm
Posts: 16
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) ?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Exabot [Bot], notsoobvious, Yahoo [Bot] and 23 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