Middle Click / F3 Topic is solved

Ask gaming related questions
Guest

Middle Click / F3  Topic is solved

03 Dec 2016, 17:18

Hi,
is there a possibility to emulate the middle mouse button is pressed when I press:
F3

That means, when I press F3 on the keyboard it automatically press the:
Middle Mouse button
too. I'm using the Logitech G700s mouse.
In World of Warcraft the "Middle Mouse Button" and any other mouse buttons, are blocked on the user interface such as HP Bars.
So when I'm using mouse over macros to heal other people, and the spell lays on a side mouse button OR middle mouse button (pressed mouse wheel) it's not working (blocked).

That's why I changed everything to:
F1, F2, F3 up to F9

Now I have a problem.
When I press the mouse wheel (middle button) it's F3.
But you close new browser tabs with middle mouse button, or you open new task in the windows task bar. Or you close chat tabs in World of Warcraft with middle mouse button (like browser tabs).
So I tried to adjus this in the Logitech Gaming Software.
Like a "macro". F3 and middle mouse button with one single middle mouse button click.
The problem:
- You can't use mouse buttons in the macro editor of the logitech gaming software.....

So I thought maybe autohotkey can do the trick.
When I press F3 it automatically simulate / emulate (what ever) the middle mouse button click for me.
If that's not possible, maybe in the opposit? Middle mouse button simulate F3 click?!

Is it possible to "detect" which window is focused with Autohotkey?!
I don't think so, but this would be nice :-P Because then I could make something like:
When in WoW, F3 + Middle mouse button
When not in WoW, only middle mouse button


Thanks for your help.
hugin
Posts: 15
Joined: 17 Aug 2016, 01:33

Re: Middle Click / F3

03 Dec 2016, 19:45

Short answer:
From your answer, even a bit long, you are just asking to emulate Middle Mouse Button Right?

If so:

Code: Select all

F3::MButton
Thats it.

Longer answer:
If you want to add more code to your Middle Mouse Click:

Good luck!

hugin
homezonebenny
Posts: 18
Joined: 23 Apr 2016, 08:36

Re: Middle Click / F3

08 Dec 2016, 01:27

Thx @hugin:

Code: Select all

;Middle Click Macro
F4::
Send, {F3}{MButton}
return
This script is (nearly) working.

1. Open Google Chrome
2. Press F3 (without any script) = it opens the "search menu" in the right top corner (normal F3 behaviour)
3. Press MiddleMouseButton = it opens the scroll menu. Press Middle Click again to close the scroll menu.
4. Press F4 (with the script above). It opens the search menu (right top) and the scroll menu. WORKS !!!!!

Now I have 2 problems. A functional problem and the problem that it's not working with F3:: only with F4:: let me explain:

1. Problem: Mouse Scroll Function
When you do Step 3 in Google Chrome you can open the scroll menu with the middle click, and you can close the scroll menu with the middle click.
1st click = you can scroll with mouse movement. 2nd (middle) click you close that menu again. Normal behaviour.
When you do the same with my F4:: script it opens the scroll menu, when you press F4 (on keyboard) again it's NOT closing the scroll menu again, like it SHOULD :-\

2. Problem: It's not working with F3::
That means even IF I'm able to fix Problem 1 it's still not working with F3:: instead of F4::
I tested stuff like that:

Code: Select all

;Middle Click Macro
F3::
Send, {F3}
SetKeyDelay, 1
Send, {MButton}
return
But that's not working. It's exactly the same like my first (F4::) script on top of this post. Guess this is because an "endless loop" of F3?!

Do you have any idea about those 2 problems?!
I mean problem 2 is the MOST important problem. Because I want the F4:: script working with F3:: that's the goal.
The Problem 1 is only a MEH thing. Because normal middle click can enable / disable that scrolling menu. Why the script is not doing this?! O.o


EDIT:
Interesstingly this is working:

Code: Select all

;Middle Click Macro
MButton::
Send, {F3}
SetKeyDelay, 1
Send, {MButton}
return
This gives me the "search" + "scroll" in google chrome. Problem 1 (close scroll menu again) is still not working.
But when I do the same with F3:: instead of MButton:: it's not working again O.o
It's only doing the Send, {MButton} but not Send, {F3} :-\
You can test that MButton:: script above, and just replace MButton:: with F3:: and test it with F3 on your keyboard.
I'm a bit confused to be honest. I could change my world of warcraft spell from F3 back to middle mouse button and use the MButton:: script above.
But I like it the way it is. That the spells are on F1 F2 F3 and I bound those keys on my mouse (Logitech G700s Thumb Keys).
And F3 is the mouse wheel click. So it's always working. I only need the script then, when I use google chrome + playing world of warcraft to close chrome tabs with middle click (F3).
hugin
Posts: 15
Joined: 17 Aug 2016, 01:33

