How to run Android-x86 with a resolution of 3840*2160 inside VMWare - vmware

I am using VMWare Workstation Player on a Smart Table under Windows and would like to get Android-x86 running there at 3840x2160 resolution.
By default, this is simply not possible. At 1152x864 is the highest resolution that the VM returns me, I could set if I use vga=ask.
I used the following link as a guide:
https://kb.vmware.com/s/article/1003
That is I have expanded the .vmx file of the VM and entered the following accordingly:
svga.vramSize = 33177600
svga.maxWidth = 3840
svga.maxHeight = 2160
Permanent change it inside the VM could be done like as example:
If the android system is started press Alt+F1.
type in
mkdir /mnt/sda
mount /dev/block/sda1 /mnt/sda
vi /mnt/sda/grub/menu.lst
press i to edit, replace quiet to nomodeset xforcevesa if you have not done it until now. Because you can make sure, that it will boot. At the end of the line add UVESA_MODE=yourdesiredresolution as example UVESA_MODE=1280x720
press Esc to return read-mode press :w then press Enter press :q then press Enter type reboot then press Enter
Okay, that was just an example. When booting up, you can press e accordingly when booting, then e again and set it individually for this boot process. As mentioned at the beginning with vga=ask you can display what should be supported. Accordingly, I would have to configure something else, since the change of the .vmx has not provided any added value.
Does anyone have experience with this and could help? Thanks in advance!

Related

C++ Win32 How to unlock a Bitlocker volume and assign a drive letter after?

I have the following problem: I am trying to unlock a Bitlocker volume (by using the unique drive ID) and assign a mount point after it's unlocked. The reason why I try to do this in the previous mentioned order is that if I assign a drive letter before it's unlocked the Windows Autorun will try to open it and will prompt an error message (ex: Cannot open F:\ because it's encrypted). I am using Win32 API to get the BitLocker volume ID and set the mount point. The unlocking part is done using a call to powershell from C++ program (using system(), WinExe(), CreateProcess(), etc).
The following sequence works (but has the drawback mentioned above): Find the Bitlocker volume ID -> Set mount point/volume letter for it -> Unlock using system + PS script with volume letter argument;
What I am trying to do is: Find Bitlocker volume ID -> Unlock using system + PS script with volume ID argument -> Set mount point/volume letter of unlocked volume.
The second method is not working: the volume is encrypted after the Set mount point function gives it a drive letter.
The only hint I have is that the PS script is not working from C++ program when using Volume ID as parameter (instead of drive letter).
Powershell script (with drive letter as parameter):
start powershell.exe -WindowStyle Hidden Set-ExecutionPolicy Unrestricted; Unlock-BitLocker -MountPoint "F:\" -RecoveryPassword ..........
Powershell script (with Volume ID as parameter, not working):
start powershell.exe -WindowStyle Hidden Set-ExecutionPolicy Unrestricted; Unlock-BitLocker -MountPoint "\\?\Volume{00000000-0000-0000-0000-000000000000}\" -RecoveryPassword ..........
C++ code snapshot (working version):
/* Code that identifies the VolumeID for the BitLocker volume */
SetVolumeMountPointW(L"F:\\", VolumeID); // this sets the mount point for the BitLocker volume
system(ps_script_drive_letter); // this does the unlocking thing; also works with WinExe; haven't tried CreateProcess but I think it works with that function also;
C++ code snapshot (not-working version):
/* Code that identifies the VolumeID...... */
system(ps_script_volume_id); // this doesn't seems to be working; in debug mode, after I execute this and assign a drive letter using Windows Drive Management the Bitlocker Volume is locked;
SetVolumeMountPointW(L"F:\\", VolumeID); // same as above
I also tested the Powershell command Unlock-BitLocker -MountPoint "\\?\Volume{00000000-0000-0000-0000-000000000000}\" -RecoveryPassword .......... and is working when executed from Powershell (but not from inside the C++ app). If I assign the mount point from Windows GUI it works ok (the bitlocker volume is unlocked). If i assign the mount point from C++ code, it get locked.
Hope we can find a workaround this problem (or what am I doing wrong in the code above).
Thanks :)

How to detect which button is pressed in windows form message box?

In my windows form application,I want to prompt to user to restart the PC. This is my code:
if(MessageBox::Show(L"Restart your PC now?", "Attention!", MessageBoxButtons::YesNo, MessageBoxIcon::Question)==::DialogResult::Yes)
{
//restarting pc
system("c:\\windows\\system32\\shutdown /r /t 10 \n\n");
system("PAUSE");
}
But this code give me error at ::DialogResult::Yes. I'm following Microsoft documentation. How to solve this?
Guessing...
It looks like this is .NET code (albeit in C++) in this case the DialogResult type is not defined at global scope, but in the System::Windows::Forms namespace. So, remove the leading :: (or fully qualify it as System::Windows::Forms::DialogResult).
Also note, that there are APIs to restart windows ExitWindowsEx or InitiateShutdownEx. No need to invoke an external program.

