Here is my code:
Same Mouse Click:
f2::
MouseGetPos, xpos, ypos
ControlClick, x%xpos% y%ypos%, Window1
ControlClick, x%xpos% y%ypos%, Window2
return
It should make a Mouse click on two different windows when pressing f2.
Apple Script seems rather complicated are there any converters to run Hotkey Scripts on a Mac?
Or has anyone a simple solution to this?ยด
Related
I have the AutoHotKey EnterPad Keyboard/Pad with 120 Programmable Keys
It works by sending a Hotkey press for each key to an AutoHotKey script which has a Label function for each key named 001 through 120
Below is my AHK Label function called when key 115 is pressed.
My code allows me to select rows in any Windows Listview component and it will show a popup GUI window with a textbox filled in with the data from the selected rows with each column separated with a TAB space. I can then copy or save it or view it whatever I like.
;---------------------------------------------------------------------115-----
; Copy Selected Windows Listview Items to Tab Spaced Text - Show popup Window Gui
; https://superuser.com/questions/814831/copy-to-clipboard-from-table-list-in-a-program-on-windows
115:
Gui, SelectedListRowsTextGui:Destroy
MouseGetPos, , , , ListView_hwnd, 2 ;2 means return HWND
ControlGet, selected_row_text, List, Selected, , ahk_id %ListView_hwnd%
Gui, SelectedListRowsTextGui: +ToolWindow +AlwaysOnTop -Caption
Gui, SelectedListRowsTextGui:Add, Edit, vUnused_variable x11 y15 w950 h66, %selected_row_text%
Gui, SelectedListRowsTextGui:Add, Button, x62 y84 w140 h30 +Center, Close
Gui, SelectedListRowsTextGui:Show, ,
return
ButtonClose:
Gui, SelectedListRowsTextGui:Destroy
return
Return
Problem
My issue is that once the popup window is opened from my AHK GUI, my CloseButton label dose not get called when I click the close button.
I realize it likely has something to do with it being nested under the key 115s label function. How can I best achieve the desired result?
I tried moving the CloseButton label outside of the 115 label however it still is not called from the GUI's Close button click.
You can see I have named the GUI SelectedListRowsTextGui this is to allow this Enterpad.ahk script to contain many GUI windows for different actions it will perform.
Preview of the GUI window this script creates when listview items are selected and this Label function is called:
I got it now....
Since my GUI is named SelectedListRowsTextGui I had to add that name in front of my CloseButton label name so it is now SelectedListRowsTextGuiButtonClose and works great
I have two monitors one of them is a touchscreen. do somebody now a simple code in autohotkey. that you received a value, between a mouse click and a touchscreen click
I use for example Photoshop application on my main monitor 1
And I have a virtual keyboard with my (favorite keystroke combos) on my touchscreen monitor 2
I want if I do with my left hand a touchscreen click on my virtual keyboard monitor 2.
That the mouse pointer stays on my main monitor 1
So that I can proceed with PhotoShop without interrupting to move my mouse pointer back to my main monitor 1.
This is the script so far a alternative idea.
::^d ;push ctrl + d to disable the mouse pointer movement
BlockInput MouseMove
return
::^e ;push ctrl + e to enable the mouse pointer movement
BlockInput MouseMoveOff
return
Distinguishing between input devices is not a trivial task with AHK. It can be done, but it's quite complicated.
If you'd be okay with interpreting every click on the touchscreen as a touch click then you could do something like this:
When the mouse moves on the normal screen
store it's position in a variable.
When a left click is executed on the touch screen do the click
move the mouse back to the last know position on the normal monitor.
You'll need:
SysGet
RegisterCallback or SetTimer+MouseGetPos
Hotkeys
I do not have a second monitor to fully test this code but I have tested on my main monitor which is a touchscreen. This code should do the trick :)
; Screen pixel split between monitors
; You should change this values according to the desired region of interest
screen_split_min := 0
screen_split_max := 200
; To get absolute monitor coordinates
CoordMode, Mouse, Screen
MouseGetPos, pre_mx, pre_my
While 1
{
MouseGetPos, tmp_mx, tmp_my
If tmp_mx > %screen_split_max%
{
pre_mx := tmp_mx
pre_my := tmp_my
}
}
~LButton::
MouseGetPos, mx, my
If mx <= %screen_split_max% and mx >= %screen_split_min%
{
MouseMove, pre_mx, pre_my, 0
}
return
HTH ;)
I have successfully used to following autohotkey script to achieve what I want (remove title bar and window frame from a windowed game):
;-Caption
LWIN & LButton::
WinSet, Style, -0xC00000, A
return
;
;+Caption
LWIN & RButton::
WinSet, Style, +0xC00000, A
return
;
What I want is for "WinSet, Style, -0xC00000, A" to be executed automatically when a specific application is launched.
Any feedback would be greatly appreciated!
Altough wOxxOm's answer is perfectly acceptable. You can also do this in a persistent script by using Settimer and WinExist .
#persistent
SetTimer, isItRunning, 1000
isItRunning:
if winexist("yourprogram")
WinSet, Style, -0xC00000
Return
Simply make an AHK launcher for the game and use it instead of the shortcut icon or taskbar icon or whatever else you're using to launch the game.
Run, d:\somepath\game.exe
WinWait Game window title goes here
WinSet, Style, -0xC00000
ExitApp
I am trying to find out how to move the mouse cursor N pixels to some direction.... through a command script, since I cannot install anything on my computer.
I basically try to keep the screen active forever, until I kill the script.
(Yes, I've been searching high and low for a way to do it by a command script.... but could not find anything. I hope it's possible.)
The most straightforward way to manipulate mouse with batch file is with
rundll32 user32.dll,SetCursorPos
But this is not very useful - just sets the mouse to 0,0 position.
Check the mouse.bat - it is a self compiled C#/batch file and does not require external tools and the source is visible and editable.
Examples:
//clicks at the current position
call mouse click
//double clicks at the current position
call mouse doubleClick
//right clicks at the current position
call mouse rightClick
//returns the position of the cursor
call mouse position
//scrolls up the mouse wheel with 1500 units
call mouse scrollUp 150
//scrolls down with 100 postitions
call mouse scrollDown 100
//relatively(from the current position) moves the mouse with 100 horizontal and 100 vertial postitions
call mouse moveBy 100x100
//absolute positioning
call mouse moveTo 100x100
//relative drag (lefclick and move)
call mouse dragBy 300x200
//absolute drag
call mouse dragTo 500x500
Search for NirCmd, and install it in C:\windows, and do:
nircmd setcursor 100 50
nircmd movecursor 10 10
or another commands for clicks etc.
(Late answer but can still be useful for others)
If you just want to keep your computer from falling asleep, the software "Caffeine" does this quite well.
You could try installing AutoHotKey. It makes controlling mouse very simple. Example script:
#MaxThreadsPerHotkey 3
^g::
Toggle := !Toggle
Loop
{
If (!Toggle)
Break
Click
Sleep 1000 ; Make this number higher for slower clicks, lower for faster.
}
Return
After running script for this example press control+g and it will click every second to keep screen awake. ctrl+g again to stop.
install at: https://www.autohotkey.com/
found solution: https://autohotkey.com/boards/viewtopic.php?t=19846
try setting sleep mode to 'none', but if you want to move your mouse without even touching it, download memz clean and let the "random cursor movement" to be bluish. now enjoy. (if it doesn't work, the payloads must be disabled. try doing shift+esc to enable/disable payloads. try doing ctrl+shift+s to skip some time because in some minutes the mouse will shake more better.)
I'm using mousegetpos to get the current mouse position. I click somewhere else. Then I try to restore the original postion with mousemove. The mouse moves to a different monitor. I tried the alternative method dllcall, with no success. How do I move the mouse back to the original monitor?
It's easier to help if you post your code - then people can see where you're going wrong.
This works fine for me when pressing the Ctrl-T hotkey:
CoordMode, Mouse, Screen
^t::
MouseGetPos, x, y
; Do Stuff Here.
MouseMove, x, y
return
The CoordMode, Mouse, Screen line sets the coordinates relative to the entire screen rather than the active window. I've tested this on my multiple monitor setup and the mouse goes back to the original location every time, even across monitors. Let me know if it's not working for you.
Also, just to make things a little smoother, you can set the mouse speed to '0' before moving the mouse with:
SetDefaultMouseSpeed, 0
This makes the mouse appear to move instantly which looks a little cleaner in most scripts.
I can confirm that Gary's answer works perfectly for anybody else out there having similar problems. Thanks, Gary!
I was myself having a problem like this with Breakaway Audio Enhancer...
For anybody that uses or knows Breakaway, you have to double-click on the toolbar (in the taskbar) to mute it. The way Breakaway works with the sound pipeline other standard AHK mute scripts won't work, so moving the mouse to the toolbar and double-clicking is really the only method of muting. I wanted Caps Lock to mute (or unmute) audio and preferably have the mouse return to where it originally was.
I've had countless problems trying to get this to work with multiple monitors until Gary's post, so here is my solution for anybody else having similar issues:
Capslock::
BlockInput On
CoordMode, Mouse, Screen
MouseGetPos, xpos, ypos
MouseClick, left, 42, 965, 2 ;change the co-ordinates to match your system
MouseMove, xpos, ypos
SetDefaultMouseSpeed, 0
BlockInput Off
Return