Detecting GUI state and generating user input programmatically in Windows Xp - windows

I am looking for a lightweight solution that would allow me to detect which form/ dialog is open in an application, then emit some keystrokes / mouse moves and clicks. I do not have control over (nor the source-code for) the application.
I am familiar with MacroMaker, also testing products like SQA / Mercury offer similar functionality. The last time I had hands on exposure in this are is late 2004, I welcome any pointers to bring my knowledge up to date.

AutoIt is a scripting environment for Windows with a long history. It's quite easy to use and flexible to do things like detect the open window or dialog, change to another one, type something, etc. I would definitely recommend it.

In case anybody is curious, in the end I decided to use Microsoft UI Automation. Here is nice intro:
http://msdn.microsoft.com/en-us/magazine/cc163288.aspx

Related

Low level keyboard hook

I just bought a new keyboard, and I'm interested in tracking exactly how many keypresses/strokes I make during the entire life of the keyboard. (I would want to just record keyUp, as I don't care about repeats)
I've been googling around for the best way to do this, but I don't even know what approach to take, so I'm having trouble searching intelligently.
Also, the only language I've really worked with is C#. Haven't done anything with C/C++ or WinAPI
Is it difficult to modify the Win 7 drivers directly?
I do want to be able to record keystrokes from the moment the computer boots, but this may not be easily done.
I would prefer to use an existing driver or hook, as I really don't care to get into learning device drivers right now.
I've looked briefly at Ctrl2Cap, but I don't know how to modify something like that to suit my case.
Other questions I looked at,
Writing a keyboard device driver
Low level keyboard Hook not at UI thread
This one indicates writing a USB Filter driver may work, but I have no clue where to start on that.
Disabling the keyboard in windows c++?
It is not necessary to go the driver route, which is not for the faint of heart. You can use use a low level keyboard hook which will work fine from .NET.
I did a quick bing and found the following on codeplex
http://globalmousekeyhook.codeplex.com/
It should get you going
If you want to do that you need to use Kernel Level Keylogger. It's grabs the keystrokes before the operating system takes effects and this one 99% invisible for detection techniques. Then you can grab the Windows Log On screen typed things like password/username etc.
#ChrisTaylor's key logger not work for WinLog-on Screen I reckon. If you can install the keyboard driver filter before the system keyboard device driver take a action you can handle windows user login screen also. But In order to install this driver level key hook you need to have administrator privileges.
I found Unix and Windows Keyloggers from Github. Free to play with this https://www.adlice.com/kernelmode-rootkits-part-3-kernel-filters/ and have fun!
That, what you want is dangerous!
With the same code everyone can create keylogger*
But if you not a virus creator then I recommend you to search "hotkeying in C/C++" or something like that and hook keyboard with hotkeys!
I have written HotKey Maker in VB6 which can make hotkey from every button of keyboard.
But I really not interested in viruses :)
Good Luck !
*Virus which hooks your keyboard and send all what you wrote in keyboard to Virus owner

Is it possible to call a function in a different, but currently executing process?

I have a friend who's working at a company that offers pretty poor support for its developers (scoring a 1/12 on the Joel Test).
Their build process is locked down pretty tight, and depending on the size of project it could take 40+(x2) mouse clicks to deploy. So I thought, "Hey, why not automate it the clicks using the win32api?" (Specifically using Python). I've got him a real nice tool that works just fine except for one issue - the tool that they use has a navigation pane that may or may not be open.
You can open and close it with a button press, but I'm not sure how I could make sure it was either open or closed. It's irrelevant to the build process - the only problem is that it alters where the mouse needs to click on the screen depending on its open status. The application is written in .NET and it exposes a function call that applications are able to use to toggle the panel, so I've been looking around for ideas and so far I've got two of them:
Attach to the process via a debugger and execute the function call somehow.
Take a screenshot at the location of the panels titlebar (which I've got through the win32 API and doesn't appear to change regardless if the panel is hidden or not).
Is there an easier way to figure out the state of this panel? The developers are given an admin account on their machine in addition to their regular account, so I can entertain ideas that require admin access, though I don't think that should be necessary?
UPDATE:
It looks like there's a button that can close the pane. In UIAVerify something shows up as "text" "Navigation" "btnClose". It says its AutomationId is btnClose but it's a ControlType.Text
What technology is this panel built from? Is it standard GDI or WPF? If its GDI, it should have a HWND. You should be able to find this HWND through either a class name or window title. Once you have the HWND, you can get its width.
If its built with WPF, er, I have no idea, but Snoop does this kind of thing, so I know its possible.

