RegiOween Posted June 1, 2016 Share Posted June 1, 2016 (edited) Hello, folks! I'm trying to define Win key + Mouse scroll (up and down) as hotkey in my script, but after a deep search in the forum, and many topics about set mouse events as hotkey, I still haven't found a solution to this specific scenario. I tried _IsPressed internal function, and also MouseOnEvent, MouseTrapEvent and HotKeySetEx UDFs, and all of them work fairly well, but apparently just for single mouse events, and not combined like I need to (a modifier key + a mouse scroll movement). I also read something about mouse hooks, dll call, and complex stuff like that, but my knowledge about these things is very limited, so I decided to ask here for help. What I got so far, and is working incredibly well, is unfortunately a solution that came from the "competitor" (AutoHotKey): WinWaitClose, ahk_class AppClass ExitApp #If WinActive("ahk_class AppClass") #WheelDown::SendPlay X #WheelUp::SendPlay Y It took me just minutes to learn how to do this in AHK, but it's kinda sad that with all these years coding with AutoIt, I didn't get a solution as simple as this one, but I really want to do all the code inside AutoIt, if possible of course... In case you want to know, the purpose is to use this combination of keyboard modifier + mouse scroll to change brush properties in Photoshop. Thanks in advance, RegiOween Edited June 1, 2016 by RegiOween Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 1, 2016 Moderators Share Posted June 1, 2016 RegiOween, Quote but it's kinda sad that with all these years coding with AutoIt, I didn't get a solution I find it "kinda sad" that after having been a member here for over 10 years you could not find a solution which took me about 10 minutes to produce: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> HotKeySet("{ESC}", "_Exit") Local $hDLL = DllOpen("user32.dll") GUICreate("", 0, 0, 0, 0) GUISetState() GUIRegisterMsg($WM_MOUSEWHEEL, "_WM_MOUSEWHEEL") While 1 Sleep(10) WEnd Func _WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Local $iDelta = BitShift($wParam, 16) ; Mouse wheel movement If _IsPressed("5B", $hDLL) Then ; If Left Win pressed <<<<<<<<<<<<<< If $iDelta > 0 Then ConsoleWrite("Down" & @CRLF) Else ConsoleWrite("Up" & @CRLF) EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_Scrollbars_WM_MOUSEWHEEL Func _Exit() Exit EndFunc And not a "mouse hooks, dll call" in sight..... By the way, at the moment it only works for the left Win key - adding the right Win key I leave as "an exercise for the student", as my old maths teacher used to say. M23 JLogan3o13 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
RegiOween Posted June 1, 2016 Author Share Posted June 1, 2016 Melba, Again, sorry for my lack of knowledge, but trust me, I did a lot of reading about this subject, and didn't find a solution, or maybe the solution was right in front of me, and I didn't see it... About your code, I don't use SciTE, so I just replaced ConsoleWrite for MsgBox, but I guess it's ok, right? Unless I miss something, the code works, but with a big drawback: The Win key is still triggering the Start menu when I release the key, stealing the focus of the active window, and the Start menu stay open until I close it manually. I tried messing with different values of SendKeyDelay and SendKeyDownDelay, and replace the MsgBox with an actual Send, but it seems that didn't make any difference. Also, I tried replacing MsgBox for ToolTip, believing that could be something related to timing, but the issue is the same. As you can see, I'm trying to make my exercise, but as I said before, I really want to keep studying in AutoIt school, despite the lessons are quite hard to solve sometimes... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now