Sign in to follow this  
Followers 0
tallow

floating list box

8 posts in this topic

Hi Guys

I have a program that supports floating list boxes whenever i right click on screen i get a menu. one item in the list is very commonly used.

I would like to create a script that would activate in the following way.

When i right click, the mouse cursor would automatically jump the required number of pixels and auto left click the menu.

I assume a hotkey would be needed in order to enable disable the function.

Can anyone show me the way here.

Thanks for any help in advance. :D

Share this post


Link to post
Share on other sites



Is that anywhere on the screen or just the list box thing, sorry, what you want to do isn't the most specific.

look at MouseGetPos and MouseMove

MouseGetPos should return $array[0] = x and $array[1] = y

you then need, mousemove with coords $array[0] + 10 and $array[1] - 20 (just an example). this moves the mouse relatively to the cursor position.

however, I think you would be better off using the keyboard, as sometimes menu's can go up, rather than down, eg if your in the bottom corner. right click in your browser and press B (I use firefox, but it should be similar in other browsers). this will send you back. see if you can do the same with your menu, it should underline the key-letter.

Share this post


Link to post
Share on other sites

Is that anywhere on the screen or just the list box thing, sorry, what you want to do isn't the most specific.

look at MouseGetPos and MouseMove

MouseGetPos should return $array[0] = x and $array[1] = y

you then need, mousemove with coords $array[0] + 10 and $array[1] - 20 (just an example). this moves the mouse relatively to the cursor position.

however, I think you would be better off using the keyboard, as sometimes menu's can go up, rather than down, eg if your in the bottom corner. right click in your browser and press B (I use firefox, but it should be similar in other browsers). this will send you back. see if you can do the same with your menu, it should underline the key-letter.

When you right click anywhere on screen the same menu pops up

So if i get you correctly you need to build a script around MouseGetPos upon right click so the script knows where the mouse is,

then MouseMove the required number of pixels and MouseClick (left) voila one working script.

I will have a go this evening and see if i can accomplish this. thanks for your help really appreciated.

Incidentally your right about menu changing relative position to cursor when at extreme edges hadnt noticed if im honest before.

However it wont effect me as i always approx centre of screen for this function.

Share this post


Link to post
Share on other sites

Hi

I have looked at various scripts to give me a clue and have come up with the following script.

Yes theres a but

it works but for one thing .

the mouse cursor dissapears of to the top left handside of the screen instead of relative to the cursor.

I assume i have done something wrong with regard to mousegetpos and mousemove.

Any hints please greatfully received

HotKeySet("{F4}", "StartProg") 
HotKeySet("{ESC}", "EndProg")

; Infinite loop
While 1
Sleep(100)
WEnd

Func StartProg()
    MouseClick ("right")
    $pos = MouseGetPos() 
    MouseMove(0, 50)
    Sleep (100)
EndFunc

Func EndProg()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

tallow,

Mouse coordinates are relative to the screen (unless you alter this using Opt(MouseCoordMode)). So you need to add your "move" pixels to the position of the mouse as it clicks. Try this:

Func StartProg()
    MouseClick ("right")
    $pos = MouseGetPos() 
    MouseMove($pos[0], $pos[1] + 50)
    Sleep (100)
EndFunc

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

tallow,

Mouse coordinates are relative to the screen (unless you alter this using Opt(MouseCoordMode)). So you need to add your "move" pixels to the position of the mouse as it clicks. Try this:

Func StartProg()
    MouseClick ("right")
    $pos = MouseGetPos() 
    MouseMove($pos[0], $pos[1] + 50)
    Sleep (100)
EndFunc

M23

Thank you i was just putting that together when you replied I ended up with this and it works perfectly except for a misunderstanding on my part.

I had assumed that the f4 hotkey would enable the script rather than run it I actually want to be able to enable disable the macro with say f4

so that when enabled any right click will run script and when disabled normal right click operation.

Any clues on that one :D

HotKeySet("{F4}", "StartProg") 
HotKeySet("{ESC}", "EndProg")

; Infinite loop
While 1
WEnd

Func StartProg()
    MouseClick ("right")
    $pos = MouseGetPos() 
    MouseMove($pos[0] + 50, $pos[1] + 75)
    MouseClick ("left")
EndFunc

Func EndProg()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

tallow,

Great minds thinking alike, eh?

In this script F4 now acts a toggle which, when set, hijacks the right mouseclick to run the "Special_Right_Click" code instead:

#include <GUIConstantsEx.au3>
#include <MouseSetOnEvent_UDF.au3>

Global $fFunc_State = False, $fRunning = False

HotKeySet("{F4}", "ToggleProg")
HotKeySet("{ESC}", "EndProg")

; Infinite loop
While 1
    Sleep(100)  ; <<<< very important or you use 100% CPU!
WEnd

Func Special_Right_Click()
; Only run it once per click
    If $fRunning = True Then Return
    $fRunning = True
; Do our "right click" thing!
    MouseClick("right")
    $pos = MouseGetPos() 
    MouseMove($pos[0] + 50, $pos[1] + 75)
    MouseClick ("left")
; Reset the flag
    $fRunning = False
EndFunc

Func ToggleProg()
; Toggle the flag
    $fFunc_State = Not $fFunc_State
; If set, use our mouse function
    If $fFunc_State Then
        _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT, "Special_Right_Click")
    Else
        _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT); Renable normal mouse button
    EndIf
EndFunc

Func EndProg()
    Exit
EndFunc

You will need to download the MouseSetOnEvent UDF from MrCreatoR which you can find here. The rest of the script is pretty self-explanatory (I hope!)

I had fun with this. :-) Thanks for the problem - keeps the old grey cells active (and my mind off the mother-in-law's imminent arrival for Easter!).

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Wow thanks for that it all works perfectly

We call ours outlaws by the way lol

Is there a way to substitute the f4 key for either the back mouse button on my intellimouse or press middle button.

Just a nice to have not essential.

Thank you for all your help.

I can see me spreading the word on scripting autoit style

So powerfull.

Happy holidays.

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