Re: Middle Click / F3

10 Dec 2016, 21:20

Try to add:
$F3::
to your Hotkey, like this:

Code: Select all

;Middle Click Macro
$F3::
Send, {F3}
SetKeyDelay, 1									; Why not just use: Sleep 50?
Send, {MButton}
return
Code not tested, but should be the issue you have with your F3 key, because:
$
This is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise cause it to trigger itself. The $ prefix forces the keyboard hook to be used to implement this hotkey, which as a side-effect prevents the Send command from triggering it. The $ prefix is equivalent to having specified #UseHook somewhere above the definition of this hotkey.

The $ prefix has no effect for mouse hotkeys, since they always use the mouse hook. It also has no effect for hotkeys which already require the keyboard hook, including any keyboard hotkeys with the tilde (~) or wildcard (*) modifiers, key-up hotkeys and custom combinations.

[v1.1.06+]: #InputLevel and SendLevel provide additional control over which hotkeys and hotstrings are triggered by the Send command.
Link: Hotkeys

I'm not sure if that was all you had on your mind, it's late here and I might misunderstand you questions.
But I will take a look at your issue later. But I have not worked with Chrome or any other browser scripting. So I'm not sure I can help you with that.
Make sure that you need, or do not need to use: IfWinExist / IfWinNotExist / WinExist or #IfWinActive / #IfWinExist.
You can control you app and corresponding script for it, (e.g. Apps Active Window) in a much controlled way than without.
Without, you can send the commands to any window theoretically. With #IfWinActive you control what Window App that will receive the code.

When using AU3_Spy.exe on Chrome I get this:

Code: Select all

ahk_class Chrome_WidgetWin_1
ahk_exe chrome.exe
So, with this info, we can do this:

Code: Select all

#IfWinActive ahk_class Chrome_WidgetWin_1 	; Checks if the specified window exists and is currently active

;Middle Click Macro
$F3::
Send, {F3}
SetKeyDelay, 1									; Why not just use: Sleep 50?
Send, {MButton}
return
Now the script will only work when Chrome window is active.

To retrieve window data the easy way, use AU3_Spy.exe, that is implemented in AutoHotkey, look under AutoHotkey's install path to find it.
Tip, use a lot of time searching forum for code, and go trough the Docs, that helped me a lot when starting up with AutoHotkey. And you will find tons of scripts and code.

Hope this help you at least a bit ;)[/font]
homezonebenny
Posts: 18
Joined: 23 Apr 2016, 08:36

Re: Middle Click / F3

11 Dec 2016, 22:24

Thanks, helped alot.
Didn't know about $ this simple change fixed it:

Code: Select all

;Middle Click Macro
$F3::
Send, {F3}{MButton}
return
About chrome. I realised that it's only in chrome, that you can't active / deactivate the scrolling middle click feature (while moving the mouse).
Because F3 enables the "search field" in chrome. In FireFox for example it's working. Middle Click activate / deactivate the scrolling with mouse movement.

So theoretically I have 2 options now:
1. I set my mouse middle click button to default (normal middle click) and check IF I'm in World of Warcraft, and then I set my script. Which gives me MiddleClick+F3 at the same time
2. I set my mouse middle click to F3. Set my script to MiddleClick+F3 WHEN I'm in WoW. And when I'm not in WoW it's only middle click.

Not sure what I like the most.
In both variants I'll need the script running when I'm playing World of Warcraft. So I would pref 1. option.
Because then my middle click is normal behaviour everywhere in Windows. Only in World of Warcraft it will be MiddleClick+F3.

When I check World of Warcraft it shows me:

Code: Select all

>>>>>>>>>>( Window Title & Class )<<<<<<<<<<<
World of Warcraft
ahk_class GxWindowClass
GxWindowClass seems like everything with DirectX or something?!
That means this would be active in every game?! Because it's not like google chrome. When you check chrome it's

Code: Select all

ahk_class Chrome_WidgetWin_1
So theoretically I have to check two things.

Code: Select all

;Middle Click Macro
IF(ahk_class == GxWindowClass && WindowTitle == "World of Warcraft) {
  $MButton::::
  Send, {F3}{MButton}
  return
}
I have to read about syntax of IF statements in AHK.
And how to check the ahk class / Window Title.
But then it should work like I want it.

