AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

weird hotkey help

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Mon Apr 21, 2008 7:23 pm    Post subject: weird hotkey help Reply with quote

im trying to make a weird hotkey.

I want to press the left mouse button and then a letter to do something.
But i want the left mouse button NOT TO trigger if the hotkey was pressed and TO trigger if it was pressed.

Any help would be appreciated.
Back to top
View user's profile Send private message
TheIrishThug



Joined: 19 Mar 2006
Posts: 370

PostPosted: Mon Apr 21, 2008 7:28 pm    Post subject: Reply with quote

Make a hotkey for the left mouse button. Then use KeyWait with a timeout and errorlevel to see if the second key was pressed. If it wasn't send the left mouse button. NOTE: the timeout will make your normal left clicks take longer to register, so you do not want it to be too long.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Mon Apr 21, 2008 7:34 pm    Post subject: Reply with quote

that would defeat the purpose of the hotkey.
Is there a way to have it the other way?---
press key and only trigger if mouse has peen pressed without a timeout?
Back to top
View user's profile Send private message
TheIrishThug



Joined: 19 Mar 2006
Posts: 370

PostPosted: Mon Apr 21, 2008 8:55 pm    Post subject: Reply with quote

GetKeyState could work too. I used KeyWait because I needed differentiate between a double click vs a click and hold.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Mon Apr 21, 2008 10:35 pm    Post subject: Reply with quote

Do u have an idea of how that could be done because im lost still?
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 1128

PostPosted: Tue Apr 22, 2008 12:29 am    Post subject: Reply with quote

here's what you're asking for:
Code:
$LButton::
If PUI("keydown:enter")
   Gosub, Sub%A_OtherKey%
Else
   Click, left, down
return

~$LButton Up::return

SubENTER:
   msgbox You pressed enter while holding the left button
return

PUI( Option_String )
{ ; imaginary library standard function "Predict User Intention" ARG1: *char
   #Include MS_ISL_SOURCE.LIB
}


If you'd rather have it so that the left button activates a series of hotkeys, then deativates them when you release the left button, just say so.
_________________
My Home Thread
More Common Answers: 1. It's in the FAQ 2. Ternary ( ? : ) guide 3. Post code with [code][/code] tags
Back to top
View user's profile Send private message
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Tue Apr 22, 2008 4:54 am    Post subject: Reply with quote

[VxE] wrote:

If you'd rather have it so that the left button activates a series of hotkeys, then deativates them when you release the left button, just say so.

That is exactly what i want.
Back to top
View user's profile Send private message
orbik



Joined: 09 Apr 2008
Posts: 25
Location: Espoo, Finland

PostPosted: Tue Apr 22, 2008 5:20 am    Post subject: Re: weird hotkey help Reply with quote

Deller wrote:

But i want the left mouse button NOT TO trigger if the hotkey was pressed and TO trigger if it was pressed.


Is it just me, or does this sentence look like an oxymoron?
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 1128

PostPosted: Tue Apr 22, 2008 6:46 am    Post subject: Reply with quote

Deller wrote:
[VxE] wrote:

If you'd rather have it so that the left button activates a series of hotkeys, then deativates them when you release the left button, just say so.

That is exactly what i want.


Try
Code:
HotkeysToToggle = a|b|c ; pipe delimiter
GoSub, TurnEmOff

$*LButton::
Loop, Parse, HotkeysToToggle, |
   Hotkey, %A_LoopField%, %A_LoopField%, on
Sleep 500 ;///////////// this is how long you have to press another key
If A_ThisHotkey = $*LButton
   Click Left Down
TurnEmOff:
Loop, Parse, HotkeysToToggle, |
   Hotkey, %A_LoopField%, %A_LoopField%, off
return

$*LButton Up::
If GetKeyState("LButton")
   Click Left Up
Else If A_PriorHotkey = $*LButton
   Click
GoSub, TurnEmOff
return

a::msgbox, you pressed 'a' shortly after pressing the left button
b::msgbox, you pressed 'b' shortly after pressing the left button
c::msgbox, you pressed 'c' shortly after pressing the left button


a regular click will pass when the button is released. To click-drag, you need to hold the LButton for half a second before it will pass the button-down event. Also, if the script opens a msgbox, it won't pass clicks.
_________________
My Home Thread
More Common Answers: 1. It's in the FAQ 2. Ternary ( ? : ) guide 3. Post code with [code][/code] tags
Back to top
View user's profile Send private message
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Tue Apr 22, 2008 10:56 pm    Post subject: Reply with quote

I found a solution.

Code:

~LButton::gosub, on
~LButton Up::gosub, off
return

on:
Hotkey, f, f, on
Hotkey, t, t, on
Hotkey, c, c, on
Hotkey, g, g, on
Hotkey, p, p, on
Hotkey, d, d, on
Hotkey, a, a, on
return


off:
Hotkey, f, f, off
Hotkey, t, t, off
Hotkey, c, c, off
Hotkey, g, g, off
Hotkey, p, p, off
Hotkey, d, d, off
Hotkey, a, a, off
return

f:
Run, C:\Program Files\Mozilla Firefox\firefox.exe
return

t:
Run, E:\
return

c:
Run, cmd
return

g:
Run, C:\Documents and Settings\USER\Desktop\Gadgets
return

p:
C:\Program Files\Corel\Corel Graphics 12\Programs\Corel PHOTO-PAINT 12
return

d:
C:\Documents and Settings\USER\My Documents
return

a:
C:\Program Files\PSPad editor\PSPad.exe
return

esc::exitapp
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 848
Location: London, UK

PostPosted: Tue Apr 22, 2008 11:41 pm    Post subject: Reply with quote

I thought you didnt want the click to register.

In that case the solution would be

Code:
~Lbutton & f::
Run, C:\Program Files\Mozilla Firefox\firefox.exe
return


Does the same thing but a lot easier.
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Deller



Joined: 21 Nov 2007
Posts: 202
Location: 0x01101110

PostPosted: Tue Apr 22, 2008 11:46 pm    Post subject: Reply with quote

but its more organized with functions. Razz
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group