Double click if / else

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Double click if / else

11 May 2023, 09:22

Good day. Been trying for a bit with no results. all I am trying to do is use say my o key for normal use but with a double click run another program. It simply doesn't work for some reason.Everything seams right. Any ideas out there? Tk's

Code: Select all

#InstallKeybdHook
#InstallMouseHook

DubbleClik()
{

KeyWait, %A_ThisHotkey% 
Sleep 10
KeyWait, %A_ThisHotkey%, D, T0.20 
If ErrorLevel = 1
{	
Return True 
}
Else 
{
Return False
}
}

o::
{

if (DubbleClik())
	{
	Send {o}
	}
Else
	{
Run, "E:\PortableApps\PortableApps\AutoHotkeyPortable\AHK Scripts\Browsers\Brave Portable.ahk"
	}
Return
}
magicshow
Posts: 67
Joined: 14 Oct 2022, 11:38

Re: Double click if / else

11 May 2023, 10:23

add #UseHook on
jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Re: Double click if / else

11 May 2023, 10:40

Perfect Magicshow. Once i figured out there was a space between the k and on all was good. Now to play with other configuration's.Thank you.Cheer's
jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Re: Double click if / else

11 May 2023, 10:52

@magicshow. 1 quick question magicshow.Why is there a delay when pressing key and it showing in search box. IE press bubt there is about a .25 delay ebfore it appears in box.Double click works fine. As you can see the e came ebfore the b. Tk's

Code: Select all

#InstallKeybdHook
#InstallMouseHook
#UseHook On

DubbleClik()
{

KeyWait, %A_ThisHotkey% 
Sleep 10
KeyWait, %A_ThisHotkey%, D, T0.10 
If ErrorLevel = 1
{	
Return True 
}
Else 
{
Return False
}
}

b::
{

if (DubbleClik())
	{
	Send {b}
	}
Else
	{
Run, "E:\PortableApps\PortableApps\AutoHotkeyPortable\AHK Scripts\Browsers\Brave Portable.ahk"
	}
Return
}



	
	
	
	
	
	
magicshow
Posts: 67
Joined: 14 Oct 2022, 11:38

Re: Double click if / else

11 May 2023, 12:40

I refer to this type of remapping as "no passthrough double press." Unfortunately, the delay is unavoidable, and even professional remapping software on the market (which is not free) cannot solve this issue. Personally, I have given up on this remapping method due to the delay. If I need the double press function for a key, I simply let the first two trigger keys pass through or use hotstrings instead.
jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Re: Double click if / else

11 May 2023, 12:49

@magicshow. Ok I understand that that there is nothing I can do for current issue. Have no idea what you are saying about trigger etc. Can you maybe send me an example so I can educate myself. Tks
jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Re: Double click if / else

12 May 2023, 07:28

@magicshow. I am very new at all this but trying. What do you mean by passing through the first 2 trigger keys. Would really like to use double shift if possible but without delay.Can this be done? Thank you

Code: Select all

#InstallKeybdHook
#InstallMouseHook
#UseHook On

DubbleClik()
{

KeyWait, %A_ThisHotkey% 
Sleep 10
KeyWait, %A_ThisHotkey%, D, T0.20
If ErrorLevel = 1
{	
Return True 
}
Else 
{
Return False
}
}

b::

{

if (DubbleClik())

	{
	Send {b}
	}
Else
	{
Run, "E:\PortableApps\PortableApps\AutoHotkeyPortable\AHK Scripts\Browsers\Brave Portable.ahk"
	}
Return
}



	
	
	
	
	
	
magicshow
Posts: 67
Joined: 14 Oct 2022, 11:38

Re: Double click if / else

13 May 2023, 03:19

Let me explain the two methods:

The "no passthrough" method involves a delay in the program's recognition of a trigger keys. If you press "a" twice quickly for a "b", the program will only recognize "b" and skip (or not capture) your first two "a" keystrokes. "a" will be recognized only when it is not part of a fast double press. By the way, my old setting for the keywait timing was 0.088.

On the other hand, the "passthrough" method captures all keystrokes and processes them within the program.
For example, if you press "a" twice quickly for a "b", the program will still capture and output both first "a" keystrokes and then output "b" .
The advantage of the passthrough method is that there is no delay for the trigger keys (a), but "a" will pass through to the programs, which may cause another problem.


This is the demo of passthrough method by using hotstrings
:B1*si:aa::b ; aa > b
jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Re: Double click if / else

13 May 2023, 05:12

@magicshow. Thank you very much for the explanation. Now I understand. Now to the hotstrings. Is this how I would make it work or does it get installed with another script? Tk's

Code: Select all

#InstallKeybdHook
#InstallMouseHook
#UseHook On


