Is there a way for pyautogui to work without taking over mouse/keyboard control? - pyautogui

I was able to write a simple game bot using pyautogui.click, pyautogui.locateonscreen, and a bunch of if/while statements.
The bot works fine, however, is there a way for the bot to work without taking over mouse control?
Example: I would like to be able to browse stackoverflow.com with the bot running.

No, pyautogui only simulates user input which will take over the mouse/ keyboard.
From their github, "All keyboard presses done by PyAutoGUI are sent to the window that currently has focus, as if you had pressed the physical keyboard key." And similarly the mouse automation just sends commands to the OS as if you had physically moved/ clicked your mouse.
To write a program to control a game while still allowing you to use user control (mouse/ keyboard) you will have to directly send commands to the game by manipulating the game's memory. This is called making a "trainer". https://en.wikipedia.org/wiki/Trainer_(games)

Related

What event is raised when the Start button is pressed in Windows Phone 8.1 RT

I used MediaCapture APIs in my App. Let's say I started recording and preview. During recording, I pressed Start key and quickly come back to the App by long pressing Back key and selecting my app (task swap). The result is that the preview is frozen either running on Emulator or 8.1 WP hardware. I don't find a better event to register for Start key. I understand that this.Resume can handle restoration when your APP is being deactivated. But here I mean I switch back from Start within 2~3 seconds and the Resume call is not get called. I am thinking that I can disable preview when Start key is pressed as a workaround. Then when App is brought back to foreground, user can restart recording. However, both scenarios I can't find a proper event. Of course if preview is not frozen when APP is swapped back, I don't need to do anything. Now it seems preview is not working after task swapped back from Start.
Here are the APIs I am using
_mediaCapture.StartRecordToStorageFileAsync(_profile, _recordStorageFile);
capturePreview.Source = App._mediaCapture;
_mediaCapture.StartPreviewAsync();
The issue you're hitting here has to do with the fact that as long as the debugger is attached, suspending/resuming won't work like it will once your app is running on its own.
See here: https://msdn.microsoft.com/en-us/library/windows/apps/hh974425.aspx
Try the same thing you're doing right now, except press the Suspend button in VS once your app is in the background. To bring it back, press the Resume button. Alternatively, try the same thing without the debugger attached.
As long as you're handling the Suspending/Resuming events correctly, MediaCapture lifecycle won't be a problem.
To learn more, have a look at the UniversalCameraSample on the Microsoft github repository: http://aka.ms/2015builduniversalcamerasample. It targets Windows 10, but a lot still applies to 8.1.
There are three events you can register for.
CoreWindow.Activated will be raised when you are no longer the foreground app. This can happen because the user switched away, or because something like a Reminder or Phone Call popped up on top, etc. Simply getting a toast notification does not raise the Activated event.
CoreWindow.VisibilityChanged will be raised when you are no longer visible. This happens when the user switches away, locks the phone, etc.
CoreApplication.Suspending will be raised when you are being suspended. The system doesn't suspend you immediately when the user switches away (in case they switch back quickly, eg they had accidentally hit the Start button). Instead it waits a few seconds before raising this event.

Windows Phone 8 fire a background task on call picked without accessing any call details

I am looking to develop an application where i just need to detect whenever a call is picked up.
I do not need any details related to call log and just need the event to be fired which will manipulate the sensors and do some functionality.
Is it possible to have that kind of access. Is it available out of the box and if not, is there a way that I can request for access from Microsoft?
WP apps don't have this kind of access/functionality.
Only possible way would be to use the Obscured Event (http://msdn.microsoft.com/library/windows/apps/microsoft.phone.controls.phoneapplicationframe.obscured%28v=vs.105%29.aspx) Which requires your app to be launched all the time you want to capture the activity.
The problem here is that Obscured event is also fired in the case of alarm or lockscreen.
I doubt Microsoft will grant you access to more functionality.

ActionScript 3.0: Wait for response from Flash Player Settings window

I recently received some code from another developer and there's one piece I would like to rework. It's a flash app that works with mic and webcam. When it is started you are prompted to press a button - after that the usual flash player settings windows appears asking you to allow access to mic and cam. The application needs to wait for user's response on this question. It was achieved in the code I received in a rather awkward fashion. Application progressed on mouse movement event, which would not be registered since the flash player settings popup block the area. Once it out of the way - any mouse move would make application to go on. I need to rework with in some better way, because this piece of code is also used in AIR application that doesn't ask for allowance and, therefore, if you click the opening button you would need to move your mouse in order to get things running. I believe there must be some decent way to notify the app that settings popup is gone. Could anyone advice on this?
The correct way to do this in Flash Player is to listen for StatusEvent.STATUS event which is dispatched after the user either allows or denies you access to their mic. See the documentation for Microphone.getMicrophone().
In AIR, however, you don't have to ask for user's permission to access their mic and camera, so this event is not dispatched when your application gets access to the input device. In that case, you can check through Capabilities.playerType property if your code is running in AIR and then proceed with doing what you would have done in response to receiving permission to access user's input devices.

Suppress Reminder in Windows Phone and instead Simulate Navigation from within code

In Windows Phone, the reminder is usually used for scheduled notifications. The reminder when popped up, requires user to click the reminder pop up in order to navigate to specific page and do certain action.
Can we simulate or suppress this reminder programatically when occured and instead perform the action it was supposed to execute when actually clicked. This would be of great use to user.
Any help, suggestions or ideas on the same?.
Thanks In Advance.
It isn't possible. A Windows Phone application has very limited interaction with the system when it isn't running in the foreground.
If you're trying to bypass the reminder to display something (for instance, a page of your application) without user interaction, then you have no way of doing that.
If it's just about updating some data or calling a webservice without displaying anything, you should use a background agent instead of a reminder.
Windows Phone was built around the idea of letting the user in control at all time. That's why there is no way of forcing the user to navigate to a page of your application if it wasn't running in first place.

How to detect calls while app is in the background?

So I understand that a foreground app can detect phone calls by registering for the obscured event, but while my app is running in the background, playing sound, sending notifications, etc, it does not hit the same event.
Is there a specific way to handle phone calls in this circumstance? The obscured event is the only one that I can find for detecting phone calls, but it won't work in this instance.
Unfortunately, with the current API there isn't...
In fact, I'd say that the obscured event can't even be considered a reliable way to detect an incoming phone call: you can use it right now for that purpose, but tomorrow Microsoft can just go ahead and add new stuff that will raise that very same event!