How can I make one key do these 2 things? - automation

Thanks in advance for the help. I have a job that requires repetitive keystrokes. To make my job easier, I need to do the following 2 things:
LButton::Send {LButton}{Tab}{Enter}
2nd: Count every time LButton is pressed.
Right now, I'm using 2 separate keystrokes:
1 above
and
2 - Spacebar to count, like this:
Counter=0
Space::Counter++
F12::MsgBox, %Counter%
So right now, I need to hit the LButton to perform my job task (left mouse, tab, enter) AND the Spacebar to count each time I do this.
I'd like to press the Left mouse, and make it do the left mouse, tab, enter sequence PLUS count the click. That way, I wouldn't have to press the spacebar each time I needed to count the action (for accuracy and ease of use).
Any idea how I could set up autohotkey to do this in a single click?
Thanks again. I've learned a ton from combing through the suggestions, and I'm enjoying how much easier my work has become with AHK.
Best,
Jesse

Related

Send vs SendInput Problems

I've tried many variations of a script whose purpose is to send rapid clicks when either mouse button is held down. In my own script I have both left and right click loops but here is the simplest version I tried:
SetKeyDelay, -1
$RButton::
While GetKeyState("RButton", "P") {
Send, {RButton}
}
Returm
When using this, I get about 20 clicks per second. However, I would like to achieve 30 or so. What I infer from this, is that the send command has a 50 ms delay (1000ms/20 clicks). I would also like to use the {Blind} modifier but that slows it down even more (to about 16 clicks per second).
The obvious answer I think is to use SendInput, and I was able to achieve desired clicks per second using SendInput. However, it came with undesirable side effects. Namely, the key buffering is very unwanted in my use case. In addition, no matter if I used a while loop with GetKeyState or a Button up configuration with SetTimer and Gosub, the right click and left click loops would get stuck occasionally (interference?). The loops getting stuck was not a problem with Send as I'm able to put the loops for each mouse button in separate scripts. When I do that with SendInput, it lowers the clicks per second drastically.
I have also tried SendPlay and SendEvent to no success. Also, I tried using V2 although most of my testing has been in 1.1.35.00.
I don't think it is CPU or memory related as SendInput is able to hit the clicks per second goal of 30 and both CPU and memory stay at about 60%. I could be wrong here though. I also don't think the application I am using is restricting the click rate for the same reason of it being able to register 30 with SendInput.
I greatly appreciate anyone who takes the time to read this! Happy Holidays!
Expecting about 30 clicks per second with both right and left mouse buttons being held down.
I've tried:
Send, SendInput, SendPlay, SendEvent
#MaxThreadsPerHotkey, 2 #SingleInstance Force
SetKeyDelay, -1 SetBatchLines, -1
While loop with GetKeyState as condition and also tried SetTimer and Gosub with individual functions
V2 and 1.1.35.00.
Resulted always in a maximum of 16 clicks per second with Send
With SendInput, user keystrokes sent while clicking were always buffered, which was undesired. As well as the loops getting stuck occassionally

wacom and myscript set handwritng recognition function

im not sure if its the right place to put my question, but i think maybe get an answer here.
the last few days thinking about a way to make μυ work easier.
What I want is to write by hand and convert into text on the computer.
namely when I am on a page with multiple text forms like this im writing now,
when i choose a text form with a pen (like wacom graphic tablet) write on a surface and the automaticaly when i stop or pressing a button the text turn into text in the form.
my title say about wacom because i found bamboo scribe.. if someone uses this please explain me whats can do and if can work for me.
i test myscript. with fullscreen tool wich you can write everywhere on the screen is easiest but when you finish you have to press a button on the program to insert the text in the selected area.
so my question is there any way to press that button with the button placed on stylus pen?
i saw that you can set functions when a button clicked on the wacom tablet or on pen.
i have not bought yet anything because im searching if is out there anything could do what i want better. something made for that particular job
Thanks and sorry for my bad english..

Mouse button hotkeys only work once, not continual

