Sign in to follow this  
Followers 0
anybastard

MouseMove function

6 posts in this topic

Hi guys ,

as usual i need your help !!

I'm trying to automatize my test and to do this i want use MoveMouse function . ( for me this is the first time with this function )

I looked in on the net and i found this code

Const $addWidthInPixels = 0
Const $addHeightInPixels = 0

MouseMove(Int(@DesktopWidth*.5),Int(@DesktopHeight*.5),0)
MsgBox(0,"Begin Test","Press enter to begin test.")

MouseMove(Int(@DesktopWidth*.38 + $addWidthInPixels),Int(@DesktopHeight*.97 +$addHeightInPixels),20)

This code works fine the first mouse move function put the mouse cursor in the middle of my screen -> open -> a message box -> press ok -> and put the mouse on the task bar

But i don't understand these :

Int(@DesktopWidth*.5),Int(@DesktopHeight*.5) or (Int(@DesktopWidth*.38 + $addWidthInPixels),Int(@DesktopHeight*.97 +$addHeightInPixels),20)

how can i know the cordinates like .5 or .38 or .97 ? is there a tool ??

Please could you explain me this or give me a link to understand this script ??

Thanks a lot

Regards

AnyB.

Share this post


Link to post
Share on other sites



anybastard,

Those are just simple decimal numbers which set the mouse coordinates to a certain percentage of the value. :mellow:

So Int(@DesktopWidth * .5) and Int(@DesktopHeight * .5) wil give you values equal to 50% (or half) of the desktop size. That is how the script gets the mouse to the centre of the screen.

Int(@DesktopWidth*.38 + $addWidthInPixels) will return a value equal to 38% of the width of the desktop plus whatever value you have in the $addWidthInPixels variable - currently 0. The Int function will ensure that you get an integer return as 38% of the desktop might not be an exact integer.

Similarly Int(@DesktopHeight*.97 + $addHeightInPixels) will give you a value equal to 97% of the height of the desktop plus $addHeightInPixels.

You should find the mouse moving to about 1/3 of the way across the screen from the left and very nearly at the bottom. :)

All clear? :)

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

Hi Melba .

first for all thanks for your prompt

Those are just simple decimal numbers which set the mouse coordinates to a certain percentage of the value. -> Clear

So Int(@DesktopWidth * .5) and Int(@DesktopHeight * .5) wil give you values equal to 50% (or half) of the desktop size. That is how the script gets the mouse to the centre of the screen. - Clear , this mean that in any case my mouse pointer will be in middle of the screen ( screen resolution or size indipendent )

Int(@DesktopWidth*.38 + $addWidthInPixels) will return a value equal to 38% of the width of the desktop plus whatever value you have in the $addWidthInPixels variable - currently 0. The Int function will ensure that you get an integer return as 38% of the desktop might not be an exact integer. -> Clear

Similarly Int(@DesktopHeight*.97 + $addHeightInPixels) will give you a value equal to 97% of the height of the desktop plus $addHeightInPixels. -> this isn't clear , becouse this mean that if i run my script on two desktops with different resolution and / or size my mouse position is different . Am I right ?

Last question ...is there a workflow or tool to find this percentage ??

Thanks again

Regards

AnyB

Share this post


Link to post
Share on other sites

anybastard,

Int(@DesktopWidth * .38) and Int(@DesktopHeight * .97) will put your mouse in the same relative position on any resolution screen - 38% of the way across and 97% of the way down. :mellow:

This position will be modified if you then add the 2 contants and use Int(@DesktopWidth * .38 + $addWidthInPixels) and Int(@DesktopHeight * .97 + $addHeightInPixels). But both these constants are set to 0 in the snippet you posted and so will have no effect - I have no idea why they are there, go and look at the script from which you took the snippet. :)

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

#5 ·  Posted (edited)

Melba ,

Now all is clear .... thanks for that

I just found a new function " MouseGetPosition" or use AutoIt windows info to find coordinates this mean that if i know screen resolution and cordinates i found the percentages . am i right?

ciaoo

AnyB

Edited by anybastard

Share this post


Link to post
Share on other sites

anybastard,

if i know screen resolution and cordinates i found the percentages

Correct. :mellow:

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

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