I work with a web application that works only on Mozilla Firefox.
A particular task generates a page to print a letter to be mailed.
After printed the letter, my colleagues should stamp the brand of post office and manually write the send date on which the letter is sent.
Is there any way to manipulate the display of the page to include a line in HTML with the stamp image before printing?
Any ideas?
Thank you very much.
Is there any reason it needs to be done via autohotkey? If you have access to the code, you could just add a print stylesheet that overlays the stamp image.
SmashingMagazine has a fantastic guide to print stylesheets:
In essence, all you have to do is add this to your existing stylesheet:
#media print {
//css to add the stamp image overlay here
}
Thanks for feedback.
I figured it out.
That's my code:
#NoEnv
#Persistent
#SingleInstance force
SendMode Input
SetWorkingDir %A_ScriptDir%
Gui, Add, Button, gCorreios, Correios
Gui, Show
Return
Correios:
Sleep 100
Send, {ALT DOWN}{ESC}{ALT UP}
Send, {CTRLDOWN}f{CTRLUP}
Sleep 10
Send, Postado{ESC}
Sleep 10
Send, {SHIFTDOWN}{END}{SHIFTUP}{CTRLDOWN}c{CTRLUP}
ClipWait
Sleep 10
DataDaPostagem=%Clipboard%
ClipBoard =
Sleep 10
StringReplace, DataDaPostagem, DataDaPostagem, postado,, All
StringReplace, DataDaPostagem, DataDaPostagem, em,, All
StringReplace, DataDaPostagem, DataDaPostagem, :,, All
StringReplace, DataDaPostagem, DataDaPostagem, `,,, All
StringReplace, DataDaPostagem, DataDaPostagem, %A_SPACE%,, All
Sleep 10
Send, {SHIFT DOWN}{F4}{SHIFT UP}
WinWait, Scratchpad,
IfWinNotActive, Scratchpad, , WinActivate, Scratchpad,
WinWaitActive, Scratchpad,
Send, {CTRLDOWN}a{CTRLUP}{DEL}
Send, var correios=document.createElement("div");{ENTER}
Send, correios.id="correios";{ENTER}
Send, correios.style="background:url(http://i62.tinypic.com/169hxls.png) no-repeat; display:block; height:37px; padding:135px 0 0 0; position:absolute; right:0; text-align:center; top:0; width:171px; z-index:-1";{ENTER}
Send, correios.innerHTML="
Send, %DataDaPostagem%
Send, ";{ENTER}
Send, document.getElementsByTagName("body")[0].appendChild(correios);{ENTER}
Send, {CTRLDOWN}r{CTRLUP}
Sleep 10
Send, {CTRLDOWN}w{CTRLUP}
WinWait, Alterações não salvas,
IfWinNotActive, Alterações não salvas, , WinActivate, Alterações não salvas,
WinWaitActive, Alterações não salvas,
Send, d
Sleep 10
return
~^s::
IfWinActive, %A_ScriptName%
{
SplashTextOn,,,Updated script,
Sleep, 200
SplashTextOff
Reload
}
return
Related
First, Here's the code
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force
IfWinNotExist, ahk_exe VisualBoyAdvance.exe
{
Run, VisualBoyAdvance.exe, D:\Games\GAMEBOY ADVANCE (.gba)\GBA\emu
WinWait, ahk_exe VisualBoyAdvance.exe
WinActivate, ahk_exe VisualBoyAdvance.exe
return
}
WinActivate, ahk_exe VisualBoyAdvance.exe
sleep, 1000
MouseClick,,22,40
sleep,100
MouseClick,,116,257
sleep,100
MouseClick,,342,312
sleep,100
MouseClick,,179,16
return
Joy4::
MouseClick,,77,43
sleep, 100
MouseClick,,111,105
sleep, 100
MouseClick,,263,217
sleep, 100
MouseMove, 1380, 251
return
Joy1::
Send, {Shift Down}
Sleep, 100
Send, {F1}
Sleep, 100
Send, {Shift Up}
Return
Joy12::Send, {F1}
return
;LCtrl::
;ExitApp
It's basically open VisualBoyAdvance from the top of the recent list on VBA, i wanted to whenever i close the VBA, the script closed as well.. i've tried lot of method on the AutoHotKey Website, like :
Process, WaitClose, exwfile.exe
ExitApp
Return
Or
RunWait, calc
ExitApp
or
Run, C:\Program Files (x86)\Sonos\Sonos.exe
WinWait, ahk_exe Sonos.exe
SetTimer,Sonos,100
Sonos:
IfWinNotExist, Sonos
ExitApp
Return
but none of them works
please help me
thank you
Try using WinWaitClose followed by ExitApp:
// [...]
sleep,100
MouseClick,,179,16
WinWaitClose, ahk_exe VisualBoyAdvance.exe
ExitApp
Return
// [...]
IfWinNotExist, ahk_exe Sonos.exe
The script is searching for a certain text in the clipboard. When found, it shows a MsgBox.
I would like this script to stop when the text has been found. How to achieve that?
#Persistent
MouseMove, 821, 700
Sleep, 500
MouseClick, Left
Sleep, 500
Loop, 5
{
Send, ^c
Sleep, 500
Send, {PgDn}
}
OnClipboardChange:
If InStr( Clipboard, "Part3" )
SetTimer, PopupMsgBox, -1
Return
PopupMsgBox:
Msgbox, Part3 Found
Return
#Persistent
clip_search := "Part3"
MouseMove, 821, 700
Sleep, 500
MouseClick, Left
Sleep, 500
Loop, 5
{
Send, ^c
ClipWait
If InStr( Clipboard, clip_search )
{
MsgBox, % clip_search " Found."
Break
}
Sleep, 500
Send, {PgDn}
}
I have been looking into this for a few days ♫ And i still haven't found what I'm looking for♫ The problem is that the script runs when I insert the sd card AND when I take it out. Any suggestions to how I could get it to just run on insert?
Code:
#Persistent
OnMessage(0x219, "notify_change")
notify_change(wParam, lParam, msg, hwnd)
{
send, <#{right}
sleep, 100
MouseClick, left, 726, 615
send, ^a
sleep, 100
send, ^c
sleep, 100
GroupAdd, ExplorerGroup,,ShellView
GroupActivate ExplorerGroup
send, ^v
return
}
So this is my very first AHK program and I am not at all familiar with the language. I am familiar with C# though. I have the following `program that loops trough a file and splits a username and password split by a pipe (|) symbol. Right now when I run the program, it does not stop looping after the end of the file.
In addition, I try to access the username and password separated by the pipe symbol using the StrSplit function. so far, when I run the program, the username is only sometimes enteredcorrectly into the browser. The password is not entered into the browser. I am pretty sure `I am using the right mouse coordinates.
Thanks in advance` for the help!
#SingleInstance, Force
SetWorkingDir, %A_ScriptDir% ; if an absolute path isn't specified
;; GUI input
;-------------------------------
; ---------------------------------------
Gui, Add, Button, x10 y20 gStart, Start the tool
Gui, Show, w300 h300, Steam Tool
return
; Labels
; -----------------------
; --------------------------------
Start:
Loop, read, accounts.txt ; the file name must be separated by a comma
{
; MsgBox %A_LoopReadLine%
loop, parse, A_LoopReadLine,
{
IfWinNotExist, Multiloginapp - 01.3.15
{
Run, C:\Program Files (x86)\Multiloginapp\multiloginapp.exe
WinWait, Multiloginapp - 01.3.15
Sleep, 20000
}
IfWinNotActive, Multiloginapp - 01.3.15, ,WinActivate, Multiloginapp - 01.3.15
WinWaitActive, Multiloginapp - 01.3.15
Click 724, 260
sleep, 1500
WinWait, Multiloginapp - Mozilla Firefox
WinActivate, Multiloginapp - Mozilla Firefox
WinWaitActive, Multiloginapp - Mozilla Firefox
Click 408, 55
Sleep 5000
Send, ^a
Send, {Backspace}
SendInput, store.steampowered.com/account ; SendInput is faster in sending text
Send, {enter}
Sleep, 5000
; Use:
; SendInput, %A_LoopField%
; if you want to send the current substring (field) from the line
s:=StrSplit(A_LoopReadLine, "|")
Click, 149, 355
urnme := s[0]
Send, %usrnme%
Click, 172 455
pwd := s[1]
Send, %pwd%
Click, 87 507
}
}
return
Try it this way:
#SingleInstance, Force
SetWorkingDir, %A_ScriptDir% ; if an absolute path isn't specified
;; GUI input
;-------------------------------
; ---------------------------------------
Gui, Add, Button, x10 y20 gStart, Start the tool
Gui, Show, w300 h300, Steam Tool
return
; Labels
; -----------------------
; --------------------------------
Start:
IfWinNotExist, Multiloginapp - 01.3.15
{
Run, C:\Program Files (x86)\Multiloginapp\multiloginapp.exe
WinWait, Multiloginapp - 01.3.15
Sleep, 20000
}
IfWinNotActive, Multiloginapp - 01.3.15, ,WinActivate, Multiloginapp - 01.3.15
WinWaitActive, Multiloginapp - 01.3.15
Click 724, 260
sleep, 1500
WinWait, Multiloginapp - Mozilla Firefox
WinActivate, Multiloginapp - Mozilla Firefox
WinWaitActive, Multiloginapp - Mozilla Firefox
Click 408, 55
Sleep 5000
Send, ^a
Send, {Backspace}
SendInput, store.steampowered.com/account ; SendInput is faster in sending text
Sleep, 300
Send, {enter}
Sleep, 5000
; If the title of the window changes after this, you should use:
; WinWait, new title
; WinActivate, new title
; WinWaitActive, new title
Click, 149, 355
; ... continue using one of the next options
; ...
return
First option - Send username and password directly (without reading a file):
SendInput, username
Sleep, 300
Click, 172, 455 ; or Send, {Tab} if it activates the password field
Sleep, 300
SendInput, password
Click, 87, 507 ; or Send, {enter} if it activates the log-in field
Second option - If you have to read username and password from a file:
FileReadLine, OutputVar, accounts.txt, 1 ; If username|password (without spaces) is the first line in this file
usrnme := StrSplit(OutputVar,"|").1
pwd := StrSplit(OutputVar,"|").2
SendInput, %usrnme%
Sleep, 300
Click, 172, 455 ; or Send, {Tab} if it activates the password field
Sleep, 300
SendInput, %pwd%
Sleep, 300
Click, 87, 507 ; or Send, {enter} if it activates the log-in field
I need to find a way in AHK to wait for a program to finish, before starting a new one.
Basically, I have a script that opens an application and inputs some parameters. The application then spends an unknown amount of time processing the input data.
Unfortunately, at the moment the ahk script ends before the application has finished processing, at which point the same ahk script is run again and does not work / interrupts the previous processing.
edit: (the ahk .exe is called using subprocess calls in Python)
is there a way or any methods to help with this?
For reference, the script:
#NoEnv
CoordMode, Mouse, Window
SendInput Mode Input
#SingleInstance Force
SetTitleMatchMode 2
#WinActivateForce
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1
if 0 < 2 ; The left side of a non-expression if-statement is always the name of a variable.
{
MsgBox, This script requires 2 incoming parameters but it only received %0%.
ExitApp
}
IfWinNotExist, ahk_exe photoscan.exe
{
Run, "C:\Program Files\Agisoft\PhotoScan Pro\photoscan.exe"
}
sleep, 200
WinActivate, ahk_exe photoscan.exe
sleep,5
WinMaximize, ahk_exe photoscan.exe
;Macro5:
Click, 476, 438, 0
SendInput {LControl Down}
SendInput {r}
Click, -56, 157, 0
WinActivate, Run Python Script ahk_class QWidget
sleep, 400
SendInput {LControl Up}
SendInput {LControl Down}
SendInput {a}
SendInput {LControl Up}
sleep, 400
SendInput {Backspace}
SendInput %1% ; 1st argument is the photoScan API scriptimages folder directory
SendInput {Tab}
SendInput {Tab}
sleep, 400
SendInput {LControl Down}
SendInput {a} ; 2nd argument is additional args (in our case, the projectName)
SendInput {LControl Up}
SendInput {Backspace}
SendInput %2% ; 2nd argument is the images folder directory & name of output log, model and texture
Sleep, 703
SendInput {Enter}
Click, 476, 438, 0
Return
You have:
IfWinNotExist, ahk_exe photoscan.exe
{
Run, "C:\Program Files\Agisoft\PhotoScan Pro\photoscan.exe"
}
sleep, 200
Which is set to start/launch the application if it is not running. Then a sleep to allow two tenths of a second for it to load (which is probably too small).
Instead of just a ‘sleep’ you have to ‘WinWait’ or ‘WinWaitActive’, found at this link:
https://autohotkey.com/docs/commands/WinWaitActive.htm
Like this sample:
Run, "C:\Program Files\Agisoft\PhotoScan Pro\photoscan.exe"
WinWaitActive, ahk_exe photoscan.exe, , 2
if ErrorLevel
{
MsgBox, WinWait timed out.
return
}
else
WinMinimize ; minimize the window found by WinWaitActive.
You may also have to use the window inspector to get the true name of the window/application/process name.