I need to make an AutoHotkey script that performs some action when and while the mouse button is pressed, then finishes when the mouse button is released.
For (a very simplified) example:
LButton::
MouseGetPos x,y
MsgBox %x%-%y%
LButton Up::MsgBox Foobar
Replacing the LButton with a keyboard key (e.g., LWin) makes it work correctly and moving the mouse cursor updates as expected while the key is held down, but using the mouse button only performs the LButton action one time. I need the hotkey action to continue occurring until the button is no longer being held.
After a bunch of query-term tweaking, I found a page that gives sample scripts for autofire.
I wasn’t sure that was what I wanted (even though it made sense) because as I said, the sample script already works just fine for keys, but I gave it a shot anyway. I tweaked the sample a bit and now it works as desired. (Actually, it is very similar to a solution I had already been using, but now it absorbs the button event, which solves the underlying problem that I led me to trying the aforementioned script.)
Hopefully I picked good keywords in this post so that anyone else who finds themselves in the same situation can find the/a solution faster than I did.
#SingleInstance,force
CoordMode, Mouse, Screen
LButton::
While GetKeyState("LButton","p") {
MouseGetPos x,y
Tooltip %x%/%y%
Sleep 75
}
return
LButton Up::
Tooltip Foobar
return

Word VBA: Watch List Disappears

This problem has been happening for awhile now, but with the particular piece of code I am now trying to debug, it has become really difficult for me to live with.
The issue is rather basic: every time I click F8 to step to the next line of code, the Expression, Value and Type columns in the watch window goes completely blank. The Context remains, as do an icon of a pair of glasses to each Watch I had created, but other than that they are blank. If I click in the Watch window, the values reappear, one at a time as I click each one. I can cause the whole list to reappear by clicking on a plus or minus sign (tree collapse or expand), once I've revealed a watch by clicking on it. After going through this process of making my list visible again, it all disappears again when I click f8. Tried searching for this issue, but can't seem to find anything. Can someone please help?
Thank you

How can Sikuli be used to wait for a button for a long time, with perhaps some maintenance task in between?

I have a webpage where I am waiting for a button to appear, and when it appears I would like to click it. The button is on a timer and may take as long as an hour to appear. Also, if the button takes longer than a certain length of time to appear, I'd like to move the mouse (otherwise the website will log me out automatically).
So, to wait for a button to appear I devised this Sikuli script:
button = "button.png"
while(1):
if exists(button):
print("found it")
click(button)
break
else:
print("wait longer")
wait(button,30*60)
# do a regular task
print "all done!"
The above does not seem to be functional. If the button is on screen, the script will find it... However, if it has to wait it will simply time out quickly with a FindFailed exception (on the click() even though the button does not exist on screen). I considered writing a handler, but seems like overkill.
What am I doing wrong and what is the best way to wait a long period for a visual event like this?
Some other thoughts for you...
while(1):
wait(Button, 30*60) # This will spinlock for 30 minutes for the button to appear
if exists(Button):
hover(Button) # Debug statement allowing user to see what Sikuli has matched to
click (Button)
else:
mouseMove(Location(50,100))
mouseMove(Location(50,200))
Links:
wait
mouse movement link
Location
Maybe Sikuli recognizes something that looks quite your button, and tries to click it.
If you right click in the IDE your button pattern, you can fine tune the tolerance level for recognition. Try to cut the image exactly around your button and increase the value to be more precise.
I suggest you to read this tutorial
http://doc.sikuli.org/tutorials/surveillance/surveillance.html
and to set up a event handler to manage your button when it appears
http://doc.sikuli.org/region.html#Region.onAppear
http://doc.sikuli.org/region.html#observingvisualeventsinaregion
It is not much code to write.
You can get a nice example with full source code in Sikuli's Blog here
http://sikuli.org/blog/2011/08/15/sikuli-plays-angry-birds-on-google-games/
I think you can just set up your handlers and go with
observe(FOREVER)
If you want sikuli to do stuff while your waiting for an image i would use the onAppear(pic, function) and observe(FOREVER, true) methods this is how it works
event = Sikuli.event
def function(event):
click(yourButton.png)
onAppear(picYourWaitingFor.png, function)
observe(FOREVER, true)
basically what this does is onAppear will continuously scan the screen for picYourWaitingFor.png. sikuli continues execution after words so it's scanning while its working. on the appearance of said pic it will jump to the function you put down as the second parameter of onAppear.
I have this same issue as described. Its not about waiting forever. And Observe won't work either, because that does watch forever. Think about wanting to check for event only for a certain period of time say 60 seconds. If it doesn't occur, move on. This could be happening in a specific series of events. If the image doesn't appear in the 60 seconds, move on to do another series.
wait(image,60)
...will crash after 60 seconds if it doesn't find the image, which isn't what is wanted at all in my case.
So I did something like this:
attempt = 1
count=0
while attempt:
if exists(image):
attempt=0
else:
count=count+1
if count>60:
attempt=0
else:
wait(1)
Probably a better way and doesn't give an exact time, but approach doesn't crash the script.
You could also try: except it.. Should be shorter.