Change Scaling via C# - c#

So we have this client using tssharp to connect to a remote computer via RDP. The client needs the scaling set to 125% for some reason. This makes the RDP-Session unusable, because tsplus takes the scaling from the system. So I want to habe a skript that switches the scaling from 125%->100%, then starts a .exe and then change the scaling back.
So here I am. My approach was to change the registry via C#. Personally I don't use Windows, so my knowledge is very basic. I can change the registry with my code. It works beautifully. I don't get the registry to reload though. I've tried to broadcast the update, but literally nothing was affected. Then I tried to kill and restart the desktopenvironment (i.e. Windows Explorer). The restart worked, but it didn't care about the new registry. Then I tried power something from microsoft, to automate the clicks. And that piece of s...oftware is absolutely unusable for that. So I'm out of ideas now... How can I make clicks in the Windowssystemsettings with c#? Is there any kind of library or something like this? I've tried the system32 api. Didn't work. Or do you have another idea on how to approach the problem? Like I said I pretty much know nothing about windows, so any idea is welcome. I literally just want to automate 8 clicks and I'm not able to do that.

Related

Is there an alternative for the SendKeys class that will work with Windows 10

I cannot find any definitive information anywhere but the System.Windows.Forms.SendKeys class appears to have been blocked / disabled / depreciated in Windows 10.
I wrote a demo program that monitors the users keystrokes and if a user enters a known code it will pop up a form and then go off to a document database and return various strings (company names / addresses / contact lists etc) and replace the typed code with the retrieved string. SendWait is used to send the retrieved strings to whatever program typed the code.
I built the program on the companies Windows 7 desktops but when I ran it on my personal Windows 10 system it didn't work. A lot of reading later and I feel like a complete idiot but I cant let them take this project any further knowing that they wont be on Win7 forever.
So my question is has this sort of functionality definitely been disabled in Windows 10 or is there another way or method I would be able to use to achieve this behavior of inserting text into running programs.
Any help appreciated.
I found this Forum-Thread:
https://www.tenforums.com/software-apps/49635-sendkeys-not-working-windows-10-a.html
SendKeys is Blocked in W10. In W8.1 it still works.
There are other anoying things, like not allowing App to Read or Wright to Drive C. The "file" is there but W10 "hides" it or simply not allowing to access it.
There are Netwok problems also, not allowing App to work on LAN environement.
Well, my opinion is that W10 behaves like Malware to user PC. Useless.
They had no solution.
It looks as if Sendkeys works with some apps and not others. I can automate an older app by sending it keystrokes but newer apps like Chrome don't respond. The inconsistent behavior has seriously messed up scripts that worked fine under Win 7.
I have not found any official documentation that says that Sendkeys has been deprecated so the inconsistency looks to be a Windows 10 bug.

2 dev computers, 1 C# solution using TFS?

I work on a team using TFS to manage a C# project. I have 2 development computers, a high end desktop and a laptop.
Ok, the TFS server is located many states away. The other developers are around the globe. I work out of my house. I really didn't think I needed to include this when I said "I am on a team"... Guess I was wrong. I also have no ability to make any changes to the TFS Server and no one outside of my office will change anything anywhere to help me do this.
I work on both. When I switch from one to the other, I have to remember to copy the files (which I often forget or don't have time to do).
I thought I could put the source files on OneDrive/DropBox and edit them there. It worked fine for one computer, but the other said:
"The solution appears to be under source control, but its binding information cannot be found. Because it is not possible to recover this missing information automatically, the projects whose bindings are missing will be treated as not under source control."
Any idea how I might fix this (doesn't anyone have ideas on this???) - or other ways I might solve this?
I just like the idea of working on my desktop, but being able to grab my laptop and run when I have to.
Links to existing answers are appreciated, but I couldn't figure out what to search on that addressed this (although I am sure it has been asked before.)
Thanks!
Trying to use a share for your local workspace is going to be something that runs into little quirks all along the way.
I would recommend using the Shelve feature. You would Shelve from one computer, then unshelve from the other. It basically takes your chosen changes and moves them onto the server such that you then can unshelve them onto the other computer. It is a way to save your changes to the server without checking them into the project. You have your own shelvesets that don't effect the main branch.
Alternative : Use Git
TFS : Map your project which is in TFS into any folder on your local. And check it in when you develop. And in other computer, press Get Latest button by clicking right click of your mouse to solution.
EDIT:
If you want to use TFS, go TFS Express without download or setup.
Why you need to copy the files instead of just use TFS checked in and get latest version?
This will guaranty you have the latest version of code on both machine without problem.
Please also checked in your projects and solution files into TFS, and you don't miss anything.
If you think it will affect others, you can have your own branch to working on.
The solution I have so far (not ideal, but works) is to use OneDrive (or DropBox - I just use OneDrive since it has more storage). On the laptop, I downloaded the entire project. All the TFS flags are set for the laptop, but the desktop can see them just as well. I can code on the desktop, and as long as I hit "save all" before I leave, I can race out the door with my laptop and work remotely, with all the current code.
The drawbacks of this approach are:
1) When I open the project on the desktop - it complains since all the TFS references are for the laptop. But only when I open it.
2) I have to use the laptop to get current and push changed files. Not a big deal.
3) I can't really work on both the laptop and the desktop at the same time - but don't really care since I don't need to and that wasn't the goal anyway.
The benefits:
1) I don't have to remember to copy from one location to another, check for changed files, etc.
2) As long as I have my laptop, I can work. No need to check in code, shelve code, or play any other silly games in order to keep them in sync.
3) I can race out last minute and always know I have all the code in whatever state it was in.
In the long run, I would still like a slightly better solution. I am guessing that I could tell OneDrive not to sync the TFS folders/files on each machine and then that would eliminate the message I get when I start on the desktop, but at this time, it's not worth the effort to figure out how to do this (although, if you know, feel free to comment.) But overall, I am now quite happy.
Fletcher
Since I always have my laptop when at the desktop, but the opposite is not true, this works for me.

