c怎麼使用PostMessage函式模擬按鍵輸入啊

時間 2021-08-11 17:47:26

1樓:

dllimport("user32.dll")]

static extern bool postmessage(int hwnd, int msg, uint wparam, uint lparam);

引數說明:int hwnd, int msg, uint wparam, uint lparam

第一引數是記事本的視窗控制代碼,這點必須要確認

第二個引數是訊息windows訊息,用wm_char試試,在c#中需要定義wm_char或者直接填wm_char的值0x0102

第三個引數填h的鍵碼

第四個引數是特徵碼

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.runtime.interopservices;

using system.drawing;

namespace tanklibrary

[dllimport("user32.dll", entrypoint = "setwindowpos")]

public static extern int setwindowpos(int hwnd, int hwndinsertafter, int x, int y, int cx, int cy, int wflags);

[dllimport("user32.dll")]

public static extern intptr getwindowrect(intptr hwnd, ref rect rect);

[dllimport("user32.dll")]

public static extern intptr getwindowrect(intptr hwnd, ref rectangle rect);

[dllimport("user32.dll")]

public static extern int32 releasedc(intptr hwnd, intptr hdc);

[dllimport("user32", charset = charset.ansi, setlasterror = true, exactspelling = true)]

public static extern bool setforegroundwindow(intptr hwnd);

[dllimport("user32.dll", entrypoint = "postmessage")]

public static extern intptr postmessage1(intptr hwnd, uint msg, int wparam, int lparam);

[dllimport("user32.dll")]

public static extern bool setcursorpos(int x, int y);

public static void clickon(intptr hwnd, int x, int y)}}

2樓:匿名使用者

int hwnd, int msg, uint wparam, uint lparam

第一引數是記事本的視窗控制代碼,這點必須要確認第二個引數是訊息windows訊息,用wm_char試試,在c#中需要定義wm_char或者直接填wm_char的值0x0102

第三個引數填h的鍵碼

第四個引數是特徵碼

3樓:du瓶邪

比如:[return: marshalas(unmanagedtype.bool)]

[dllimport("user32.dll", setlasterror = true,charset = charset.auto)]

static extern bool postmessage(intptr hwnd, uint msg, intptr wparam, intptr lparam);

4樓:一邊一半

這個還真沒用過。再等等其他童鞋吧。

c 中strcmp函式怎麼使用

韌勁 int strcmp char src,char dst 函式功能 比較兩個字串是否相等。函式解析 這個函式,在vc的庫函式中的定義如下 int cdecl strcmp const char src,const char dst 我們需要留意的是這個函式的迴圈部分,while ret uns...

c中使用bool函式的例子,C 中使用bool函式的例子

等待的幸福快樂 例子 bool 就兩個值,真或者假,通常用來儲存關係表示式或者邏輯表示式的結果。以前是用 int 來表示真假,大 int 有多個值,所以才規定 0 為假,非零為真,導致對應關係比較麻煩,有了 bool 就方便多了,如果把結果賦值給 bool 型別的變數,他會自動轉換,即把0轉換為假,...

如何使用c語言開啟檔案,如何使用c語言開啟一個檔案

實現的方法和詳細的操作步驟如下 1 第一步,開啟軟體,在 的第一行寫標頭檔案,然後在此處寫 include 其中包含要在此標頭檔案中呼叫的函式,見下圖,轉到下面的步驟。2 第二步,完成上述步驟後,在第二行中是主要功能,是程式執行的入口點。int maihn void 可以省略void,見下圖,轉到下...