Press a button with postmessage - autohotkey

There is a way to make a mouse click with postmessage, a solution without moving the mouse (no click x, y)?
For example:
loop{
hotkey,ctrl,pressb
}
pressb:
msgbox a button
PostMessage, 0x0201, , 9765141, ahk_class #32770
PostMessage, 0x0202, , 9765141, ahk_class #32770
; or ControlClick, x95 y115, ahk_class #32770
return
Functions PostMessage and ControlClick don't work, the button is not pressed.

Each of these should work
ControlClick, Button1, ahk_class #32770
ControlClick, OK, ahk_class #32770

I had the same problem (until just recently). Most of the AutoHotKey interactive commands (such as SendMessage, ControlClick, SendRawMessage and so on) does not work within a 32700 window (a dialog) as well as other windows.
Solution: If you're running Windows 7. You need to run your AHK script as an administrator. To do this, right click on your AutoHotKey Script and click on 'Run as administrator'.

Related

AHK How to completely hide ApplicationFrameHost.exe window (such as Windows 10 Settings, Photos, Mail)

I have tried WinHide but it only hides the window and the taskbar icon remains.
Before WinHide
After WinHide
Here's my code:
WinHide, ahk_class ApplicationFrameWindow ahk_exe ApplicationFrameHost.exe, Settings
MsgBox, Hidden but the taskbar icon remains
WinShow, ahk_class ApplicationFrameWindow ahk_exe ApplicationFrameHost.exe, Settings
MsgBox, Shown

What window is active after click toast notification - AHK

i'm browsing google chrome then toast notification appears on bottom right.
i click it and it disappears.
after that i can see google chrome as top window, it looks like a active window but it's not activated.
then sometimes i press ctrl+t to open new tab in google chrome but it doesnt work because its not activated.
its annoying.
i want to make like below one.
#If WinActive("After Click Toast")
^t::
WinActivate ahk_exe chrome.exe
WinWaitActive ahk_exe chrome.exe
Send %A_ThisHotkey%
return
after click toast, windows spy doesnt show anything.
MsgWinTitle(){
WinGet, ExStyle, ExStyle, A
MsgBox % ExStyle
return
}
but with this shows 0x08200000
i dont know how can i use this though.
thanks for read.
thanks for help.
Thanks for Big advise
now i solved it with this
#If WinActive("ahk_class Windows.UI.Core.CoreWindow")
~LButton:: return
~LButton Up::
Send {Alt Down}{Tab}{Alt Up}
return

AutoHotkey script to right click and save an image in Word

I am trying to make a script to allow me to right click on an image and use the context menu to save it as an image at the default location and with the default image name that Word selects. I am trying to reduce a (Right Click -> Button press -> Enter) sequence to just a Ctrl + RClick combo.
Context menu screenshot
Default location and image name
This is what I have right now, which does not work:
^RButton::
MouseClick, right
Sleep, 500
Send, s
Sleep, 500
Send, {Enter}
return
Apologies if I am doing something stupid, I just started using ahk today.
Try
#IfWinActive ahk_exe WINWORD.EXE ; only if MS Word is the active window
^RButton::
KeyWait, Ctrl, L ; wait for the Control key to be released
Click right
WinWait, ahk_class Net UI Tool Window ; Word's context menu
WinActivate, ahk_class Net UI Tool Window
WinWaitActive, ahk_class Net UI Tool Window
Send, s
WinWait, Save As Picture
WinActivate, Save As Picture
WinWaitActive, Save As Picture
Send, {Enter}
return
#IfWinActive
https://www.autohotkey.com/docs/commands/_IfWinActive.htm

Stardew Valley autohotkey script

I have a problem with my autohotkey script for stardew. I for some reason can't get it to cast for me on button 4.I currently have this code which by all account should work:
#IfWinActive Stardew Valley
XButton1::
SendInput, {LButton Down}
KeyWait, LButton, T1.0248
SendInput, {LButton Up}
Return
If you have problems with #IfWinActive, then you probably haven't entered the window name that AutoHotkey is seeing. Use the WindowSpy utility from your AutoHotkey installation folder to find the correct window name.
Alternatively you could try using #IfWinActive ahk_exe proccessname.exe.
And if your game runs as admin, then you might have to run your script as admin too.

How to activate a window after it has lost focus?

So i am using this great software called Website-Watcher, which is rss feed reader and web content tracker.
I have configured it to open external links in firefox, which is opening tabs in the background.
BUT the problem is that Website-Watcher looses focus after i hit some link, so is there a way to open a link, regain lost focus and send click to be able to scroll, i have found a script that activates window on mouse scroll BUT the scroll functionality of program is not regained.
Please, give me some ideas!
EDIT UPDATE::: I have finally made it work, the problem was with the Windows 8.1 Admin rights, because i run Website-Watcher elevated, script that i was using stopped working.
The scripts are here:
http://www.autohotkey.com/board/topic/6292-send-mouse-scrolls-to-window-under-mouse/
http://www.autohotkey.com/board/topic/99405-hoverscroll-verticalhorizontal-scroll-without-focus-scrollwheel-acceleration/?p=623967
With those scripts you can perform scroll without activating windows or if you use the former you can even activate windows with mouse scroll.
Use WinActivate
For example, WinActivate Untitled - Notepad would activate (bring focus to) the window "Untitled - Notepad". This title must be exact and is case-sensitive.
It might be easiest to do this in a low-tech way. I'm not familiar with Website-Watcher, so I'll share a script I use that you should be able to adapt.
I use Feedly in Chrome for RSS reading, and hitting "v" in Feedly opens the story in a new tab. I use my Media Play button to hit "v" and bring me back to Feedly:
Media_Play_Pause::
send v
sleep 50
send {Ctrl Down}{Shift Down}{Tab}{Shift Up}{Ctrl Up}
return
So, define your hotkey, have it trigger the link to open in Firefox, and then hit Alt-Tab to jump back:
X::
send y
sleep 50
send {Alt Down}{Tab}{Alt Up}
return
Obviously, replace "X" and "y" above.
I don't care about using my Media Play button for anything else, but if you want your hotkey to be context sensitive, use #IfWinActive.
Use "WinGet, variableName , List, yourWindowName" (without quote)
then call your variableName contate it with 1 in every ControlSend
for example :
WinGet, nexid, List, myHyperTerminal
ControlSend, , {shift down}at=cmgs{shift up}=303{ENTER}, ahk_id %nexid1%
sleep, 1000
ControlSend, , {shift down}sms{shift up}{space}10000, ahk_id %nexid1%
sleep, 1000
if you want to use control key such as shift, ctrl, alt, don't forget to add "SetKeyDelay, intDelay, intPressDuration" (without quote)
for example the script will be list this
#usehook on
SetKeyDelay, 50, 20
WinGet, nexid, List, zz1
$F6::
ControlSend, , {shift down}at=cmgs{shift up}=303{ENTER}, ahk_id %nexid1%
sleep, 1000
ControlSend, , {shift down}sms{shift up}{space}10000, ahk_id %nexid1%
sleep, 1000
return
$F7::pause
it will be sent to active/inactive window "zz1" as :
AT+CMGS=303
SMS 10000