forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Alt Key and Left Mouse Button Down Simultaneously???

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Wed Aug 04, 2004 5:37 pm    Post subject: Alt Key and Left Mouse Button Down Simultaneously??? Reply with quote

Hi All,

Would someone out there be able to provide an example of how to determine if a user clicks the left mouse button while the Alt key is pressed down?

Example: User holds down the Alt key, clicks the left mouse button, then an event occurs....

Perhaps by using GetAsyncKeyState???

Thanks,

- Boo
Back to top
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Wed Aug 04, 2004 7:18 pm    Post subject: Reply with quote

Give this a try and see if this does what you need:

Code:
  OPTION SLEEPTIME,20
  DIALOG CREATE,Test,-1,0,200,100
  DIALOG SHOW
  LOADLIB USER32
  %%ALT = @lib(user32,GetAsyncKeyState,int:,$12)
  %%ALT = 0

:EVENTLOOP
  WAIT EVENT,0
  %E = @event()
  IF %E
    GOTO %E
  END
  GOTO EVENTLOOP

:TIMER
  %%ALT = 0
  %%ALT = @lib(user32,GetAsyncKeyState,int:,$12)
  IF @both(@mousedown(L),@unequal(%%ALT,0))
    INFO It's a go for launch!
  END
  GOTO EVENTLOOP

:CLOSE
  FREELIB USER32
  EXIT

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Wed Aug 04, 2004 7:57 pm    Post subject: Reply with quote

Hi Garrett,

Long time no type! Wink

Thanks for the example. However, it does not seem to work on my end. 8-(

I previously was playing around with the following:

Code:

Title My Dialog
DIALOG CREATE,MY DIALOG,-1,0,496,125,CLASS MYWIN
DIALOG SHOW
LOADLIB USER32
%%ALT = @lib(user32,GetAsyncKeyState,int:,$12)
%%LMOUSE = @lib(user32,GetAsyncKeyState,int:,$01)
%%ALT = 0
%%LMOUSE = 0
:Evloop
 wait event,0.06
 goto @event()
:TIMER
 %%ALT = @lib(user32,GetAsyncKeyState,int:,$12)
 %%LMOUSE = @lib(user32,GetKeyState,int:,01)
 IF @NOT(@equal(%%ALT,0))
 If @NOT(@equal(%%LMouse,0))
 INFO Goto Event!
 end
 end
%%ALT = 0
%%LMOUSE  = 0
goto EVLOOP


Problem is, I can click separately with the left mouse button, and then separately on the Alt key, to get the response. However, I need a solution that only works when they are pressed simultaneously....

Cheers,

- Boo
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Wed Aug 04, 2004 10:05 pm    Post subject: Reply with quote

This should work for ya:
Code:

LOADLIB user32.dll
%%VK_LMENU = $A4
%%VK_RMENU = $A5
%%VK_LBUTTON = $01
Title My Dialog
  DIALOG CREATE,MY DIALOG,-1,0,496,125,CLASS MYWIN
  DIALOG SHOW
:evloop
  wait event,0.01
  goto @event()
:Timer
  REM Check both alt keys
  %%LAlt = @LIB(user32,GetAsyncKeyState,INT:,%%VK_LMENU)
  %%RAlt = @LIB(user32,GetAsyncKeyState,INT:,%%VK_RMENU)
  %%LButton = @LIB(user32,GetAsyncKeyState,INT:,%%VK_LBUTTON)
  if @BOTH(@UNEQUAL(%%LAlt,0),@UNEQUAL(%%LButton,0))@BOTH(@UNEQUAL(%%RAlt,0),@UNEQUAL(%%LButton,0))
    INFO Alt & Left Mouse Button Down
  end
  REM Call again to clear
  %%LAlt = @LIB(user32,GetAsyncKeyState,INT:,%%VK_LMENU)
  %%RAlt = @LIB(user32,GetAsyncKeyState,INT:,%%VK_RMENU)
  %%LButton = @LIB(user32,GetAsyncKeyState,INT:,%%VK_LBUTTON)
  goto evloop
:Close
  exit

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Wed Aug 04, 2004 10:12 pm    Post subject: Reply with quote

Sweeeeeeeeeeeeeeeeeeeeet! Cool

Thanks Sheep! As always -- YOU ROCK!

Cheers,

- Boo
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Thu Aug 05, 2004 2:15 am    Post subject: Reply with quote

Glad to help.
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group