:B1*si:aa::Run, "E:\PortableApps\PortableApps\AutoHotkeyPortable\AHK Scripts\Browsers\Brave Portable.ahk" ; aa > baa
Return
jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Re: Double click if / else

13 May 2023, 14:59

@magicshow. Well I am almost got it with process of elimination. Here is where I am at. i have double a working to run program but for some reason when I am typing in say my firefox search box if I type in say aaron or even in this reply box as soon as I hit double a program starts. Any ideas?Do I need something besides asterisk? Tk's

Code: Select all

:*:aa::
Run, "E:\PortableApps\PortableApps\AutoHotkeyPortable\AHK Scripts\Browsers\Brave Portable.ahk"
Return
ananthuthilakan
Posts: 188
Joined: 08 Jul 2019, 05:37
Contact:

Re: Double click if / else

14 May 2023, 08:24

Code: Select all

~a::
if (A_PriorHotkey <> A_ThisHotkey Or A_TimeSincePriorHotkey > 400)
		Return
Run, "E:\PortableApps\PortableApps\AutoHotkeyPortable\AHK Scripts\Browsers\Brave Portable.ahk"
Return
jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Re: Double click if / else

14 May 2023, 08:56

@ananthuthilakan .Thank you for your help. your code works fine unless I am open in say notepad or search.As soon as I press double anything it brings up that program. IE i have oo set to open opera.As soon as I press oo in this reply to you the first o shows up and then disappears and opera opens. No idea why. If you have any other ideas let me know .Tks
ananthuthilakan
Posts: 188
Joined: 08 Jul 2019, 05:37
Contact:

Re: Double click if / else

14 May 2023, 21:19

play with the time 400, reduce it to find a middle ground.
when you double click faster it will bring the program , when you click 2 times slower it wont bring up the program

another way is to add something that will check for notepad or you are typing.

or create a toggle to enable and disable all of your hotkeys
jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Re: Double click if / else

15 May 2023, 05:50

@ananthuthilakan. Thank you for your suggestions but nothing works. Adjusting time up or down does nothing. Setting active window does nothing.Confused about hotkey suggestion.If i turn off will everything not work? And how would I create a toggle to do it? any other ideas? quite like your idea as well as this hotstring code I have.It is odd.When I type soon all is fine but if I type something starting with oo it opens opera right away.In order for it to work I have to turn off all running scripts. Maybe toggle on/off would work?

Code: Select all

;#NoTrayIcon
#InstallKeybdHook
#InstallMouseHook
#UseHook On

:*:BB::
Run, "E:\PortableApps\PortableApps\AutoHotkeyPortable\AHK Scripts\Browsers\Brave Portable.ahk"
Return
	
:*:CC::
SendInput, {Ctrldown}c{Ctrlup} 
Return
		
:*SE, k1000:FF::
Run, "E:\PortableApps\PortableApps\AutoHotkeyPortable\AHK Scripts\Browsers\Firefox Portable.ahk"
Return

:*:HH::
SendInput, {F4} 
Return

:*:MM::
Run,  "E:\PortableApps\PortableApps\AutoHotkeyPortable\AHK Scripts\PC Tool's\AltTab.ahk"
Return

:*:OO::
Run, "E:\PortableApps\PortableApps\OperaPortable\OperaPortable.exe"
Return

:*:PP::
Run, "E:\PortableApps\PortableApps\PortableApps.com\PortableAppsPlatform.exe"
Return

:*:TT::
Run, "E:\PortableApps\PortableApps\ThunderbirdPortable\ThunderbirdPortable.exe"
Return

:*:VV::
SendInput, {Ctrldown}v{Ctrlup}
Return
jrachr
Posts: 545
Joined: 01 Mar 2021, 17:33

Re: Double click if / else

15 May 2023, 06:11

Got it. I can make this work. Tk's to all for your help.Cheer's

Code: Select all

WM_COMMAND := 0x111
CMD_RELOAD := 65400
CMD_EDIT := 65401
CMD_PAUSE := 65403
CMD_SUSPEND := 65404

DetectHiddenWindows, On

Process, Exist
this_pid := ErrorLevel
control_id := WinExist("ahk_class AutoHotkey ahk_pid " this_pid)

; Press Home to toggle Pause & Suspend state for all scripts.
z::
WinGet, id, list, ahk_class AutoHotkey
Loop, %id%
{
	this_id := id%A_Index%
    If (this_id <> control_id)
	{
		PostMessage, WM_COMMAND, CMD_PAUSE,,, ahk_id %this_id%
		PostMessage, WM_COMMAND, CMD_SUSPEND,,, ahk_id %this_id%
	}
}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], DRS and 89 guests