Desktop app noob question: best cross-platform library that can listen for window-change events (focus, lose focus, etc)?

I've only ever done server, web, and database programming, never any desktop programming. I now want to learn and have a small project I want to attempt, but am not sure which library/framework to use.
I'd like to create a small cross-platform app that runs in the system tray (and whatever the OSX equivalent is), and listens for changes to windows on the Desktop. Specifically:
Windows XP, Vista, 7, Gnome, KDE, OSX. BSD, Android, and/or iOS would be nice too but not required.
Listens for when any window gains focus, loses focus, is opened or closed, or if the window title changes (for example when switching tabs in a tabbed browser). Any other information it can scrape from the window would be useful as well.
Can store these events, preferably in an embedded database like SQLLite.
The lighter-weight the better.
Includes an options GUI accessible via a right-click menu from the system-tray icon.
Preferably FOSS, but if you know any non-FOSS please list too.
Is there a single library or framework that can do all that across multiple platforms? QT? Python? Java? Something else? TIA.
Almost any GUI framework can easily let you know when your own application gains or loses focus (or the other operations you mention). However, listening for these events for other arbitrary applications is definitely platform-specific and may or may not even be possible.
One framework for doing this on Windows is the CBT callback hook. See the question CBT Hook not working in Windows Vista for information about possible limitations on using this technique.

Get title of front window in carbon

I am writing a program to sit in the background on osx 10.6, listen to keystrokes and record them, grouping them by window title. (No, I am not writing malicious software. I do not need this program to be sneaky in any way, I just want to have a safety net for when I have typed a huge email and then accidentally refresh the page (APPLE-R) instead of opening a new tab (APPLE-T)) I have already found apple's EventMonitorTest example for the keystroke capturing code, now I just need to find the "key window" title.
Does anyone know where I can find examples for this kind of functionality? Thank you!
A couple of possibilities:
You could use the Accessibility API (though of course keep in mind that 64-bit Carbon does not support this)
You could use the CGWindow functions introduced in Leopard
I suspect the first option will be easier to do this with, since the CGWindow API is somewhat low-level and treats all windows (application windows, menu bars, dock icons, etc.) more or less equally.

Painting directly on the Windows desktop

I'd like to play animations on the Windows desktop without relying on 3rd-party products such as StarDock DeskScapes or Windows DreamScene. What APIs should I look into?
you can read this thread...
http://www.gamedev.net/community/forums/topic.asp?topic_id=113986
it is long, but in it, is a discussion of writing to the desktop...
hope this helps...
~Bolt
I've never done this, but here's the approach I'd take.
Inject a dll into explorer via SetWindowsHookEx.
Grab a handle by using GetDesktopWindow.
Subclass the Desktop using GetWindowLongPtr & SetWindowLongPtr.
Do all your fancy rendering in the new WndProc you've hooked up.
Be aware that breaking the Desktop window will probably lock up your machine, as all its decedent windows (read: every window for that User) will likely be adversely affected.
Also, given the um rich compatibility history of Windows, be on the lookout for dummies meant to absorb abuse. In particular, I wouldn't be at all surprised if GetDesktopWindow does not in fact return the Desktop window you're looking for. You might have to do some digging with Spy++ or the like, basically.

Resources