Related
I need RAlt + LAlt + g to behave as LShift + Del (nothing happend)
#InputLevel, 1
RAlt::F24
#inputLevel, 0
F24 & g::Del
LAlt::LShift
I test RAlt + RShift + g it works fine,
also I test to change the key g to d and it works too!!
#InputLevel, 1
RAlt::F24
#inputLevel, 0
F24 & d::Del
LAlt::LShift
did I miss something !?
This script is working fine when I run it in the foreground with Send and MouseClick instead of ControlSend and ControlClick (and wb.Visible = true). What is the issue here with running it in the background?
code1 := "foobar"
url := "https://app.powerbi.com/groups/me/reports/xxx"
wb := ComObjCreate("InternetExplorer.Application") ;create com object
wb.Visible := false ;true to show IE
wb.Navigate(url)
while (wb.busy) ;wait while page loads
sleep 10
ControlSend,, {LWin down}{Up down}
ControlSend,, {LWin up}{Up up}
sleep 20000
ControlClick, left, 1275, 320
sleep 3000
ControlClick, left, 1275, 510
sleep 500
ControlClick, left, 2200, 1380
sleep 3000
ControlClick, left, 2200, 1380
sleep 3000
ControlClick, left, 2200, 1380
sleep 120000
ControlClick, left, 2760, 2000
sleep 500
ControlClick, left, 2760, 2000
sleep 5000
ControlClick, left, 2760, 2000
sleep 3000
ControlClick, left, 2760, 2000
DetectHiddenWindows, On directive can detect a window running in the
background.
Keystrokes and strings can be passed to hidden or inactive windows.
for example, the snippet below starts notepad.exe, sends a message "sending a string to the notepad.exe" even though notepad is running in the background.
#SingleInstance, Force
DetectHiddenWindows, On
Run, Notepad, , Hide ; run notepad in the background
if WinExist("ahk_class Notepad")
ControlSend, Edit1, sending a string to the notepad.exe, Untitled
; verify: wait for 2s to see the effect
sleep 2000
WinShow
Similarly for your problem, it will hopefully work (can't test, don't have powerbi account)
DetectHiddenWindows, On
code1 := "foobar"
url := "https://app.powerbi.com/groups/me/reports/xxx"
wb := ComObjCreate("InternetExplorer.Application") ;create com object
wb.Visible := false ;true to show IE
wb.Navigate(url)
while (wb.busy) ;wait while page loads
sleep 10
if WinExist("ahk_class IEFrame")
;MsgBox % "hidden window id = " . WinExist("A")
ControlSend,, {LWin down}{Up down}
ControlSend,, {LWin up}{Up up}
sleep 20000
ControlClick, left, 1275, 320
sleep 3000
ControlClick, left, 1275, 510
sleep 500
ControlClick, left, 2200, 1380
sleep 3000
ControlClick, left, 2200, 1380
sleep 3000
ControlClick, left, 2200, 1380
sleep 120000
ControlClick, left, 2760, 2000
sleep 500
ControlClick, left, 2760, 2000
sleep 5000
ControlClick, left, 2760, 2000
sleep 3000
ControlClick, left, 2760, 2000
I am writing a script which uses the ImageSearch command.
The script starts by pressing F3 and it scans from 900,55 to 1005,72.
If it locates any of these 3 identical images, it should send F1, otherwise it should keep scanning until I press F12.
I tried changing the resolution and such but to no success.
F3::
SendMode , Input
SetMouseDelay , -1
SetBatchLines , -1
Loop
{
ImageSearch ,,, 0 , 0 , A_ScreenWidth , A_ScreenHeight , para1.png
bT := ErrorLevel ? bT : 1
ImageSearch ,,, 0 , 0 , A_ScreenWidth , A_ScreenHeight , para2.bmp
bT := ErrorLevel ? bT : 1
ImageSearch ,,, 0 , 0 , A_ScreenWidth , A_ScreenHeight , para3.png
bT := ErrorLevel ? bT : 1
If bT
{
bT := 0
Send , {F1}
Sleep , 100
}
}
Return
f12::ExitApp
thanks for the correction #GoldenLizard
Send {Tab 33}
Send {Enter}
Sleep, 2500
Click, 235, 380
Sleep, 2500
Send {Tab 19}
Send {Enter}
Sleep, 1200
Send, ^a
Send, ^c
return
In this script, I want to increase the number of tabs from 33 to 34, 35, 36,....... without actually changing the script.
How do I do that?
Do I use a loop?
Obviously I can't see if you're triggering this via a hotkey - but lets assume yes (lets assume Ctrl+l for my example below), you would change it to this:
global tabNumber = 33 ; the word "global" is optional, but helps make it more clear
^l::
Send {Tab %tabNumber%}
Send {Enter}
Sleep, 2500
Click, 235, 380
Sleep, 2500
Send {Tab 19}
Send {Enter}
Sleep, 1200
Send, ^a
Send, ^c
tabNumber += 1
return
I also see you're using 2 tab entries - 33 and 19. To increase both of them, do this:
global tabNumberA = 33
global tabNumberB = 19
^l::
Send {Tab %tabNumberA%}
Send {Enter}
Sleep, 2500
Click, 235, 380
Sleep, 2500
Send {Tab %tabNumberB%}
Send {Enter}
Sleep, 1200
Send, ^a
Send, ^c
tabNumberA += 1
tabNumberB += 1
return
i was trying to make a .ahk to macro a gif making, uploading, and url coping but it often times ignores keystrokes like send, {tab down}{tab up} which compleatly breaks the macro. also send, ^L isnt working when i send it in the middle of the string
^q::
Run, firefox.exe "gifcreator.me"
sleep 9000
Loop 9
{
Send, {tab}
sleep 100
}
send, {enter down}
sleep 500
send, {enter up}
sleep 200
Loop 4
{
send, {ctrl down}
send, ^L
send, {ctrl up}
}
sleep 200
send {ctrl down}
send, a
send, {ctrl up}
sleep 200
send, {delete down}
sleep 200
send {delete up}
sleep 5000
send, C:\Users\John Reuter\OneDrive\art
sleep 300
send, {enter down}
sleep 500
send, {enter up}
sleep 5000
click 1200, 50
sleep 3000
click 1200, 50
sleep 200
send, {ctrl down}
sleep 200
send, v
sleep 200
send, {Ctrl Up}
sleep 13000
click 50, 150
sleep 3000
send, {Ctrl Down}
sleep 200
send, a
sleep 200
send, {Ctrl Up}
sleep 200
send, {Ctrl Down}
sleep 200
send, a
sleep 200
send, {Ctrl Up}
sleep 7000
send, {enter}
sleep 5000
send, 5
sleep 200
send, 1
sleep 3000
send,^{ctrl down}-{ctrl up}
sleep 3000
send,^{ctrl down}-{ctrl up}
sleep 3000
send,^{ctrl down}-{ctrl up}
sleep 3000
send,^{ctrl down}-{ctrl up}
sleep 3000
send,^{ctrl down}-{ctrl up}
sleep 3000
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 300
send, {down}
sleep 3000
click 567, 227; miss
sleep 3000
send, {Ctrl Down}
send, f
send, {Ctrl Up}
sleep 3000
send, download gif
sleep 5000
send, {enter}
sleep 5000
send, {Ctrl Down}
send, l
send, {Ctrl Up}
sleep 5000
send, giphy.com/upload
sleep 3000
send, 2
sleep 3000
click 642, 325
sleep 8000
send, {down}
sleep 3000
send, {right}
sleep 3000
send, {down}
sleep 3000
send, {right}
sleep 3000
send, {down}
sleep 3000
send, {right}
sleep 3000
send, {down}
sleep 3000
send, {right}
sleep 3000
send, {enter}
sleep 7000
send, {Ctrl Down}
send, f
send, {Ctrl Up}
sleep 3000
send, upload gifs
sleep 3000
click right 661, 198
sleep 3000
click 713, 218
sleep 3000
send, {Ctrl Down}
send, l
send, {Ctrl Up}
sleep 3000
send, {Ctrl Down}
send, x
send, {Ctrl Up}
sleep 3000
send, <img src="
sleep 3000
send, {Ctrl Down}
send, v
send, {Ctrl Up}
sleep 3000
send, "alt=""style="width:12px;height:18px;">
;======================
Esc::ExitApp
Instead of sleeps, try using WinWait etc. Look in AHK help file how the commands (Run, WinWait etc.) are properly used.
SetTitleMatchMode, 2
Run, firefox.exe "gifcreator.me"
WinWait, Online Animated GIF Maker
IfWinNotActive, Online Animated GIF Maker, ,WinActivate, Online Animated GIF Maker
WinWaitActive, Online Animated GIF Maker
sleep 100
Loop 8
{
Send, {tab}
sleep 100
}
Send, {Enter}
; WinWait, ...
; IfWinNotActive, ...
; ...
; SendInput, C:\Users\John\OneDrive\art
; ...
EDIT
If the next window doesn't appear after the first "Send, {Enter}", try using a loop:
SetTitleMatchMode, 2
Run, firefox.exe "gifcreator.me"
Loop
{
WinWait, Online Animated GIF Maker
IfWinNotActive, Online Animated GIF Maker, ,WinActivate, Online Animated GIF Maker
WinWaitActive, Online Animated GIF Maker
sleep 100
Loop 8
{
Send, {tab}
sleep 100
}
Send, {Enter}
sleep 1000
IfWinExist, title of next window
break
}
; WinWait, title of next window
; IfWinNotActive, ...
; ...
; SendInput, C:\Users\John\OneDrive\art
Why are you putting a comma after Send? That is not proper syntax. These examples from the AltHotKey website would be the proper syntax for your commands:
Send {b down}{b up}
Send {TAB down}{TAB up}
Send {Up down} ; Press down the up-arrow key.
Sleep 1000 ; Keep it down for one second.
Send {Up up} ; Release the up-arrow key.
Check their web page for more details about the Send command: https://www.autohotkey.com/docs/commands/Send.htm