Kiosk mode in wxpython? - python

Is there a way to create a 'kiosk mode' in wxpython under Windows (98 - 7) where the application disables you from breaking out of the app using Windows keys, alt-tab, alt-f4, and ctrl+alt+delete?

If an application could do that it would make a great denial-of-service attack on the machine.
In particular Ctrl+Alt+Delete is the Secure Attention Sequence. Microsoft goes to great lengths to insure that when the user hits those keys, they switch to a secure desktop that they can be confident that the logon box is the real Windows logon and not a counterfeit.
What you need to look at isn't functions that your application can call, but System Administration options that allow an Administrator to configure a machine for limited use. These exist, but it's more a question for Super User than for Stack Overflow.
This should get you started
http://msdn.microsoft.com/en-us/library/aa372139(VS.85).aspx

wxPython alone cannot be done with that.
You need to do Low Level Keyboard Hook with C/C++ or with equivalent ctypes, for
Windows keys, alt-tab, alt-f4,
but Ctrl-Alt-Del, I don't think so for Windows XP and above.

Related

On button click send character to background application

I'm trying to implement numpad in PyQt5 and Windows 10. There are buttons 1, 2, ... 9, enter
I'd like to implement the following event:
When user clicks for example on button 1, the character '1' will be sent to background application (for example notepad).
I have done simple GUI. I only need to implement this event. What libraries, functions can I use to this purpose?
You should research how Inter-process communication works and APIs.
You did not specify which Operating System you target, each one has its own ways to do it.
You mention "sending characters to notepad" but which application do you plan to communicate with ? Because working with any application may be a very difficult problem.
For Notepad I found this question that uses the Windows API to communicate, but it was relatively easy because the source language was C# (which is well-integrated with Windows). According to this other question you should use PyWin32 to do that in Python.
But if you plan your NumPad application to work with many other applications, you should look how other Input sofwares work. It may have clues how to do it.

Send keystrokes to non-active GUI application without occupying the keyboard

As the title explain, i'm trying to use the terminal to send commands as keystrokes to a GUI application that's minimized.
There is a lot of similar questions here on Stack with some great answers, but i'm having, mainly, three problems with the solutions i saw: Most of the solutions need the automated application to be the active one. Or, i can't normally use my keyboard while the script/process is running. Or worse, the solution works only on Windows OS.
I need what this person asked 2 months ago: Send keystrokes to a specific window (in background), but do something else in the meantime
But i want it on Linux.
I'm using Kubuntu 18.10, if that helps.
xdotool was close, but i couldn't quite get it to send the commands to a specific window or PID. It also uses "my keyboard", so i can't, for example, write an essay/code/browse online while xdotool is running. Pexpect also have this last problem.
AutoHotKey looks like it would work, but it's only for Windows and i'm trying to not use Wine. Same with pywin32.
keyboard (https://github.com/boppreh/keyboard) seems nice, but it can't send a command to a specific application. Same with PyAutoGUI.
I selected the Python tag because most of the solutions i saw use Python, but i'm open to any language.
Use a nested X server to input keystrokes without changing focus or keyboard grab.
Proof of concept:
Xephyr -resizeable :13
export DISPLAY=:13
xterm
xdotool type rhabarber
The Xephyr nested X server is started and will listen on local X socket 13 (whereas :0 typically identifies the currently running X server, but when multiple sessions are ran concurrently, it could be higher).
Then we set DISPLAY environment variable to :13, so any X application we start will connect to Xephyr; xterm is our target application here. Using xdotool or any other tool we can send keystrokes.
As the target X server is identified through $DISPLAY, applications can be started or input events triggered from elsewhere as well. If needed, you might also run a lightweight window manager within Xephyr, e.g. to 'maximize' the application so that it fills the whole Xephyr window.

SendKeys method of AutoIT, shell script or pywinauto lib is not working

Scenario is, I want to handle IE pop up in robot framework with python. To handle pop up, I used AutoIT SendKeys, shell script, pywinauto TypeKeys.
The code is working properly when running on a local machine but when I run the script through team city on the agent machine, then it fails.
My observation is that in the agent machine the code is not working to handle the windows pop up.
After analysis, I have found that this is because the agent machine is working as a locked system while running script through team city.
Code:
def fhandle_savepopup(self):
shell = win32com.client.Dispatch("WScript.Shell")
seleniumLib = BuiltIn().get_library_instance('Selenium2Library')
shell.AppActivate ("Internet Explorer")
sleep(2)
autolib = BuiltIn().get_library_instance('AutoItLibrary')
shell.SendKeys('{F6}')
sleep(3)
shell.SendKeys('{TAB}')
sleep(3)
shell.SendKeys('{ENTER}')
I used AutoIT and pywinauto lib too. But no luck.
Please help me find a solution for this.
You need to keep your desktop open and non-locked (it can be solved by setting auto-logon up + VNC session like TightVNC). For TightVNC you might also require video card drivers update and set custom resolution (in NVIDIA control panel, for example). Of course this node must be connected to the Team City master node from this open desktop (not as a service).
Another option is to click window buttons silently (without real user input emulation). In pywinauto it can be done using Click() (ClickInput() is more realistic and won't work for locked system):
app.Window_(title="Popup title").Wait('visible', timeout=10)
app.Window_(title="Popup title").OK.Click()
P.S. TypeKeys() also works as a real user input. We have plans to implement silent version (SendChars) using WM_CHAR window message that might work for you. But pywinauto 0.6.0 release is currently in deep re-factoring. So it might be released in April or even May, but with great WPF support.

Altering "Send To" on Windows with Python

I need to redirect the "Send To Mail Recipient" menu in Microsoft Office (primarily Word and Excel) to send the document using a web client email. I need to do the same thing with the context menu that appears when right-clicking a file (i.e. Send To -> Mail Recipient).
I'd like to catch these events using Python, probably via PyWin32 via COM or ctypes. Does anyone know how to do this sort of thing? I'm using Windows XP and Python 2.6. Thanks!
the only thing I can think of is to use Microsoft Active Accessibility bindings for Python. These give you the ability to monitor events, including window open/close events. I can't think of any other library that has this functionality.
http://www.cs.unc.edu/Research/assist/doc/pyaa/public/pyAA.AA.AccessibleObject-class.html
I won't kid you. This is not a pretty solution, but it can work.
here's another description:
http://web.archive.org/web/20080510165211/mindtrove.info/articles/gui-automation-with-pyaa/

Python Send Keystrokes to Non-Active Application

I'm automating some common GUI tasks I have to do in an application, and I'm using a Python program and SendKeys to do it. So far I've had to activate the application I'm sending keys to (since SendKeys just sends the keystrokes to the active window), but I'd like to be able to send keystrokes to an application in the background. Is there a way to do that, or am I dreaming an impossible dream?
Thanks for your help.
pywinauto is another MS-only GUI automation tool, this one written in Python.
SendKeys is a Python module for Windows that can send one or more keystrokes or keystroke combinations to the active window.
If you need to do some automated work in the background, make another user/session and do it in that.
However if you must do something of this like on windows, I always reach for autoit.
It's M$ only and perfectly suited to automating tasks on that OS.
This is a frequent question in the autohotkey.com forums. Search under
"sending commands to controls". Basically, if you have the control ID, then it doesn't need to be visible in order to operate on it. There're more details on the forums.
good luck!

Categories

Resources