Jump to content

I wrote this script and it wont work - (Moved)


Recommended Posts

I want it to pop up a message when I roll the mouse wheel button up and down, here is the script

 

$wheelclick = 1 & 0
$movewheel =  "down" & "up"

MouseWheel($movewheel,$wheelclick)


While 1

    If    $movewheel = "down" & $wheelclick = 1 Then
        ToolTip("down", 0, 0)

    ElseIf  $movewheel = "up" & $wheelclick = 1 Then
         ToolTip("up", 0, 0)

    EndIf
WEnd
 

Edited by jacky998877
Link to comment
Share on other sites

you are assigning $wheelclick the string  '10' ( '&' is for joining things together as strings )
likewise for $movewheel, you assign it the string 'downup'
MouseWheel() only moves the mouse wheel, if you provide the right parameters. (see https://www.autoitscript.com/autoit3/docs/functions/MouseWheel.htm ) however it doesn't provide output of the mousewheel position
in your While loop, nothing alters the values of $movewheel or $wheelclick, and both If/ElseIf statements are false at the start of the loop so the Tooltip() in both will never be reached

those are just some mistakes. you need to find a UDF on the forum for detecting mousewheel events perhaps, i don't know how to do that

Edited by lIlIIlIllIIIIlI
Link to comment
Share on other sites

1 hour ago, lIlIIlIllIIIIlI said:

you are assigning $wheelclick the string  '10' ( '&' is for joining things together as strings )
likewise for $movewheel, you assign it the string 'downup'
MouseWheel() only moves the mouse wheel, if you provide the right parameters. (see https://www.autoitscript.com/autoit3/docs/functions/MouseWheel.htm ) however it doesn't provide output of the mousewheel position
in your While loop, nothing alters the values of $movewheel or $wheelclick, and both If/ElseIf statements are false at the start of the loop so the Tooltip() in both will never be reached

those are just some mistakes. you need to find a UDF on the forum for detecting mousewheel events perhaps, i don't know how to do that

I think the "UDF file" idea is reasonable, before i do anything it will do it for me , some detecting mechanism is needed, and the rest of the idea you have mentioned i need time to process them 😃

Link to comment
Share on other sites

2 hours ago, jacky998877 said:

I want it to pop up a message when I roll the mouse wheel button up and down, here is the script ...

@lIlIIlIllIIIIlI has already addressed some bugs in your script and recommended to search for an existing solution.

@jacky998877 : You're probably looking for something like this :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

_Example()

; _Example
Func _Example()
    GUICreate("My GUI", 640, 480, 50, 50) ; will create a dialog box that when displayed is centered

    GUIRegisterMsg($WM_MOUSEWHEEL, "_WM_MOUSEWHEEL")

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $GUI_EVENT_PRIMARYDOWN
                Sleep(250)
                ToolTip("")
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>_Example

Func _WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    Local $iMPos = MouseGetPos()

    Switch $wParam
        Case 0x00780000
            ToolTip("Mouse wheel UP is detected!" & @CRLF & @CRLF & 'Click in the "My GUI" to return...', $iMPos[0], $iMPos[1], "Wheel UP", 1, 3)
        Case 0xFF880000
            ToolTip("Mouse wheel Down is detected!" & @CRLF & @CRLF & 'Click in the "My GUI" to return...', $iMPos[0], $iMPos[1], "Wheel Down", 1, 3)
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_MOUSEWHEEL

(Origin : is-it-possible-to-detect-the-mouse-whee-move by @JScript )

Edited by Musashi
typo

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states:

Quote

Share your cool AutoIt scripts, UDFs and applications with others.


Do not post general support questions here, instead use the AutoIt Help and Support forums.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

jacky998877,

When you reply in future, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - responders know what they wrote and it just pads the thread unnecessarily. Thanks in advance for your cooperation.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

1 hour ago, jacky998877 said:

 it can open a exe file by rolling the wheel ,but it must depend on a gui, if the gui is deleted the whole script will not work 

Then I recommend you to take a look at the mouseonevent-udf made by @MrCreatoR . There you will also find various example scripts.

Here is an approach of mine (created on the fly) ;).

#include <MouseOnEvent.au3>

HotKeySet("{ESC}", "_Terminate")
$hGUI = WinGetHandle("")

_MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT, "MOUSE_WHELLSCROLL_UP", "", "", $hGUI)
_MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, "MOUSE_WHELLSCROLL_DOWN", "", "", $hGUI)

While True
    Sleep(100)
WEnd

Func MOUSE_WHELLSCROLL_UP()
    Local $iMPos = MouseGetPos()
    ToolTip("Mouse wheel UP is detected!" & @CRLF, $iMPos[0], $iMPos[1], "Wheel UP", 1, 3)
    Sleep (2000)
    ToolTip("")
EndFunc

Func MOUSE_WHELLSCROLL_DOWN()
    Local $iMPos = MouseGetPos()
    ToolTip("Mouse wheel Down is detected!" & @CRLF, $iMPos[0], $iMPos[1], "Wheel Down", 1, 3)
    Sleep (2000)
    ToolTip("")
EndFunc

Func _Terminate()
    ToolTip("")
    Exit
EndFunc   ;==>_Terminate

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
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
 Share

  • Recently Browsing   0 members

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