Sign in to follow this  
Followers 0
ryanbogadi

Read from Keyboard

9 posts in this topic

I'm trying to write a program to automate a whole bunch of clicks and user inputs to a particular application and have run into a slight problem. Because of the nature of the application on top of which my script will be run, users will be required to calibrate the environment. So what I want is this: the user moves the cursor to a certian spot (button) in the application then presses a keyboard button (space bar). When the user hits the keyboard button, the script records the coordinates of the mouse. I know how to use MouseGetPos to get the coordinates, but I don't know how to have that done only when the user presses a key. Could someone please help me out?

Share this post


Link to post
Share on other sites



I'm trying to write a program to automate a whole bunch of clicks and user inputs to a particular application and have run into a slight problem.  Because of the nature of the application on top of which my script will be run, users will be required to calibrate the environment.  So what I want is this: the user moves the cursor to a certian spot (button) in the application then presses a keyboard button (space bar).  When the user hits the keyboard button, the script records the coordinates of the mouse.  I know how to use MouseGetPos to get the coordinates, but I don't know how to have that done only when the user presses a key.  Could someone please help me out?

<{POST_SNAPBACK}>

HotKeySet() ?

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I'm trying to write a program to automate a whole bunch of clicks and user inputs to a particular application and have run into a slight problem.  Because of the nature of the application on top of which my script will be run, users will be required to calibrate the environment.  So what I want is this: the user moves the cursor to a certian spot (button) in the application then presses a keyboard button (space bar).  When the user hits the keyboard button, the script records the coordinates of the mouse.  I know how to use MouseGetPos to get the coordinates, but I don't know how to have that done only when the user presses a key.  Could someone please help me out?

<{POST_SNAPBACK}>

you could go with either of the suggestions HotKeySet(), _IsPressed(), but i'm not sure that it's really necessary... are you doing the calibration for the sake of the code? i mean to like mathematically figure out the location of elements and controls? if so, you should definitely look at controlclick, controlsend, controlgetpos, and wingetpos in the helpfile.

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

Unfortunately the calibration is necessary because of the application that this will run on top of. Apparently the users can't agree on where to put certain windows and such, so they have to calibrate every time they start.

I used HotKeySet and I now have it working perfectly. Strangely enough, since I started using AutoIT just yesterday, HotKeySet is pretty much the one thing I've used more than anything else. But for whatever reason I didn't even think to use it in this case. Thanks for your help.

Ryan

Share this post


Link to post
Share on other sites

Unfortunately the calibration is necessary because of the application that this will run on top of.  Apparently the users can't agree on where to put certain windows and such, so they have to calibrate every time they start.

I used HotKeySet and I now have it working perfectly.  Strangely enough, since I started using AutoIT just yesterday, HotKeySet is pretty much the one thing I've used more than anything else.  But for whatever reason I didn't even think to use it in this case.  Thanks for your help.

Ryan

<{POST_SNAPBACK}>

If the application uses default MS controls, rather than creating it's own, you can use controlclick/controlsend to send information to the controls they'd be clicking on or typing in, regardless of where on the desktop they have the window situated. thus eliminating the need for the calibration.

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

If the application uses default MS controls, rather than creating it's own, you can use controlclick/controlsend to send information to the controls they'd be clicking on or typing in, regardless of where on the desktop they have the window situated.  thus eliminating the need for the calibration.

<{POST_SNAPBACK}>

So how do I find out if the application uses default MS controls? I mean, to me it looks pretty "default", just a bunch of intertwined tables and such. But I don't know anything about sending information to controls, aside from just clicking them then sending data. I would love to be able to do this without calibration if at all possible.

Share this post


Link to post
Share on other sites

So how do I find out if the application uses default MS controls?  I mean, to me it looks pretty "default", just a bunch of intertwined tables and such.  But I don't know anything about sending information to controls, aside from just clicking them then sending data.  I would love to be able to do this without calibration if at all possible.

<{POST_SNAPBACK}>

check out 'controlclick()' and 'controlsend()'. you may also want to look at 'controlsettext()'. actually, maybe just go to the index tab in your helpfile and type in 'control' and check out the things listed. good stuff.

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

And if that doesn't work for you:

msgBox(0x30, "Calibration", "Move the mouse over the 'XY' control and then press Enter.")
$coords = mouseGetPos()

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