To prefix, I am using the latest copy from the website, and have installed the 64 bit version.
I am attempting to open 2 seperate notepads and simply bounce back and forth between them and type numbers. I know this sounds simple, I want to be able to have multiple other notepads running and only switch between the two handled by the script while ignoring the others. Following is the code I thought would accomplish this, but it seems to fail.
My thinking was that As I run the instances of Notepad that I could retain the Process IDs for each then use those to access the specific windows, I was expecting to see two instances of Notepad, one with odd numbers 135 and the other with even numbers 246 displayed. Instead I see two instances of notepad and all numbers 1,2,3,4,5,6 displayed in one and the other blank.
Following is my code, any assistance you can render would be of great help.
Code: Select all
#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.
; This key will create a pair of notepads and type in them seperately.
^d:: ; Control D
Run Notepad.exe, , , Pad1PID ; Create first Notepad
Run Notepad.exe, , , Pad2PID ; Create second Notepad
WinWait ahk_pid %Pad1PID%, , 3 ; Activate the first Notepad
Send, 1 ; 1
WinWait ahk_pid %Pad2PID%, , 3 ; Activate the second Notepad
Send, 2 ; 2
WinWait ahk_pid %Pad1PID%, , 3 ; Activate the first Notepad
Send, 3 ; 3
WinWait ahk_pid %Pad2PID%, , 3 ; Activate the second Notepad
Send, 4 ; 4
WinWait ahk_pid %Pad1PID%, , 3 ; Activate the first Notepad
Send, 5 ; 5
WinWait ahk_pid %Pad2PID%, , 3 ; Activate the second Notepad
Send,6 ; 6
Return ; Done