I am converting a VirtualBox XP image to Virtual PC. When booting up, the XP image is going through the Found New Hardware Wizard.
At this point in the process, VirtualPC does NOT pass in the mouse or keyboard. So I am using a script to run nircmd.
The first thing my script does is clears the Reactivation Message by waiting 10 seconds, sending a Tab key press and an Enter key press.
This followed by a 60 second wait for the New Hardware wizard to appear.
Then I move the cursor onto the Next button.
So far the first five entries work correctly.
(I wait one second and send a left mouse click to get the focus.)
Then try to get the hardware wizard to continue.
None of my attempts work.
Left mouse click - nothing happens.
Enter key press - nothing happens.
send key press of Alt+n - nothing happens.
Left mouse double-click - nothing happens.
So I wait 30 seconds and shutdown - That works.
I am open to suggestions.
thank you,
chuck
Script:
nircmdc wait 10000
nircmdc sendkeypress tab
nircmdc sendkeypress enter
nircmdc wait 60000
nircmdc setcursor 390 390
nircmdc wait 1000
nircmdc sendmouse left click
nircmdc wait 1000
nircmdc sendmouse left click
nircmdc wait 1000
nircmdc sendkey enter press
nircmdc wait 1000
nircmdc sendkeypress alt+n
nircmdc wait 1000
nircmdc sendmouse left dblclick
nircmdc wait 30000
nircmdc exitwin shutdown
Ok, here's what happened.
It seems that my script would only run part way when set to run as a StartUp script from the GPO.
When I added the appropriate items to the script and ran that from the user..\startup location, it worked.
I am not sure why, after the user logon was processed, that the move cursor would work, but not the other steps.
Anyways, if someone else runs into this, this is what I used.
Now someone with higher power than I will need to close this one.
thanks,
chuck
Related
I've made a AHK script to keep an application open and focused as soon as Windows starts / logs in. I've since found though that WinActivate doesn't work in Windows 10 if the Start Menu is open. And apparently the last time "WinClose, Start Menu" worked was in WinXP.
Here's my code changed to use notepad so you can easily see what I'm trying to do (WinClose Start Menu step):
#WinActivateForce
FocusTimer = 3000 ;Time spent between refocusing on window (in milliseconds)
APP_TITLE = Untitled - Notepad ;Title of application window
APP_EXE = C:\Windows\System32\notepad.exe ;Application executable filepath
Sleep, %FocusTimer% ;Allows time for Windows to login and run other startup processes
While(TRUE) ;Infinite loop for program commands
{
Run, %APP_EXE% ;Opens application
Sleep, %FocusTimer% ;Allows time for previous action
While WinExist(APP_TITLE) ;Infinite loop for while application window is available
{
WinClose, Start Menu ;Closes Start Menu if open so as not to interrupt WinActivate command
WinActivate, %APP_TITLE% ;Commands focus on the application window
WinWaitActive, %APP_TITLE%, , 0 ;Waits for application window to have focus
Sleep, %FocusTimer% ;Wait timer before starting the loop again
}
Sleep, %FocusTimer% ;Allows clean-up time before starting the program commands again
}
I don't want to do anything drastic by disabling the Start Menu altogether. I just want to close it to remind the user that "this PC is only to run this application". It'll also alert the fact if randoms walk in and say "The Start Menu keeps closing???" If they want to interrupt the application then they have to manually pause the script via the system tray icon.
TIA
The Start Menu's title is no longer "Start Menu". This seems to work for me:
WinClose ahk_class Windows.UI.Core.CoreWindow ahk_exe SearchUI.exe
WinClose ahk_class Windows.UI.Core.CoreWindow ahk_exe StartMenuExperienceHost.exe ; Suggested by 0x464e
It will also close search and Cortana.
I have a program (program.exe) which I want to be closed when my laptop goes to sleep either if the sleep button was pressed, the lid was closed or some time has passed and entered automatically in sleep mode.
I suspect is something from the Task Scheduler but I don't know how to find event "When laptop goes to sleep" and then to close program.exe
I know that maybe I can do a Python script but I feel Task Scheduler it's the easiest way and maybe someone else, like me, needs to fix the same challenge.
Thanks!
After some digging, I found the solution I will post it here maybe it helps someone at some moment.
Open Task Scheduler
Create Task
Give it a name (Close_program_on_sleep)
Check Run whether user is logged on or not
Select Configure for Windows 7
Go on Triggers tab and then select New
Select from Begin the task: On an event
Select Log = System Source = Kernel-Power Event ID = 42. Click ok
On Actions tab click new and then New> Start a program
On the Program/Script add taskkill /f /im "your_program_to_be_closed.exe"
Ok
Enjoy :)!
I'm playing a game and alongside the game .exe I also run another .exe that runs a personal program I'm developing (it records information that I can then monitor outside the game.)
One of the .exe's opens a cmd window, which I'd then like to immediately close at the end of the .bat.
Pressing enter manually will close the window, however, I don't know how to automate the enter keypress.
All I want to do is automate the pressing of the enter key after both the exes have been launched.
Should be simple to do I guess! but looked around for a while and can't find a solution.
Thanks.
the code for my very very basic batch:
start "" "E:\World of Warcraft\Wow-64.exe"
start "" "C:\Users\Kek\Desktop\New folder\DocumentAll.exe"
Does anyone come across a scenario when the command prompt is running a process and then it gets stuck and the process is also sleeping.
Then when we press Enter key in the cmd window the process continues.
Is there any way to avoid this?
or can this be handled??
The other answers are wrong! The Windows console has a separate mode called "mark mode" for selecting text. In that mode the screen will be frozen, texts will go into the buffer and if the buffer is full the running process will be blocked
If quick edit mode is enabled (by default it's disabled in older Windows but enabled in Windows 10) then clicking inside the console window will activate mark mode and result in what you observed
It's very easy to accidentally click the console and stop the command. When you press Enter or Esc the selected text will be copied to clipboard and mark mode will be exited, therefore the process will run again. Priority is absolutely irrelevant here because if the buffer is full then the process is blocked forever until you exit mark mode, regardless of the priority. The console does nothing to change the priority when there are some inputs. Try opening an app that outputs a lot of data in the highest priority and click the console, the app will still be blocked indefinitely even if the CPU is in idle
Here's an example of QuickEdit mode setting in Windows 8 console:
To fix this you can disable QuickEdit mode if you don't need it. In this case copying will be more troublesome because you must open the context menu, select Edit > Mark. You can also disable QuickEdit mode by setting ENABLE_QUICK_EDIT_MODE with SetConsoleMode() if you're writing your own console application
See also
How and why does QuickEdit mode in Command Prompt freeze applications?
What does it do exactly if I click in the window of cmd?
Turn off Windows 10 console "Mark" mode from my application
If other processes are sucking all the cycles and have a higher prio, then your process might be stopped. A user input might just give it a prio boost, so it starts again. See Microsoft Docs at https://learn.microsoft.com/en-us/windows/win32/procthread/priority-boosts for more information.
It happened to me today while executing a batch file that includes TFSBuild.
I already received email notification from TFSBuild that it is successful, but somehow the batch file did not proceed to the next line.
I waited 1 hour.
I pressed Enter, Mark for Edit etc. but none of that worked.
Then I hit Ctrl+C to try to terminate the batch file.
When asked if I want to terminate, i entered N.
Weirdly enough, the batch file continued after that.
Is it possible to automate a program in windows and run a sequential click of each control and buttton. for example click some radiobutton to configure some setting and press enter.
For an example, Is it possible if i run this cauculator program once a day click 1+1 then click equal and close this program after it finished execution or at a certain amount of time for example 1 15 minute
Add More information : i have a program that my boss want to run this once a day. I have to click the same radio button setting everyday and press enter. i have no source code of it i am just an end user. i am looking for a way to automate this
Not sure what you really intend, but AutoHotkey might be your weapon of choice for the automation part. The scheduling can also be done in AutoHotKey or with the Windows inbuilt task scheduler.