Sign in to follow this  
Followers 0
litlmike

Return To Cursor Position

16 posts in this topic

Can't figure out what commands to use for this. I just would like to return to the cursor position I was at.

I have a script running in the background that will run under certain conditions. It activates another window, sends a few commands, then re-activates the window I was just at. But I would like to return to where I was typing, etc. without moving my mouse, because I am so-friggin-lazy.

So, is there a command like GetCurrentCursorPos, MoveCursorPos, ClickCursorPos, etc?

Share this post


Link to post
Share on other sites



MouseClick allows X & Y positions, MouseGetPos will return the current X & Y position MouseMove allows X & Y coordinates.

~cdkid


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

Can't figure out what commands to use for this. I just would like to return to the cursor position I was at.

I have a script running in the background that will run under certain conditions. It activates another window, sends a few commands, then re-activates the window I was just at. But I would like to return to where I was typing, etc. without moving my mouse, because I am so-friggin-lazy.

So, is there a command like GetCurrentCursorPos, MoveCursorPos, ClickCursorPos, etc?

what kind of control is it that you want to reset the cursor in? you could just set focus to that control probably and controlsend("title","","^{END}")

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Might take a look at WinGetCarrotPos()


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Might take a look at WinGetCarrotPos()

Thanks everyone for the response. It's possible to use Mouse Coords, but it would take extra effort on my part everytime the script is called. Unfortunately, ControlFocus is not an option; the controls on this application are ridiculous.

WinGetCaretPos might work. But, what comes after this command? WinPutCaretPos? WinFocusCaretPos?

I guess this could work, but is there a better way?:

$tmp = WinGetCaretPos ()
Sleep (2000)
MouseClick ("left", $tmp)

Share this post


Link to post
Share on other sites

Thanks everyone for the response. It's possible to use Mouse Coords, but it would take extra effort on my part everytime the script is called. Unfortunately, ControlFocus is not an option; the controls on this application are ridiculous.

WinGetCaretPos might work. But, what comes after this command? WinPutCaretPos? WinFocusCaretPos?

I guess this could work, but is there a better way?:

$tmp = WinGetCaretPos ()
Sleep (2000)
MouseClick ("left", $tmp)
there's still the control send (control + end) to the control in question, so that you'd be at the end of the text already there...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

there's still the control send (control + end) to the control in question, so that you'd be at the end of the text already there...

That is a clever idea I must say, and I think I will use that on some of my other scripts. Unfortunately, with this app, I can't work with the controls (long story).

Is there any other commands besides WinGetCaretPos, that I should be aware of?

Share this post


Link to post
Share on other sites

That is a clever idea I must say, and I think I will use that on some of my other scripts. Unfortunately, with this app, I can't work with the controls (long story).

Is there any other commands besides WinGetCaretPos, that I should be aware of?

what type of controls are you interacting with? are you able to give a screenshot of the app and the autoit window info with the control selected?

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Might take a look at WinGetCarrotPos()

The carrot position? Try in front of the rabbit....

Share this post


Link to post
Share on other sites

The carrot position? Try in front of the rabbit....

BOOOO! sorry, i'm all about random jokes and what not, but come on man, that was bad. friends don't let friends make puns.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

The carrot position? Try in front of the rabbit....

wabbit

Share this post


Link to post
Share on other sites

BOOOO! sorry, i'm all about random jokes and what not, but come on man, that was bad. friends don't let friends make puns.

I know it was bad, I was just pointing it out.. because seriously? WinGetCarrotPos??? What the hell is that?

Share this post


Link to post
Share on other sites

I know it was bad, I was just pointing it out.. because seriously? WinGetCarrotPos??? What the hell is that?

That was my stomach and my head talking at the same time :think:

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

what type of controls are you interacting with? are you able to give a screenshot of the app and the autoit window info with the control selected?

Kind of controls? Evil ones. Its an old database, you can see a .jpg at the link below. We in the forums, have had a very hard time interacting with these controls.

I tried using my idea, but everytime it would go to the top-left of the screen and click, instead of where it just was. Any ideas? Oh, and I used CaretCoordMode 0, 1, and 2, all gave pretty much the same result. Maybe this means it is MDI, but I have no idea how to fix it.

$tmp = WinGetCaretPos ()
Sleep (2000)
MouseClick ("left", $tmp[0], $tmp[0])

ScreenShot of App

Share this post


Link to post
Share on other sites

Kind of controls? Evil ones. Its an old database, you can see a .jpg at the link below. We in the forums, have had a very hard time interacting with these controls.

I tried using my idea, but everytime it would go to the top-left of the screen and click, instead of where it just was. Any ideas? Oh, and I used CaretCoordMode 0, 1, and 2, all gave pretty much the same result. Maybe this means it is MDI, but I have no idea how to fix it.

$tmp = WinGetCaretPos ()
Sleep (2000)
MouseClick ("left", $tmp[0], $tmp[0])

ScreenShot of App

Gawd... your still trying to play with ACT...lol

What MouseCoordMode did you use? (should probably be 2 if it's going to work at all)


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I'm assuming you want to just add into your current script.

;of course our trusty pause/break to trigger the mousegetpos and esc to cancel.
HotKeySet("{ESC}", "Terminate")
HotKeySet("{PAUSE}", "MOUSELOC")
While 1
    Sleep(100)
WEnd

Func MOUSELOC()
$pos = MouseGetPos()
MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1]); makes a mental note of where the curser curenly is.
Sleep(5000); this would be replaced by the call from your script. but gives time to move your mouse in this example.
MouseMove($pos[0], $pos[1]); recalls where it used to be and goes there.
    
EndFunc

Func Terminate()
    Exit 0
EndFunc

This is what i would do personally, if I understand your need.

If you incert the $pos = MouseGetPos() line before your script swtiches calls another screen, you can use the MouseMove($pos[0], $pos[1]) to get back to where your mouse was when you left.

My app at work is java and lacks the controlfocus support also, so i feel your pain. =)

Good Luck.

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