windows7 Visial studio Community2017のC++/CLIでボタンを押すとマウスを特定の位置に動かして、クリックするというGUIを作っているのですが、mouse_eventを呼び出せません。
mouse_eventというものがWinUser.hに定義されていると思うのですが、なぜでしょうか。
<MyForm1.h>
#pragma once #include <iostream> #include <math.h> #include <windows.h> #include <string> #include <ctime> #include <WinUser.h> namespace Project1 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace std; using namespace System::Runtime::InteropServices; /// <summary> /// MyForm の概要 /// </summary> public ref class MyForm : public System::Windows::Forms::Form { public: MyForm(void) { InitializeComponent(); // //TODO: ここにコンストラクター コードを追加します // } protected: /// <summary> /// 使用中のリソースをすべてクリーンアップします。 /// </summary> ~MyForm() { if (components) { delete components; } } protected: private: System::Windows::Forms::Button^ button1; private: System::ComponentModel::IContainer^ components; private: System::Windows::Forms::Button^ button2; private: /// <summary> /// 必要なデザイナー変数です。 /// </summary> #pragma region Windows Form Designer generated code /// <s ummary> /// デザイナー サポートに必要なメソッドです。このメソッドの内容を /// コード エディターで変更しないでください。 /// </summary> void InitializeComponent(void) { this->components = (gcnew System::ComponentModel::Container()); // // button2 // this->button2->Location = System::Drawing::Point(41, 205); this->button2->Name = L"button2"; this->button2->Size = System::Drawing::Size(57, 23); this->button2->TabIndex = 12; this->button2->Text = L"button2"; this->button2->UseVisualStyleBackColor = true; this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click); // // MyForm // this->AutoScaleDimensions = System::Drawing::SizeF(6, 12); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(588, 489); this->Controls->Add(this->button2); this->Controls->Add(this->button1); this->Name = L"MyForm"; this->Text = L"MyForm"; this->Click += gcnew System::EventHandler(this, &MyForm::button2_Click); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { lclick(100, 100); } void lclick(int x, int y) { SetCursorPos(x, y); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } }; }
以下のようなエラーが出ます。
エラー LNK2028 未解決のトークン (0A000532) "extern "C" void __cdecl mouse_event(unsigned long,unsigned long,unsigned long,unsigned long,unsigned __int64)" (?mouse_event@@$$J0YAXKKKK_K@Z) が関数 "private: void __clrcall Project1::MyForm::lclick(int,int)" (?lclick@MyForm@Project1@@$$FAE$AAMXHH@Z) で参照されました。 Project1 C:\Users\diagnosis\source\repos\Project1\Project1\MyForm1.obj 1 エラー LNK2028 未解決のトークン (0A0005C0) "extern "C" int __cdecl SetCursorPos(int,int)" (?SetCursorPos@@$$J0YAHHH@Z) が関数 "private: void __clrcall Project1::MyForm::lclick(int,int)" (?lclick@MyForm@Project1@@$$FAE$AAMXHH@Z) で参照されました。 Project1 C:\Users\diagnosis\source\repos\Project1\Project1\MyForm1.obj 1 エラー LNK2019 未解決の外部シンボル "extern "C" int __cdecl SetCursorPos(int,int)" (?SetCursorPos@@$$J0YAHHH@Z) が関数 "private: void __clrcall Project1::MyForm::lclick(int,int)" (?lclick@MyForm@Project1@@$$FAE$AAMXHH@Z) で参照されました。 Project1 C:\Users\diagnosis\source\repos\Project1\Project1\MyForm1.obj 1
プロパティでリンカーの設定などもしているのですが、うまくいきません、、
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/01/19 14:12