Crontab No Longer Runs Raspberry Pi Python Script in Background But Still Runs Manually

I am able to run my Python script in the background to control two servos by automatically launching the script at boot up using sudo crontab -e. I modified the script so I am now continually writing the servos current position to a horz.txt and vert.txt file and using those files to initialize the steppers to their home position so I can find home position again after a power loss. The script works fine with the horz.txt and vert.txt code that I added when I manually launch the script from the command line on the black screen using sudo python mystepper6.py, but it doesn't launch automatically at startup nor does it show up as running when I type ps ax on the command line. I added a little extra code just to wiggle the servos before the main program starts and and the servos automatically wiggle as programmed in the sudo crontab -e but then it just stops and won't continue to find the home position. It seems to be something with the new code but I don't know what it could be. My sudo crontab -e line is #reboot (sleep2;python /home/pi/mystepper6.py) &. Below is the script for mystepper6.py.
The script below was shortened to show the relevant lines due to limited space available in this post. The sudo reboot hangs with no error message near the bottom where it is commented 'move to home position' (it doesn't move). I am able to print adjustv and adjusth integers prior to that point so the variables are properly assigned a value from the .txt files at that point. When I manually run mystepper6.py from the command line it runs perfectly.
I have spent waaay too many hours on this problem and have purchased two e-books to no avail. Please help.
import RPi.GPIO as gpio # import library RPi.GPIO gpio=use general purpose input output pin names
import time # import time library
PINSh = [27,10,18,23] # variable 'PINS' holds a list of gpio pin numbers
SEQAh = [(27,),(10,),(18,),(23,)]
PINSv = [4,17,22,24] # variable 'PINS' holds a list of gpio pin numbers
SEQAv = [(4,),(17,),(22,),(24,)]
DELAY = 0.01 # time between motor steps (too small of a number then the motor stalls)
alpha = 140 # horizontal full scale viewing angle in motor counts 128 counts = 360 degrees
beta = 30 # was 15 vertical full scale viewing angle in motor counts 128 counts = 360 degrees
gpio.setmode(gpio.BCM) # tells RPi.GPIO we want to use pin names (BCM is the mfg)
for pin in PINSh: # pin is a variable name assigned a new value each loop; PINS is a list
gpio.setup(pin, gpio.OUT) # this says we want to use 'pin' as an output
for pin in PINSv: # pin is a variable name assigned a new value each loop; PINS is a list
gpio.setup(pin, gpio.OUT)
def stepper(sequence, pins): # def says 'stepper' is the function name (like a variable), then parameters are inside ()
for step in sequence:
for pin in pins:
if pin in step:
gpio.output(pin, gpio.HIGH)
else:
gpio.output(pin, gpio.LOW)
webcam_horz_home = open("horz.txt", "a")
webcam_horz_home.close()
webcam_vert_home = open("vert.txt", "a")
webcam_vert_home.close()
# load last position prior to power down
webcam_horz_home = open("horz.txt", "r")
rows = webcam_horz_home.readlines();
for row in rows:
adjusth = int(row)
webcam_horz_home.close()
webcam_vert_home = open("vert.txt", "r")
rows = webcam_vert_home.readlines();
for row in rows:
adjustv = int(row)
webcam_vert_home.close()
counter = 0 # move to home position
while counter < adjustv:
stepper(SEQAv, PINSv)
counter = counter + 1
# CONTINUAL PAN AND TILT OPERATION (box pattern):
I just tested this on my Pi running Raspbian and it worked.
First, I created a python script called some_script.py in the primary user's home directory.
Script contents:
import sys
import time
with open("/home/username/some_script.py.out", "w") as f:
f.write(str(time.time()) + " " + "some_script.py RAN!\n")
Then, in the terminal, I set the executable bit on the file which allows it be executed:
sudo chmod +x some_script.py
Then, also in the terminal, I typed sudo crontab -e and added the following line at the bottom of the root user's crontab:
#reboot sleep 2; /usr/bin/python /home/username/some_script.py
I then rebooted, cded to /home/username/ and confirmed that python had run at reboot and written to a file:
cat some_script.py.out
1458062009.53 some_script.py RAN!
UPDATE / SOLUTION
After confirming that the OP was able to successfully replicate the steps above, I was fairly confident that this was not an issue stemming from varying implementations of cron on different *nix systems or some other edge case. As expected, he could run python via cron, he could use the #reboot feature and he could write to disk without any sort of permission issues.
However, it still didn't work. What did solve the issue was simply to use absolute paths rather than relative paths.
Changing
webcam_horz_home = open("horz.txt", "a")
to
webcam_horz_home = open("/home/pi/horz.txt", "a")
and
webcam_vert_home = open("vert.txt", "a")
to
webcam_vert_home = open("/home/pi/vert.txt", "a")
got OP's steppers purring again :)
EXPLANATION / BACKGROUND
When executing scripts or commands via the crontab of other users (in this case root), paths relative to the regular user's home directory (eg. ~/.bashrc) will no longer be valid or will point to a different file with the same filename if it exists. The same "issue" is sometimes seen when people run servers that call scripting languages such as PHP (often executed by the www-data user).
On a Raspberry Pi, these things can cause a bit of a catch-22 when working with GPIOs because the GPIO device is locked down and not accessible to unprivileged users without a change of permissions and groups.
If OP ran his script as root by adding the cron entry via sudo crontab -e, he would have access to the GPIO device (since root has access to almost everything). However, the relative paths in his python script that implicitly reference the home folder of the non-privileged user pi would no longer be valid (since home now means the folder /root which is the home folder of the root user).
If OP ran his scripts via the non-privileged pi user's crontab by adding the cron entries via crontab -e (without sudo), the paths would be valid (home or ~/ would now mean /home/pi/) but then he wouldn't have access to the GPIO device since pi is pretty unprivileged. Note: the #reboot feature is not available in all cron implementations (some embedded and stripped down *nix distros don't have it) and often it doesn't work for users other than root.
This means that OP had two options (there might be more; i'm no Linux guru):
place the files vert.txt and horz.txt in the home folder of the root user.
simply change the paths specified in the python script and keep running the script #reboot in root's crontab.
No. 2 is probably better since it keeps the home folder of root empty and keeps OP's files in pi's home folder. root should generally not be messed with unless there's no other options such as using sudo.

How to read text from an application window using pywinauto

I have a python code which opens a SSH session using Putty and passes a command to reboot a remote machine using pywinauto.
I want to read the text from the putty terminal after typing the password and compare it
Is there a way I can do it?
Below is the piece of code for the same
app_Putty = application.Application()
app_Putty.start_("C:\Users\debajyoti.bose\Downloads\putty.exe")
app_Putty.top_window_().TypeKeys(IP)
app_Putty.top_window_().TypeKeys("{TAB}"+"22")
app_Putty.top_window_().RadioButton4.Click()
app_Putty.top_window_().OpenButton.Click()
time.sleep(10)
app_Putty.top_window_().NoButton.Click()
time.sleep(2)
app_Putty.top_window_().TypeKeys(user+"{ENTER}")
time.sleep(3)
app_Putty.top_window_().TypeKeys(password+"{ENTER}")
time.sleep(3)
app_Putty.top_window_().TypeKeys("/bin/reboot"+"{ENTER}")
time.sleep(5)
app_Putty.kill_()
time.sleep(120)
I am using pywinauto v0.4.0
Thanks in advance.
OK, let's try app_Putty.top_window_().WindowText(). If it fails your mission looks impossible.
You can't capture directly like this from what I can tell, but I had to find a workaround, and the one I found was this
#clear the buffer with alt space menu
app.window(title='PuTTY - Title').type_keys('% l',with_spaces=True)
#copy the buffer to clipboard
app.window(title='PuTTY - Title').type_keys('% o',with_spaces=True)
I was having to do this because the putty.log file was missing the selection indicator icon (asterisk) on the screen when it was logging output and I needed a way to know which item was selected to move up or down.

Weird Behavior in Windows XP with Python snippet

I wrote a snippet that would automatically copy a file from a source directory to a path on an usb. Because drive letter names are assigned by the PC independent o the slot I figured I would GetLogicalDrives() and if the path to the usb directory is in any of those drives then it would copy (I hope I'm making some sense). Here is the piece of code I wrote in Python:
import itertools, ctypes, string, sys, os.path, shutil
def drive_list():
drive_bitmask = ctypes.cdll.kernel32.GetLogicalDrives()
drive_list = list(itertools.compress(string.ascii_uppercase,
map(lambda x:ord(x) - ord('0'), bin(drive_bitmask)[:1:-1])))
return drive_list
for drive in drive_list():
path = drive + ":\\targer_directory\target_file.ext"
if drive not in ["C", "D", "E"]:
if os.path.exists(path) == True:
shutil.copy2(r'C:\source_directory\source_file.ext', path)
Whenever I run this script I get a bunch of error messages saying:
"Exception Processing Message c0000013 Parameters 75b1bf7c 4 75b1bf7c 75b1bf7c"
I think this probably means that I have some "ghost drives" in my pc. Any help in bypassing this behavior is deeply appreciated.
Note: The code runs at the end and the copy job is done succesfuly, but not until the error messages are cleared which is not the objective if I want to perform automatic backups.
I'm not sure whether this will help or not. But you can try this!
We were receiving the same error on execution of a windows application (an .exe file) and the below steps resolved it.
Goto Registry Editor
(Run -> type 'regedit' -> hit enter)
Expand HKEY_LOCAL_MACHINE
Expand System
Expand CurrentControlSet
Expand Control
Select Windows
Double click on ErrorMode in the right side pane
Set the Value Data as 2
Click OK
Restart your system