So I can set middle click to default (for my mouse) and AutoHotkey script should replace the middle click with the "macro".
MiddleClick + F3 at one click.


PS:
For your question with the sleep.
I used both. I used sleep, and keydelay. Both worked. So I thought I stick with keydelay because it's a key thing im using, don't know what would be better.
But I don't need a sleep or keydelay. Because the script works with SEND without anything.
And like I know the difference between "send" and "sendinput" is, that send "types" every letter, one after another.
And sendinput sends everything at once. So when I'm using "send" it would type a long text letter by letter (like fast typing my own).
And sendinput sends the whole text completly in one second.

Could you correct me the text above (IF statement). I'll search the forum and read some docs.
So I should make it work my own anyways any time soon :)

A BIG thanks again <3 You really helped me.
And it's fun. For my first experience with AHK.


I already created a "nipple sound board". Like press a hotkey to play a sound:

Code: Select all

<^<+<!c::
sendinput {Media_Play_Pause}
Run, "C:\Program Files\VideoLAN\VLC\vlc.exe" --qt-start-minimized "D:\Programme\Tools\AutoHotkey\001 SoundFiles\011_Female-Vocal-Countdown.mp3"
sleep 12200
sendinput {Media_Play_Pause}
return
And it works like a charm :-) The only thing I "don't like" is that I have to open the sound file, see how's the LENGHT of the file (time).
And then I have to set the milliseconds for the sleep :-\ I was searching for a "check if the file is done playing" auto function or something, but I didn't find anything.
But anyways. The sleep works. The script simply PAUSE the media player (when I'm listening to music), plays the sound file, and after the sound file the music continues (play again).
I'm using that for my stream. So I can play funny sounds for the viewers :-)
I mean, it's not a big deal to set the sleep by my own. I don't change the sound files every day :-P
But AutoHotkey is fun so far. Thanks again.


EDIT:
This works like a charm now:

Code: Select all

#IfWinActive World of Warcraft ahk_class GxWindowClass
$MButton::
Send, {F3}{MButton}
return
#IfWinActive
hugin
Posts: 15
Joined: 17 Aug 2016, 01:33

Re: Middle Click / F3

15 Dec 2016, 12:04

homezonebenny wrote:Thanks, helped alot.
Didn't know about $ this simple change fixed it:

Code: Select all

;Middle Click Macro
$F3::
Send, {F3}{MButton}
return
About chrome. I realised that it's only in chrome, that you can't active / deactivate the scrolling middle click feature (while moving the mouse).
Because F3 enables the "search field" in chrome. In FireFox for example it's working. Middle Click activate / deactivate the scrolling with mouse movement.
Sure np ;)
I just started with AHK 4 or 5 months ago myself. But, I do code a little in VB, VBA, as a relic from engineer school and found coding to be really fun and useful if you are over medium interested in computers.

As of late I have been struggling with my fingers not working as they should anymore, so I started to look for solutions beyond Keyboard macros and stuff and discovered AutoHotkey.

That saved on my fatigue a lot and made me play games for a lot longer, and then I discovered what the Script language really could do by browsing trough the forums, And I was hooked!

Just so you know, I am very much an amateur, and not near any other of the coders in this forum. So my answers might not be the correct or the most smooth way to code.
But I will anyway tell if there are something I have no clue or have no experience in. I am sure you can get better answers from others in here if you ask them.


Anyway, if I recall correctly, I think the forum has a lot about Chrome browser and Ahk issues/ solutions, so you are not alone anyway.
I don't use Chrome, have it installed, but just as a backup when FF don't work in the Net bank etc.

Search the forum for Chrome and I am sure you will find other, similar issues/ solutions.
homezonebenny wrote: So theoretically I have 2 options now:
1. I set my mouse middle click button to default (normal middle click) and check IF I'm in World of Warcraft, and then I set my script. Which gives me MiddleClick+F3 at the same time
2. I set my mouse middle click to F3. Set my script to MiddleClick+F3 WHEN I'm in WoW. And when I'm not in WoW it's only middle click.

Not sure what I like the most.
In both variants I'll need the script running when I'm playing World of Warcraft. So I would pref 1. option.
Because then my middle click is normal behaviour everywhere in Windows. Only in World of Warcraft it will be MiddleClick+F3.
If you don't need to change anything other than in WoW, I don't see the issue, if you need to remap for both instances, just make two scripts or make one were you put it in a loop or a timer, to check which window is active with #IfWinActive ahk_class GxWindowClass? Controlling two instances should be straight forward from what you want to do.

