Jump to content

MouseWheel SWAP Direction & Set Window to Same Position


Recommended Posts

I have Windows7 x64 and i wrote my script that run my browser, and until it is active
Mouse Wheel have direction inverted (i would use this function also for my VideoPlayer)
but don't run.
Using AutoHotKey is sufficent these 2 rows:

        WheelUp::WheelDown
        WheelDown::WheelUp

Under AutoIT i have problems.
I have proved under different programs as "Windows Explorer" - "PowerDVD" - "FireFox"  but wheel
is crazy when running my script.
In addiction when i Run my program i want that its window is showed always with same user dimension
in the same fixed area of my screen also if i can change this parametres using it.
I know only function "MOVE" that don't permit me to have window that program opens already in user
position/dimension but moves it in that area and i see window in previos position before move it.

#NoTrayIcon
#include <Winapi.au3>
#include <MouseOnEvent.au3>

HotKeySet("{ESC}", "Quit")
_MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT, 'Event')
_MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, 'Event')


Global Const $GWL_STYLE = 0xFFFFFFF0
; Global Const $WS_BORDER = 0x00800000
Global $Up = 0
Global $Down = 0


Run("Slimboat.exe", "", @SW_MINIMIZE)
While NOT WinExists("SlimBoat")
    Sleep(10)
WEND


; Run Minimized & Then Restore Window to Remove its Border. If i RUN program normally it
; shows on screen its window with border & my script don't take effect to remove it after

        $hW = WinGetHandle("SlimBoat")
        $features = _WinAPI_GetWindowLong($hW, $GWL_STYLE)
        $NewFeatures = BitXOR($features, $WS_BORDER)
    
        _WinAPI_SetWindowLong($hW, $GWL_STYLE, $NewFeatures)

        Sleep(20)
        WinSetState ( $hW, "", @SW_RESTORE)


    
; I Would that Program opens its Window in same position with same dimension
; also user in previous session has changed them, but i know only "WINMOVE"
    
    WinMove($hW, "", @DesktopWidth/2, 1, @DesktopWidth/2-5, @DesktopHeight-30)
        



        
;  If i remove MouseWheel command the ToolTip shows correctly Up and Down
;  choice also if Tooltip don't disappear  :-(

While ProcessExists("SlimBoat.exe")
    If WinActive("SlimBoat") Then   
        Select
            Case $up = 1
                ;ToolTip ( "Change Up to Down" )
                ;sleep(1000)
                MouseWheel("Down")
                $up = 0

            Case $Down = 1
                ;ToolTip ( "Change Down to Up" )
                ;sleep(1000)
                MouseWheel("up")
                $Down = 0
        EndSelect
    Endif
    
    ; Activate Again Mouse Event
    _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT, 'Event')
    _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, 'Event')     
Wend        
        
        

Func Event($iEvent)
    Switch $iEvent
        Case $MOUSE_WHEELSCROLLUP_EVENT
            $up = 1
        Case $MOUSE_WHEELSCROLLDOWN_EVENT
            $Down = 1
    EndSwitch

    _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT)    ; *unset* the $iEvent to make MouseWheel Without Loop
    _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT)
EndFunc
        
            

            
Func Quit()
    ProcessClose("Slimboat.exe")
    Exit
EndFunc
Edited by mercadantelaura
Link to comment
Share on other sites

The only way that i'm be able to code in order to invert mouse wheel direction under AutoIT
is running default program that i want use follow starts my small script wrote into "AutoHotKey" code.
 

....
Run("MyProgram.exe")
Run("WheelSWAP.exe")

#NoTrayIcon
Loop
{
    Sleep 250
    IfWinNotExist, PowerDVD
        EXITAPP
}

#IfWinActive, PowerDVD  
    WheelUp::WheelDown
    WheelDown::WheelUp

if someone can explain me how convert correctly my autohotkey script into AutoIT i can use only one EXE for my purpose

Thanks

Link to comment
Share on other sites

Thanks infact i have coded same 2 rows into my script AutoHotkey reading the exact link that you have post me.

I have hopened that AutoIT have possibility to include this function.

To answer to you : AutoHotkey function runs very well for me.

When is active Porgram that i want wheel direction is Swapped and when the program close

the script Auto-exit

Edited by mercadantelaura
Link to comment
Share on other sites

  • 7 years later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...