Mouse button hotkeys only work once, not continual - mouseevent

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

Related

IntelliJ - Debug info window shortcut?

In IntelliJ, when a breakpoint suspends an a program.. If I hover over a variable with the mouse cursor and wait for a second or two, a tooltip appears, which lets me inspect the variable by clicking the + sign. For example in the below image, I kept my mouse cursor over three for a second or two and the tooltip saying Main$Die#452 appeared.
Is there a way to show this tooltip only by using the keyboard and the current cursor location? In other words, in the screenshot above, how would I see the tooltip for the variable one (where my keyboard cursor is) without moving the mouse cursor over the variable one? (And how would I expand it once I see the tooltip?)
While debugging code, I realized I end up inspecting objects like this very often and moving around the mouse and waiting for the tooltip to appear starts to slow down the process a little.
The action is called "Quick evaluate expression":
You can invoke it via alt+⌘+F8 on macOS, or ctrl+alt+F8 on Windows

Auto Hot Key - Holding down one key holds down 2 different keys

So I've used AutoHotKey to disable the AppsKey (the button on the keyboard which brings up the right-click menu). But I thought I could put it to better to use, and am trying to get it so that while I'm holding down the AppsKey the computer thinks I'm holding down Shift & Control instead.
I've been reading through the Command List but can't see anything for AppsKey down & up. Would anyone be able to share anything to enable me to do this?
Thanks
I don't understand what your problems are, but this little piece of code works for me:
AppsKey::Send, {SHIFT down}{CTRL down}
AppsKey up::Send, {CTRL up}{SHIFT up}
As you can see, there is an AppsKey up. Down on the other hand doesn't exist for hotkeys. In this example, the first hotkey triggers when AppsKey is pressed (that is, it triggers as soon as you hit it). The second hotkey triggers when it is released.

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.

AutoHotkey background clicking and typing

I'm trying to use AutoHotkey to do some background clicking and typing while I'm doing other stuff in the foreground.
I've gotten used to Send but I haven't figured out how ControlSend works yet. Can anyone give me an example using something simple like MSPaint in the background and changing the color of paint.
Is this even possible to do? I have a script currently that pulls from daily Excel report, assigns each row a variable and punches it into another program, but I need it to click and type some canned messages as well.
The first question should probably be why use mouse control? Keyboard control is sooo much easier and often more reliable. What is it that you try to do with a mouseclick that can't be done through keyboard commands?
Also mouse clicks normally activate the hidden app.
OK you wanted an example...
+Home:: ;Shift + Home = stop/start radio
SetControlDelay -1
ControlClick, x384 y143, Radioplayer
Return
Here i click on the play/pause button of a streaming radioplayer. The mouse coordinates are found with the aforementioned Windows Spy and the title of the browser (you might have to use SetTitleMatchMode). Why not look at the AutoHotKey Command list and check out the examples there....
Let me know if this is (roughly) what you are looking for....
SendMode Input ; Recommended for new scripts
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 2 ; A window's title can contain the text anywhere
!F1:: ; Press Alt F1 to execute
IfWinExist, Microsoft Excel
{
ControlSend ,, 1000{Enter}{Down}, Microsoft Excel
}
return
Here is some code I used to first record the mouse position (relative mouse position did not work since the window was tiled and the click position could be changed by moving the tiles). Immediately after that I click the mouse at the recorded position (and redo this later on in the code as well).
SplashTextOn, 200, 100, Script Preparations, Please Click on the Person `"Search Term`" link (1) in SAP. ; Show new instructions to the user
WinMove, Script Preparations,, (A_ScreenWidth/2)-150, (A_ScreenHeight/2)-200 ; Move the text instructions window with the name "Script Preparations" 150 pixels right of the center of the screen and 200 pixels up SoundBeep 600, 300 ; Wake up user
; From here on the left mouse button will temporarily be disabled
Hotkey, LButton, on ; Turn Left Mouse Button OFF, to capture the Mouse click
KeyWait, LButton, D ; Wait for LeftMouseButton click Down
MouseGetPos, xposS ,yposS ; Store the position where the mouse was clicked (Search Box)
MouseClick, left, %xposS% ,%yposS% ; Perform the mouse click on the captured mouse location
Hope this helps.
In your situation, I assume that you only need to determine the mouse position with Window Spy.