homezonebenny wrote: I already created a "nipple sound board". Like press a hotkey to play a sound:

Code: Select all

<^<+<!c::
sendinput {Media_Play_Pause}
Run, "C:\Program Files\VideoLAN\VLC\vlc.exe" --qt-start-minimized "D:\Programme\Tools\AutoHotkey\001 SoundFiles\011_Female-Vocal-Countdown.mp3"
sleep 12200
sendinput {Media_Play_Pause}
return
And it works like a charm :-) The only thing I "don't like" is that I have to open the sound file, see how's the LENGHT of the file (time).
And then I have to set the milliseconds for the sleep :-\ I was searching for a "check if the file is done playing" auto function or something, but I didn't find anything.
But anyways. The sleep works. The script simply PAUSE the media player (when I'm listening to music), plays the sound file, and after the sound file the music continues (play again).
I'm using that for my stream. So I can play funny sounds for the viewers :-)
I mean, it's not a big deal to set the sleep by my own. I don't change the sound files every day :-P
But AutoHotkey is fun so far. Thanks again.
For playing sound files in the script, I use this method:

SoundPlay, %A_WinDir%\Media\Windows Logon.wav This will find the path Win Directory (usually C drive) and then play the: \Media\Windows Logon.wav sound file. Yes, you are correct, this use the Windows OS Media Sound Files from its original A_WinDir path.



For "local", custom sound files, put your sound file or your Ahk script file in the same directory and use:

SoundPlay, %A_ScriptDir%\Windows Notify.wav I use a original Win media File here, but you can use any file as long it has the Extension as .wav or .mp3 if I recall correctly. Maybe some limitation in lenght, but I have not tested this, so i guess you can do that your self.

Controller: SoundPlay, Filename [, wait]



And look, it has an answer to your code when it comes to solving figuring the lenght of your file, by using: , Wait. This gives us:

SoundPlay, %A_WinDir%\Media\Windows Logon.wav , Wait for Win Media files, and custom files would be: SoundPlay, %A_ScriptDir%\Windows Notify.wav, Wait


This means this one line of code will take care of anything you have mentioned to get solved ;)




Win Media Files path: C:\Windows\Media
autohotkey.com/docs: SoundPlay, Filename [, wait]


So, if you use different sounds when you stream, this means you can set up a Ahk script with Hotkeys for each sound, use the , wait at end so the file will play to the end before you are allowed to do any other input to the script. Meaning if you accidentally hit another Sound Hokey, it will not play before the first one is done playing.


Quick and dirty put together, but hope this will help you a bit on your scripting adventures, good luck! ;)
homezonebenny
Posts: 18
Joined: 23 Apr 2016, 08:36

Re: Middle Click / F3

16 Dec 2016, 06:48

Thanks for your response.
I'm a programmer aswell. Mainly in the Web (building website for my living, HTML / CSS, JavaScript, PHP / MySQL sometimes Java).

So it's not that big of a deal to code with AHK.
It's just the time to look into how everything works. Normally I should read the documentation of AHK and Syntax to get ready fast. But yeah :-P

I just put back my mouse to default function. That means Middle Click is Middle Click again.
And I'm using this script:

Code: Select all

#IfWinActive World of Warcraft ahk_class GxWindowClass
$MButton::
Send, {F3}{MButton}
return
#IfWinActive
I used it with $F3:: instead of the MButton. So this worked perfect when I bound my middle click to F3 in my mouse software.
But default is better, because the Middle Button works in all Browsers and everywhere. Only WoW adds the F3 now. So this is the perfect solution.
BUT now I figured out something strange.

When I press:
Shift MButton, CTRL MButton, ALT MButton
it's not working. it's not using the script. Interesstingly it was WORKING with $F3:: but not with $MButton:: ...
So, I could simply just add all the modificators (SHIFT, ALT, CTRL) to the script, or figure out why it's not working.


EDIT:
I made a pastebin for an IRC AutoHotkey Chat I was asking for it:
http://pastebin.com/raw/ewH2DP7L

It's strange that the behaviour of a MButton script is different than a F3 button script...
It's the same code, same syntax. It should work in the same way. So AHK feels extremly strange to be honest.
Maybe AHK act differently with mouse buttons compared to keyboard buttons. But it shouldn't...


I made a new post here:
https://autohotkey.com/boards/viewtopic ... 18&t=25723
(because it's a different topic. Maybe it's a bug in AHK because MouseButtons act differently then keyboard buttons)

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 38 guests