IanN1990 Posted February 10, 2013 Share Posted February 10, 2013 (edited) I Have cut this code out of my main script. It seams i have a small problem.Many months ago, i replaced my logitch drivers with my own autoit functions (as i use autoit wherever i can now). The code below is ment to do 4 things. Enable the side buttons to control volume, pause/play music, next/prev track and to that effect it all works very well but i have noticed a few times "I think during Dayz (Arma 2) and League of Legends (LoL) the game seams to stop my script from working. Meaning i cant control my volume or music from mouse.Does anyone know why this is happening ?expandcollapse popup#NoTrayIcon #include 'WinApi.au3' Local $MouseClick, $MouseSideButton, $MouseHoldAdlib _WinAPI_SetWindowsHookEx(14 , DllCallbackGetPtr(DllCallbackRegister('MouseHook', 'long', 'int;wparam;lparam')), _WinAPI_GetModuleHandle(0)) ;Mouse Hook While 1 sleep(2500) WEnd Func MouseHook($nCode,$wParam,$lParam) Switch $wParam Case '0x20B', '0x20C' ;Side Buttons $MouseClick+=1 If $MouseHoldAdlib Then $MouseHoldAdlib=Adlib('VolUp', '') $MouseClick=Adlib('VolDn', '') ElseIf $MouseClick=1 Then $MouseSideButton=DllStructGetData(DllStructCreate('struct;long X;long Y;endstruct;dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo',$lParam),3) AdlibRegister('MouseHookDetection',225) EndIf Return 1 Case '0x20E' ;Wheel Buttons If DllStructGetData(DllStructCreate('struct;long X;long Y;endstruct;dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo',$lParam),3)=7864320 Then Return ControlClick('Windows Media Player','WMPAppHost','[CLASS:WMPAppHost; INSTANCE:1]','Left',1,1000,1025) If DllStructGetData(DllStructCreate('struct;long X;long Y;endstruct;dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo',$lParam),3)=4287102976 Then Return ControlClick('Windows Media Player','WMPAppHost','[CLASS:WMPAppHost; INSTANCE:1]','Left',1,900,1025) EndSwitch EndFunc Func MouseHookDetection() If $MouseClick=1 And $MouseSideButton=131072 Then $MouseHoldAdlib=Adlib('VolUp', '25') If $MouseClick=1 And $MouseSideButton=65536 Then $MouseHoldAdlib=Adlib('VolDn', '25') If $MouseClick=2 And $MouseSideButton=131072 Then $MouseClick=Not VolUp() If $MouseClick=2 And $MouseSideButton=65536 Then $MouseClick=Not VolDn() If $MouseClick>2 Then $MouseClick=-ControlClick('Windows Media Player','WMPAppHost','[CLASS:WMPAppHost; INSTANCE:1]','Left',1,950,1025) $MouseSideButton=Adlib('MouseHookDetection', '') EndFunc Func Adlib($Function, $Time) If $Time Then Return AdlibRegister($Function, $time)*0+1 If Not $Time Then Return AdlibUnRegister($Function)*0 EndFunc Func VolUp() Return Run('"C:\Program Files (x86)\Scripts\Source\Includes\Software\nircmd.exe" changesysvolume 1250') EndFunc Func VolDn() Return Run('"C:\Program Files (x86)\Scripts\Source\Includes\Software\nircmd.exe" changesysvolume -1250') EndFunc**NirCmd.exe is a windows command ulity. http://www.nirsoft.net/utils/nircmd.htmlI dont belive there is a fault in the code, as that works 99.9% of the time for all other windows. I belive the game is preventing my hook from working but wanted to get others views. Edited February 10, 2013 by IanN1990 Link to comment Share on other sites More sharing options...
JohnOne Posted February 10, 2013 Share Posted February 10, 2013 Some games block autoit, because people use it for game bots and cheating, but I'm sure you know that. Good luck, but I'll be surprised if someone helps you with a way to hide autoit from game protection. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
IanN1990 Posted February 10, 2013 Author Share Posted February 10, 2013 (edited) I didn't infact, such a thought didnt cross my mind. Though i reading what you said i found it weird that LoL would block autoit but it did give me the answer. To play LoL on Windows 7, the game has to be run as "Admin". I run my script has normal, and i remember from the past autoit cant interaction with things that are "admin" unless autoit is admin. So Adding #RequireAdmin Solves the problem. Edited February 10, 2013 by IanN1990 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 10, 2013 Moderators Share Posted February 10, 2013 IanN1990,such a thought didnt cross my mindWell, please make sure it does before you post anything like this again. M23 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...
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