SystemSounds.Beep.Play not making any sound

I am having trouble with System.SystemSounds.Beep.Play() not making any sound for a particular user. It seems to be working for everyone else (a fairly large user base with generally 24/7 use) but simply does not make any sound for a particular user.
What I would like to know is if this method has any particular idiosyncrasies that I should be aware of, particularly if they could cause this issue (but really even if they couldn't too)? Has anyone else run into something like this that might point to this being a non-programming issue?
Some extra info that might help: (or might be more confusing)
It does not appear to be a corrupt .NET install because it appears for a particular user across machines.
The user is using the same Active Directory profile for all these machines when they have the issue
Another user can log into the machine and use the exact same executables to get sound successfully
The particular location where the user is has Windows XP machines, though not all users do (some use Windows 7)
You may want to check this link:
http://www.howtogeek.com/howto/windows/turn-off-the-annoying-windows-xp-system-beeps/
make sure that the beep sound is not disabled for the user.
Are the system beeps still on his computer? check C:\Windows\Media, because Beep.Play(); should work fine.
Some other possible problems just to be sure:
The speaker volume isn't at 0%?
The speakers are installed correctly?
Check Windows Control Panel - Sound
Sound event reference must to be set.
For example:
default beep -> Windows Background.wav

Trick Windows To See Second Monitor

is there anyway to trick windows into thinking that a second monitor is connected to the computer, even if there isnt one?
Example:
Laptop also has an external screen connected into it. The external screen is the primary screen.
When the screen is disconnected the laptop becomes primary even if the external screen is reconnected. Is there a way to trick windows into thinking that the monitor is always there? and not revert to the laptop screen as primary screen?
The way I am thinking it could work is some kind of low level driver? But I wouldnt have a clue where to start
For work, I actually had the same situation -- on an embedded PC, we needed a second monitor to always be available.
I put a considerable amount of time into researching it, but I wasn't able to find any solution other than with hardware.
If you have a VGA port (or DVI-I), you're in luck. You can find directions on how to fake that with a couple resistors (here's one set of directions).
Ultimately, for my project, we only had a DVI-D port available. I had to come up with a microcontroller solution to send "fake" monitor signals (via I2C) to the PC. I can't go into much more specific detail than that, unfortunately.

How to turn off particular monitor with .NET?

OK, I know there are quite a few posts on this topic. However, none of them provide the solution to my issue: I don't want just to turn off my monitor(s), I wish my code to turn off a specific monitor. The URL the most people refer to, http://fci-h.blogspot.com/2007/03/turn-off-your-monitor-via-code-c.html, doesn't help here, as it turns off all the displays.
So, I have my laptop screen and an additional external monitor. While I'm watching movies, I switch the display to the external monitor and my laptop screen goes black, however, it's still on and glowing in the dark. I wish to turn it off. Could anyone help please?
EDIT: Is there any way to acomplish this, meaning it needn't have to be written in .Net. Basically, I just need an .exe file that's able to turn the particular monitor off and on alternately.
It looks like there's no good way of turning off a specific monitor, but it is possible to set your laptop's backlight to minimum brightness. Depending on which version of Windows you have, there are different ways to do it:
send IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS I/O control as described here: http://msdn.microsoft.com/en-us/magazine/dvdarchive/cc163415.aspx
use WMI method WmiSetBrightness as described here: What API call would I use to change brightness of laptop (.NET)?
use Win API SetMonitorBrightness, but I don't know of anybody who has done it in C#.

Categories