Sign in to follow this  
Followers 0
Neoborn

Mouse Hook... Help?

7 posts in this topic

:D Can someone please for the love of chocolate ice cream show me how to use this Mouse hook etc?

http://www.autoitscript.com/forum/index.php?showtopic=23173

Thanks,

:D Neoborn :P


~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Larry posted a demonstration script along with the dll.

If I were to adapt this code to my purposes I would start by acting on the message details instead of displaying them.

What are you trying to accomplish? This might not even be what you need.

Edit: Larry beat me to the post.

@Larry: Excellent work, as usual.

Edited by Skruge

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

All depends on what you want to do... seriously, your question is nearly unanswerable.

Lar.

My original code was:

#Include <File.au3>

$up = MouseWheel("up", 1)
$dw = MouseWheel("down", 1)
HotKeySet($up, "Move1")
HotKeySet($dw, "Move2")


While 1
Sleep(250)
WEnd


Func Move1()
MsgBox(48, "", "hi")
If WinExists("Transcender Practice Exam - Cert-N10-003", "") Then
WinActivate("Transcender Practice Exam - Cert-N10-003", "")
If MouseWheel("Up", 1) Then
Send("!n")
EndIf
EndIf
HotKeySet($up)
EndFunc

Func Move2()
If WinExists("Transcender Practice Exam - Cert-N10-003", "") Then
WinActivate("Transcender Practice Exam - Cert-N10-003", "")
If MouseWheel("Down",1) Then
Send("!p")
EndIf
EndIf
HotKeySet($dw)
EndFunc

What I would like to do is when in that specified program mouse wheel up sends alt N and mouse wheel down sends alt p.

Edited by Neoborn

~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites

Try this:

Const $WH_MOUSE = 7
Const $WM_AUTOITMOUSEWHEELUP = 0x1400 + 0x0D30
Const $WM_AUTOITMOUSEWHEELDOWN = 0x1400 + 0x0D31

HotKeySet("{ESC}", "GoAway")

$gui = GUICreate("test")

Global $DLLinst = DllCall("kernel32.dll", "hwnd", "LoadLibrary", "str", ".\hook.dll")
Global $mouseHOOKproc = DllCall("kernel32.dll", "hwnd", "GetProcAddress", "hwnd", $DLLinst[0], "str", "MouseProc")

Global $hhMouse = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE, "hwnd", $mouseHOOKproc[0], "hwnd", $DLLinst[0], "int", 0)

DllCall(".\hook.dll", "int", "SetValuesMouse", "hwnd", $gui, "hwnd", $hhMouse[0])

GUIRegisterMsg($WM_AUTOITMOUSEWHEELUP, "myfunc")
GUIRegisterMsg($WM_AUTOITMOUSEWHEELDOWN, "myfunc")

Dim $WinTitle = "Transcender Practice Exam - Cert-N10-003"

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then ExitLoop
WEnd

Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam)
        Select 
            case winactive($WinTitle) and $msgid=$WM_AUTOITMOUSEWHEELUP
                send("!n")
            case winactive($WinTitle) and $msgid=$WM_AUTOITMOUSEWHEELDOWN
                send("!p")
            EndSelect
EndFunc  ;==>MyFunc

Func GoAway()
    Exit
EndFunc  ;==>GoAway

Func OnAutoItExit()
    DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hhMouse[0])
    DllCall("kernel32.dll", "int", "FreeLibrary", "hwnd", $DLLinst[0])
EndFunc  ;==>OnAutoItExit

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

Tried no worky :D


~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites

Tried no worky :D

I don't have any Transcenders, so I set $WinTitle = "Notepad" and changed the send keys to "WheelUp"/"WheelDown"... works like a charm.

My guess is that the title isn't a match.

Set WinTitleMatchMode to 2 and $WinTitle = "Transcender".

Did you try Larry's script? If his doesn't work for you, neither will mine.


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

I hang my head in shame, it works beautifully but the thing is you need to put the .dll in the same folder as the script :D

sigh

Thank you

Sincerely

Nubcakes.


~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0