I'm trying to make a bot that uses OCR and I'm having issues trying to get a hotkey library I found to work.
It uses the ModifierKeys enum as an argument in one of it's functions but apparently 'ModifierKeys doesn't exist'.
I am using System.Windows.Input which should have ModifierKeys in it and I have double checked that I have System.Windows referenced in my project (although that should be pretty obvious since I get no error to do with using System.Windows.Input, I guess)
Here's my current code (error is happening at var key):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using mrousavy;
using System.Windows.Input;
using OCRBot.Handlers;
namespace OCRBot
{
class Program
{
static OCRHandler oCRHandler = new OCRHandler();
static void Main(string[] args)
{
Console.Write("!!");
#if DEBUG
Console.WriteLine("\nPress enter to close...");
Console.ReadLine();
#endif
var key = new HotKey(
(ModifierKeys.Control | ModifierKeys.Alt),
Key.S,
this,
delegate {
MessageBox.Show("Ctrl + Alt + S was pressed!");
}
);
while (true)
{
MainLoop();
}
}
static void MainLoop()
{
oCRHandler.ReadWindow();
}
}
}
The Reference you want is WindowsBase to get ModifierKeys, not System.Windows.
Related
Problem Summary
I have two projects (Console Application and Settings Console). I want "Console Application" to access "Settings Console's" Settings.settings file and use that data in the program.
What I've Done
I've already set the Settings.Settings Access Modifier to "Public", and Have set the Scope of each setting to "User"
Settings Console Output:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Diagnostics;
namespace Settings_Console
{
class Program
{
static void Main(string[] args)
{
//Show Stored Settings
Console.WriteLine(Properties.Settings.Default.Name + "" + Properties.Settings.Default.Number);
String name, number;
name = Console.ReadLine();
number = Console.ReadLine();
Properties.Settings.Default.Name = name;
Properties.Settings.Default.Number = number;
Properties.Settings.Default.Save();
//Show Settings Changed into
Console.WriteLine(Properites.Settings.Default.Name + "" + Properties.Settings.Default.Number);
}
}
}
Settings Console Output:
Amanda 9568675309
Sergio
9568254235
Sergio 9568254235
Press any key to continue . . .
Console Application Project:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System_Console;
namespace Console_Application
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Settings_Console.Properties.Settings.Default.Name + "" + Settings_Console.Properties.Settings.Default.Number);
}
}
}
Console Application Output:
Press any key to continue . . .
i am currently deploying matlab over .net i have included my matlab project dll and mwarray.dll of matlab run-time compiler successfully but when i tried in using component data i have 2 errors one is:
name space missing using MathWorks.MATLAB.NET.ComponentData;
second one is:
cannot convert type void MathWorks.MATLAB.NET.Arrays.Mwcellarray in
line cellout = (MWCellArray)obj.braille();
complete code is as mentioned below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CsharpMatlab;
using MathWorks.MATLAB.NET.Arrays;
using MathWorks.MATLAB.NET.Utility;
using MathWorks.MATLAB.NET.ComponentData;
namespace MATCsharp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Code For Matlab to C#");
MWCellArray cellout = null;
CsharpMatlab.CellExampleApp obj = new CsharpMatlab.CellExampleApp();
cellout = (MWCellArray)obj.braille();
MWNumericArray item1 = (MWNumericArray)cellout[1];
MWNumericArray item2 = (MWNumericArray)cellout[2];
MWCharArray item3 = (MWCharArray)cellout[3];
Console.WriteLine("item1 is {0}", item1);
Console.WriteLine("item2 is {0}", item2);
Console.WriteLine("item3 is {0}", item3);
Console.ReadLine();
}emphasized text
}
}
I'm trying to understand how the Swi-cs-pl library works by doing my own little program, but I cannot printout any result from a query based on the example from SWI-Prolog web.
I have this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SbsSW.SwiPlCs;
namespace HolaMundo
{
class Program
{
static void Main(string[] args)
{
if (!PlEngine.IsInitialized)
{
String[] param = { "-q" }; // suppressing informational and banner messages
PlEngine.Initialize(param);
PlQuery.PlCall("assert(father(hader, nevar))");
PlQuery.PlCall("assert(father(hader, sergio))");
PlQuery.PlCall("assert(brother(nevar, sergio):- father(hader, nevar), father(hader, sergio))");
//How do I write out in a Console the answer for a query like:
// brother(nevar, sergio)
PlEngine.PlCleanup();
}
}
}
}
As I said on my code, I just want to query something basic like: brother(nevar, sergio). and get any answer from Console like true or whatever.
Can anyone help me?
I'm new to code and most things work, but I can't get this code to run. Can someone help?
I tried using System.Forms but it showed as missing a namespace. When I used using System.Windows.Forms that message went away. It does not let me use both.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
StreamReader sr = new StreamReader(#"file.csv");
// for set encoding
// StreamReader sr = new StreamReader(#"file.csv", Encoding.GetEncoding(1250));
string strline = "";
String[] _values = null;
int x = 0;
while(!sr.EndOfStream)
{
strline = sr.ReadLine();
_values = strline.Split(',');
if (_values.Length >= 6 && _values[0].Trim().Length > 0)
{
MessageBox.show(_values[1]);
}
}
sr.Close();
}
}
}
There is no such namespace System.Forms, the class you were trying to use (MessageBox) is in System.Windows.Forms. By correcting your using statement, the error went away.
Remember, you must have a reference to System.Windows.Forms.dll in your console app to use this class.
You need to reference System.Windows.Forms.dll in your project. Here is a detailed instruction how to do that.
There is no such namespace as System.Forms there is only a namespace called System.Windows.Forms, wich has the MessageBox class you are talking about. To be able to use it, you need to add a reference to the System.Windows.Forms.dll to to your project (find it in the .NET Tab in the "Add Reference ..." dialog) and it will work. Also note that MessageBox.Show() requires a capital 'S'. Please see below an optimized and fully working version of your code.
using System.IO;
using System.Windows.Forms;
namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
using (StreamReader sr = new StreamReader(#"file.csv"))
{
while (sr.Peek() >= 0)
{
string strline = sr.ReadLine();
string[] values = strline.Split(',');
if (values.Length >= 6 && values[0].Trim().Length > 0)
{
MessageBox.Show(values[1]);
}
}
}
}
}
}
You try use it in Console application first you should add System.Windows.Forms dll in your references (from .Net reference tab) then use it by adding it's namespace.
I'm a bit confused here. there is no namespace called System.Forms. It's always System.Windows.Forms. And the MessageBox class is defined in System.Windows.Forms
You need to manually ADD a reference to your project for System.Windows.Forms as you are on a console application and not a Windows Application. Just add the reference.
How can I add a C# object to JavaScript code?
using System;
using System.Collections.Generic;
using System.Text;
using System.CodeDom.Compiler;
using System.Reflection;
using Microsoft.JScript;
using Microsoft.JScript.Vsa;
using Microsoft.Vsa;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Program program = new Program();
program.Run();
}
public object Run()
{
VsaEngine Engine = VsaEngine.CreateEngine();
object Result = null;
try
{
//Engine.PushScriptObject(new ScriptObject());
// C# object replace with ?
Result = Eval.JScriptEvaluate("var a = 1; var b = c# object", Engine);
}
catch (Exception ex)
{
return ex.Message;
}
return Result;
}
}
}
Just compile your C# object into an assembly and load that assembly in your jscript code. all the languages that .NET supports can load each other's assemblies.
You can take a look at Script#
As they say,
"Script# brings the power and productivity of C# and .NET tools to Ajax development by compiling C# source code into regular JavaScript."