Jump to content

A script which saves the mouse coordinates to work them?


Gadoz
 Share

Recommended Posts

Hey,

 

I have a problem, which I can't solve yet...

I want build a script, which allows me to save the mouse coordinates as a variable to work with them, if I'm pressing the Hotkey.

My script won't start, If I'm pressing F5 on the SciTE Editor, no errors or something.

 

Could someone help me?

 

#RequireAdmin

HotKeySet("{F9}", "Position")
HotKeySet("{F8}", "Start")
HotKeySet("{F11}", "End")

Global $aPos = 0

Func Position()
while 1
$aPos = MouseGetPos()
wend

EndFunc

Func Start()    
MouseClick("Left", $aPos[0], $aPos[1])
EndFunc

Func End ()
Exit
EndFunc

 

Edited by Gadoz
Link to comment
Share on other sites

  • Developers

Let me guess: It does start but ends right away without doing anything...  right?

#RequireAdmin

HotKeySet("{F9}", "Position")
HotKeySet("{F8}", "Start")
HotKeySet("{F11}", "End")

Global $aPos = 0

Func Position()
    While 1
        $aPos = MouseGetPos()
    WEnd

EndFunc   ;==>Position

Func Start()
    MouseClick("Left", $aPos[0], $aPos[1])
EndFunc   ;==>Start

Func End()
    Exit
EndFunc   ;==>End

Have a close look again at your script again! There is nothing to be done and it will reach the end right away.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

But why? I don't see the problem :( ...

 

My logical way is: I start the Script. Now it is waiting for user actions.

So if F9 is pressed, it saves the mousecoordinates through mousegetpos, under $aPos

Everytime If I press F8, my mouse will go on the position which is saved under $aPos.

 

 

Link to comment
Share on other sites

Thank you, this works now

#RequireAdmin

HotKeySet("{F9}", "Position")
HotKeySet("{F8}", "Start")
HotKeySet("{F11}", "End")

Global $aPos = 0

Func Position()

$aPos = MouseGetPos()

EndFunc

Func Start()

MouseClick("Left", $aPos[0], $aPos[1])

EndFunc

while 1
    Sleep(50)
    WEnd

Func End ()
Exit
EndFunc

 

Edited by Gadoz
Link to comment
Share on other sites

Is this possible to get the MouseGetPos from the actual window and not from my whole resolution (1920x1080)?

So the coordinates will always same, even I move the window.

 

If yes, how can I do it, you can link me the help files :)

Edited by Gadoz
Link to comment
Share on other sites

  • Developers
Link to comment
Share on other sites

  • Developers

Just run this script and see the difference :)

AutoItSetOption("MouseCoordMode",0)
$ph=Run("Notepad.exe")
Sleep(500)
$aPos= WinGetPos("[ACTIVE]")
ConsoleWrite("X-Pos: " & $aPos[0] & "  Y-Pos: " & $aPos[1] & "  Width: " & $aPos[2] & "  Height: " & $aPos[3] & @CRLF)
MouseMove(0,0)
MsgBox(0,"MouseCoordMode 0","Pos (0,0)")
AutoItSetOption("MouseCoordMode",2)
MouseMove(0,0)
MsgBox(0,"MouseCoordMode 2","Pos (0,0)")
ProcessClose($ph)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Is this possible to store 2-3 mousegetpos as variable with one Hotkeyset?

I mean, evertime If I have pressed F9, mousegetpos will save the current position of my mouse.

My script is actually doing: its just take only one mousegetpos - the always last one.

Maybe I'm thinking logical wrong, and this is not working on autoit expect I create a new hotkey..

 

#RequireAdmin

HotKeySet("{F9}", "Position")
HotKeySet("{F8}", "Start")
HotKeySet("{F11}", "End")

Global $aPos = 0
Global $aPos1 = 0

Func Position()

$aPos = MouseGetPos()
$aPos1 = MouseGetPos()

EndFunc

Func Start()
MouseClick("Left", $aPos[0], $aPos[1], 2)
MouseClick("Left", $aPos1[0], $aPos1[1], 2)

EndFunc

while 1
    Sleep(50)
    WEnd

Func End ()
Exit
EndFunc

 

 

 

 

Link to comment
Share on other sites

¡Hi Gadoz!

 

Seems you're having problems?

 

Try locating the While loop right after the HotKeySet statements.

 

When you run the script, it saves the MousePosition before you ask for it, that's why you're having problems when saving the wanted coordenates.

 

Try this script:

 

#RequireAdmin
Global $aPos = 0
Global $aPos1 = 0

HotKeySet("{F9}", "Position")
HotKeySet("{F8}", "Start")
HotKeySet("{F11}", "End")
Call ("SleepForUser")

Func SleepForUser()
While 1
   Sleep (100)
WEnd
EndFunc

Func Position0()
MsgBox (0, "Waiting for user", "Put your mouse at the wanted position to save Pos0" )
$aPos = MouseGetPos()
MsgBox (0, "Waiting for user", "Put your mouse at the wanted position to save Pos1" )
$aPos1 = MouseGetPos()
MsgBox(0, "Success", "Sucessfully saved mouse locations")
Call("SleepForUser")
EndFunc

Func Start()
MouseClick("Left", $aPos[0], $aPos[1], 2)
MouseClick("Left", $aPos[0], $aPos1[], 2)
Call ("SleepForUser")
EndFunc
    
Func End ()
Exit
EndFunc

It saves 2 different mouse locations:

  • Generates 2 MSGBOXes
  • After saving aPos functions it waits for user response.

 

Hope that's what you need :)

 

¡Good luck and happy scripting!

Link to comment
Share on other sites

3 minutes ago, DynamicRookie said:

 

#RequireAdmin
Global $aPos = 0
Global $aPos1 = 0

HotKeySet("{F9}", "Position")
HotKeySet("{F8}", "Start")
HotKeySet("{F11}", "End")
Call ("SleepForUser")

Func SleepForUser()
While 1
   Sleep (100)
WEnd
EndFunc

Func Position0()
MsgBox (0, "Waiting for user", "Put your mouse at the wanted position to save Pos0" )
$aPos = MouseGetPos()
MsgBox (0, "Waiting for user", "Put your mouse at the wanted position to save Pos1" )
$aPos1 = MouseGetPos()
MsgBox(0, "Success", "Sucessfully saved mouse locations")
Call("SleepForUser")
EndFunc

Func Start()
MouseClick("Left", $aPos[0], $aPos[1], 2)
MouseClick("Left", $aPos[0], $aPos1[], 2)
Call ("SleepForUser")
EndFunc
    
Func End ()
Exit
EndFunc

 

You may say:

              How i am suppossed to click the OK Button without moving my mouse?

 

Simple, press ENTER key to press the OK button without the mouse.

 

 

May sound obvious but some people dont know

    

Hope it helped you :)

Link to comment
Share on other sites

On 12/30/2017 at 4:02 PM, Gadoz said:

Is this possible to store 2-3 mousegetpos as variable with one Hotkeyset?

I mean, evertime If I have pressed F9, mousegetpos will save the current position of my mouse.

 

;HotKeySet("{F9}", "Position")
Position()
Func Position()
$aPos = MouseGetPos()
$aPos1 = MouseGetPos()
$aPos2 = MouseGetPos()
MsgBox(64, '', $aPos[0]&' - '&$aPos[1]&@CRLF&$aPos1[0]&' - '&$aPos1[1]&@CRLF&$aPos2[0]&' - '&$aPos2[1])
EndFunc

Sure but have no idea why store 2 or 3.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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...