Which programming language?

Hello, I want to build a GUI application that can be used to optimize my PC. For example, there's a widget that lets you set the power saving mode to maximum performance. So what do I actually need: a GUI and efficient access to the system, such as regediting, so I can basically optimize the entire system. Maybe even a BIOS without a password.

(2 votes)
Loading...

Similar Posts

Subscribe
Notify of
10 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Erzesel
1 year ago

Actually, the programming language used does not play a big role, so you have access to a Framwork that provides GUI functionality.

Under .Net is usually Form.

In C# a simple demo would look like this:

Demo.cs

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;

public class Form1 : Form {
Β  Β  private Button Button1;Β Β 
Β  Β  private Label Display1;

Β  Β  Β  //Native FunktionΒ  zum setzen der aktiven Powershemas
Β  Β  [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
Β  Β  static extern UInt32 PowerSetActiveScheme(IntPtr RootPowerKey,Guid SchemeGuid);


Β  Β  private Guid HeighProfile = Guid.Parse("8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c");


Β  Β  public Form1() {
Β  Β  Β  Β  this.Size = new Size(600,140);


Β  Β  Β  Β  Display1 = new Label();
Β  Β  Β  Β  Display1.Text = "Irgendein Text";
Β  Β  Β  Β  Display1.Location = new Point(10, 20);
Β  Β  Β  Β  Display1.AutoSize = true;
Β  Β  Β  Β  this.Controls.Add(Display1);
Β  Β  Β  Β Β 
Β  Β  Β  Β  Button1 = new Button();
Β  Β  Β  Β  Button1.Text = "Setze HΓΆchstleistung";
Β  Β  Β  Β  Button1.Location = new Point(10, 40);
Β  Β  Β  Β  Button1.AutoSize = true;
Β  Β  Β  Β  Button1.Click += new System.EventHandler(Button1_Click);
Β  Β  Β  Β  this.Controls.Add(Button1);
Β  Β  }

Β  Β  private void Button1_Click(object sender, EventArgs e){Β 
Β  Β  Β  Β  Display1.Text = "JetzΒ  sollteΒ  HΓΆchstleitun aktivΒ  sein";
Β  Β  Β  Β  PowerSetActiveScheme(IntPtr.Zero,HeighProfile);
Β  Β  }
Β  Β Β 
Β  Β  static void Main() {
Β  Β  Β  Β Β 
Β  Β  Β  Β  Β  Β  Application.EnableVisualStyles();
Β  Β  Β  Β  Β  Β  Application.Run(new Form1());
Β  Β  }
}

the same thing in Powershell:

demo.ps1

Β #console ausblenden
$user32=Add-Type -m '[DllImport("user32.dll")] public static extern void ShowWindow(IntPtr hWnd, int nCmdShow);' -Name myAPI -passthru
$hwnd=(gps -id $PID).MainWindowHandle
$user32::ShowWindow($hwnd, 0)


Add-Type -AssemblyName System.Windows.Forms

$Form = New-Object System.Windows.Forms.Form
$Form.Text = 'Irgendwas'
$Form.Size = '600,140'

$Display1 = New-Object System.Windows.Forms.Label
$Display1.Location = '10,10'
$Display1.TextΒ  Β = 'Irgendein Text'
$Display1.AutoSize = $True;
$Form.Controls.Add($Display1)

$Button1 = New-Object System.Windows.Forms.Button
$Button1.Location = '10,40'
$Button1.Text = 'Setze Hoechstleistung'
$Button1.AutoSize = $True

$Button1_Action={
Β  Β  $Button1.Enabled = $False
Β  Β  $Display1.Text = "JetzΒ  sollteΒ  Hoechstleitung aktivΒ  sein"
Β  Β  Β  #da es kein Problem ist Powershell von Consol-BefehlenΒ  gebrauch zuΒ  machen, einfach den bequemstenΒ  WegΒ  nutzen
Β  Β  powercfg /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635cΒ  Β #setzeΒ  HΓΆchstleistung
}
$Button1.Add_Click( $Button1_Action )
$Form.Controls.Add($Button1)

$Null=$Form.ShowDialog()

On a Windows computer it is of course easiest to program small projects with C# or Powershell.

Theoretically you don’t even need Visual Studio a simple compiler “csc.exe” located on any Windows system.

Here is a small batch with which you can compile small C# programs with .Net-Framework 4.8:

compile.cmd

@echo off
chcp 65001 >nul
if "%~1"=="" (
Β  Β  echo C# Compiler-Batch.
Β  Β  echo:
Β  Β  echo Ziehe eine Datei mit C#-Source auf "%~nx0" ...
Β  Β  timeout 7
Β  Β  exit /b
)
for /f "tokens=* delims=" %%v in ('dir /b /s /a:-dΒ  /o:-n "%SystemRoot%\Microsoft.NET\*csc.exe"') do (
set "csc=%%v"
)
if "%csc%"==""Β  (
Β  Β  echo Kein C#-Compiler gefunden
Β  Β  echo Bitte installiere Microsoft-.NetFramework!
Β  Β  pause
exit /b
) else (
Β  Β  echo "%csc%" gefunden.
)


set "WPF_Path=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\WPF"
set "WPF_Speech=/reference:%WPF_Path%\system.speech.dll"
set "WPF_Media=/reference:%WPF_Path%\PresentationCore.dll"
set "WPF_WindowBase=/reference:%WPF_Path%\WindowsBase.dll"
set "Platform=/platform:anycpu"


set "Switches=/nologo %Platform% %WPF_Speech% %WPF_Media% %WPF_WindowBase%"
rem teste ob es sich um eine Windowsformsaplikation handeln kΓΆnnte
for /f "tokens=*" %%a in ('type "%~f1" ^|findstr /irc:"usingΒ  *System\.Windows\.Forms *;" /c:"staticΒ  *....*Β  *Main *(.*)" /c:"Application.Run *(.*)"') do @(
Β  set /a "IsWinApp+=1"
Β  echo %%a |find /i "Main">nul &&(set "IsApp=1")
)


if "%IsWinApp%" == "3" (call :AskCompileWinApp)
if "%IsApp%" neq "1" (goto :NoApp)


set "inputFile=%~f1"
set "outputFile=%~dpn1.exe"
call:compileΒ  %Switches%Β  -out:"%outputFile%" "%inputFile%" && (
Β  Β  echo Hat geklappt...
Β  Β  echo ...." %~dpn1.exe"...
Β  Β  echo Ausgabe Deines Programms:
Β  Β  cd /d "%~dp1"
Β  Β  echo:
Β  Β  "%~dpn1.exe"
Β  Β  echo:
) || (
Β  Β  echo Compilererror...
Β  Β  echo:
Β  Β  type compile.log
Β  Β  echo:
)
pause
exit /b
::::::::: subroutines
:compileΒ 
"%csc%" %* >compile.log
exit /b


:AskCompileWinApp
echo:
echo possible WindowsApplication
echo Compile as WindowsGUIApp without Console?
choice /c yn /t 1 /d yΒ 
if %errorlevel% equ 1 (set Switches=%Switches% /target:winexe)
exit /b
:NoApp
echo Maybe an Library?
echo Doing nothingΒ  jet!
pause

simply drag a .cs file to the batch…

tide1109
1 year ago

My personal favorite for GUI applications is floodter.

There is a flooded package with access to the Win32Api, which could probably go a lot.

You can also execute C code in Dart (Programming language by Flutter. That’s how you would have C for the functionality and flooders for the GUI.

What is exactly possible will also depend on what is changed in Windows at all. With C or C++, the chances could be best.

Native Windows widgets should not be possible with Flutter. You would have a window from the program.

The setting of the maximum power mode would have to with work. It is part of the Win32 API and will be available in Dart, C, C++, C# and probably other languages.

SusgUY446
1 year ago

C or cpp?

SusgUY446
1 year ago
Reply to  Tino17487

Python is not slow when you have new hardware

SusgUY446
1 year ago

I don’t know what the difference between the two is

Anonym13592
1 year ago

C/PP?

Anonym13592
1 year ago
Reply to  Tino17487

I find CPP cooler πŸ˜€