SalehSouqi Posted October 24, 2011 Posted October 24, 2011 (edited) Hi im trying to make a Dll in C++ , and i only know the basics in C++ , so its kind of hard the dll im trying to make is taken from a program source code i downloaded , here it is expandcollapse popup#include "resource.h" #include "windows.h" #include "windowsx.h" #define IDT_TIMER1 10001 #define IDT_TIMER2 10002 #define IDT_TIMER3 10003 #define IDT_TIMER4 10004 #define IDT_TIMER5 10005 #define IDT_TIMER6 10006 #define IDT_TIMER7 10007 #define IDT_TIMER8 10008 #define IDT_TIMER9 10009 #define IDT_TIMER10 10010 LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); DWORD ShowGui(HINSTANCE hInstance); DWORD WINAPI SkillThread(LPVOID lpParam); DWORD WINAPI Hotkeys(LPVOID lpParam); void savesettings(); void loadsettings(); void SendBuffKey(WPARAM VK); HWND hWnd; bool run = false; bool hidden = false; HANDLE skill_thread; DWORD _PMA; void hide() { char read_name[50]; GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT2), read_name, 50); HWND sro = FindWindowA("Notepad", read_name); if(hidden == false) { ShowWindow(sro, SW_HIDE); hidden = true; } else if(hidden == true) { ShowWindow(sro, SW_SHOW); hidden = false; } } void timer(UINT idEdit, UINT idTimer) { char read_delay[50]; GetWindowTextA(GetDlgItem(hWnd, idEdit), read_delay, 50); DWORD i = atoi(read_delay) * 1000; SetTimer(hWnd, idTimer, i, (TIMERPROC)NULL); } void start() { if(run == false) { skill_thread = CreateThread(0, 0, SkillThread, 0, 0, 0); timer(IDC_EDIT1, IDT_TIMER1); timer(IDC_EDIT3, IDT_TIMER2); timer(IDC_EDIT4, IDT_TIMER3); timer(IDC_EDIT5, IDT_TIMER4); timer(IDC_EDIT6, IDT_TIMER5); timer(IDC_EDIT7, IDT_TIMER6); timer(IDC_EDIT8, IDT_TIMER7); timer(IDC_EDIT9, IDT_TIMER8); timer(IDC_EDIT10, IDT_TIMER9); timer(IDC_EDIT11, IDT_TIMER10); run = true; } } void stop() { run = false; TerminateThread(skill_thread, 0); KillTimer(hWnd, IDT_TIMER1); KillTimer(hWnd, IDT_TIMER2); KillTimer(hWnd, IDT_TIMER3); KillTimer(hWnd, IDT_TIMER4); KillTimer(hWnd, IDT_TIMER5); KillTimer(hWnd, IDT_TIMER6); KillTimer(hWnd, IDT_TIMER7); KillTimer(hWnd, IDT_TIMER8); KillTimer(hWnd, IDT_TIMER9); KillTimer(hWnd, IDT_TIMER10); } __declspec(naked) BOOL WINAPI _PostMessageA(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { __asm { mov edi, edi push ebp mov ebp, esp jmp dword ptr ds:[_PMA] } } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { _PMA = (DWORD)GetProcAddress(LoadLibraryA("user32.dll"), "PostMessageA") + 5; CreateThread(0, 0, Hotkeys, 0, 0, 0); ShowGui(hInstance); return 0; } LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { switch(Msg) { case WM_TIMER: switch (wParam) { case IDT_TIMER1: if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK11)) == BST_CHECKED) SendBuffKey(0x31); KillTimer(hWnd, IDT_TIMER1); timer(IDC_EDIT1, IDT_TIMER1); return true; case IDT_TIMER2: if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK12)) == BST_CHECKED) SendBuffKey(0x32); KillTimer(hWnd, IDT_TIMER2); timer(IDC_EDIT3, IDT_TIMER2); return true; case IDT_TIMER3: if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK13)) == BST_CHECKED) SendBuffKey(0x33); KillTimer(hWnd, IDT_TIMER3); timer(IDC_EDIT4, IDT_TIMER3); return true; case IDT_TIMER4: if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK14)) == BST_CHECKED) SendBuffKey(0x34); KillTimer(hWnd, IDT_TIMER4); timer(IDC_EDIT5, IDT_TIMER4); return true; case IDT_TIMER5: if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK15)) == BST_CHECKED) SendBuffKey(0x35); KillTimer(hWnd, IDT_TIMER5); timer(IDC_EDIT6, IDT_TIMER5); return true; case IDT_TIMER6: if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK16)) == BST_CHECKED) SendBuffKey(0x36); KillTimer(hWnd, IDT_TIMER6); timer(IDC_EDIT7, IDT_TIMER6); return true; case IDT_TIMER7: if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK17)) == BST_CHECKED) SendBuffKey(0x37); KillTimer(hWnd, IDT_TIMER7); timer(IDC_EDIT8, IDT_TIMER7); return true; case IDT_TIMER8: if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK18)) == BST_CHECKED) SendBuffKey(0x38); KillTimer(hWnd, IDT_TIMER8); timer(IDC_EDIT9, IDT_TIMER8); return true; case IDT_TIMER9: if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK19)) == BST_CHECKED) SendBuffKey(0x39); KillTimer(hWnd, IDT_TIMER9); timer(IDC_EDIT10, IDT_TIMER9); return true; case IDT_TIMER10: if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK20)) == BST_CHECKED) SendBuffKey(0x30); KillTimer(hWnd, IDT_TIMER10); timer(IDC_EDIT11, IDT_TIMER10); return true; } case WM_INITDIALOG: return TRUE; case WM_COMMAND: switch(wParam) { case IDC_BUTTON1: start(); return true; case IDC_BUTTON2: stop(); return true; case IDC_BUTTON3: loadsettings(); return true; case IDC_BUTTON4: savesettings(); return true; case IDC_BUTTON5: hide(); return true; case IDCANCEL: exit(1); } break; } return 0; } DWORD ShowGui(HINSTANCE hInstance) { MSG msg; hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)DlgProc); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT1), "180"); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT3), "190"); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT4), "200"); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT5), "210"); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT6), "220"); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT7), "230"); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT8), "240"); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT9), "250"); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT10), "260"); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT11), "270"); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT12), "9"); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT13), "0"); ShowWindow(hWnd, SW_SHOW); while(GetMessage(&msg, hWnd, 0, 0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } return true; } void SendKey(HWND hWnd, WPARAM VK) { HWND hWnd2 = FindWindowExA(hWnd, 0, "Edit", 0); _PostMessageA(hWnd2, WM_KEYDOWN, 0x32, 0); Sleep(50); } void SendBuffKey(WPARAM VK) { char read_name[50]; GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT2), read_name, 50); HWND sro = FindWindowA("Notepad", read_name); TerminateThread(skill_thread, 0); SendKey(sro, VK_F2); Sleep(2000); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK22)) == BST_CHECKED) { char buffer[50]; GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT12), buffer, 50); SendKey(sro, VkKeyScanA(buffer[0])); Sleep(2000); } SendKey(sro, VK); Sleep(2000); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK22)) == BST_CHECKED) { Sleep(2000); char buffer[50]; GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT13), buffer, 50); SendKey(sro, VkKeyScanA(buffer[0])); Sleep(1000); } SendKey(sro, VK_F1); skill_thread = CreateThread(0, 0, SkillThread, 0, 0, 0); } DWORD WINAPI SkillThread(LPVOID lpParam) { while(1) { char read_name[50]; GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT2), read_name, 50); HWND sro = FindWindowA("Notepad", read_name); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK1)) == BST_CHECKED) SendKey(sro, 0x31); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK2)) == BST_CHECKED) SendKey(sro, 0x32); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK3)) == BST_CHECKED) SendKey(sro, 0x33); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK4)) == BST_CHECKED) SendKey(sro, 0x34); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK5)) == BST_CHECKED) SendKey(sro, 0x35); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK6)) == BST_CHECKED) SendKey(sro, 0x36); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK7)) == BST_CHECKED) SendKey(sro, 0x37); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK8)) == BST_CHECKED) SendKey(sro, 0x38); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK9)) == BST_CHECKED) SendKey(sro, 0x39); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK10)) == BST_CHECKED) SendKey(sro, 0x30); if(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK21)) == BST_CHECKED) { SendKey(sro, 0x47); SendKey(sro, 0x47); SendKey(sro, 0x47); SendKey(sro, 0x47); } Sleep(10); } } DWORD WINAPI Hotkeys(LPVOID lpParam) { while(1) { if(GetAsyncKeyState(VK_F5)) { start(); } else if(GetAsyncKeyState(VK_F6)) { stop(); } Sleep(10); } } void savesettings() { char read_name[50]; GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT2), read_name, 50); char inipath[MAX_PATH]; GetCurrentDirectoryA(sizeof(inipath), inipath); strcat_s(inipath, "\\keypresser.ini"); char buffer[50]; WritePrivateProfileStringA(read_name, "1", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK1)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "2", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK2)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "3", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK3)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "4", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK4)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "5", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK5)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "6", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK6)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "7", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK7)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "8", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK8)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "9", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK9)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "10", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK10)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "11", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK11)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "12", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK12)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "13", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK13)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "14", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK14)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "15", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK15)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "16", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK16)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "17", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK17)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "18", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK18)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "19", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK19)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "20", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK20)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "21", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK21)), buffer, 50), inipath); WritePrivateProfileStringA(read_name, "22", _itoa(Button_GetCheck(GetDlgItem(hWnd, IDC_CHECK22)), buffer, 50), inipath); char read_recast[50]; GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT1), read_recast, 50); WritePrivateProfileStringA(read_name, "recast1", read_recast, inipath); GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT3), read_recast, 50); WritePrivateProfileStringA(read_name, "recast2", read_recast, inipath); GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT4), read_recast, 50); WritePrivateProfileStringA(read_name, "recast3", read_recast, inipath); GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT5), read_recast, 50); WritePrivateProfileStringA(read_name, "recast4", read_recast, inipath); GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT6), read_recast, 50); WritePrivateProfileStringA(read_name, "recast5", read_recast, inipath); GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT7), read_recast, 50); WritePrivateProfileStringA(read_name, "recast6", read_recast, inipath); GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT8), read_recast, 50); WritePrivateProfileStringA(read_name, "recast7", read_recast, inipath); GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT9), read_recast, 50); WritePrivateProfileStringA(read_name, "recast8", read_recast, inipath); GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT10), read_recast, 50); WritePrivateProfileStringA(read_name, "recast9", read_recast, inipath); GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT11), read_recast, 50); WritePrivateProfileStringA(read_name, "recast10", read_recast, inipath); GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT12), read_recast, 50); WritePrivateProfileStringA(read_name, "2nd", read_recast, inipath); GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT13), read_recast, 50); WritePrivateProfileStringA(read_name, "1st", read_recast, inipath); } void loadsettings() { char read_name[50]; GetWindowTextA(GetDlgItem(hWnd, IDC_EDIT2), read_name, 50); char inipath[MAX_PATH]; GetCurrentDirectoryA(sizeof(inipath), inipath); strcat_s(inipath, "\\keypresser.ini"); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK1), GetPrivateProfileIntA(read_name, "1", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK2), GetPrivateProfileIntA(read_name, "2", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK3), GetPrivateProfileIntA(read_name, "3", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK4), GetPrivateProfileIntA(read_name, "4", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK5), GetPrivateProfileIntA(read_name, "5", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK6), GetPrivateProfileIntA(read_name, "6", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK7), GetPrivateProfileIntA(read_name, "7", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK8), GetPrivateProfileIntA(read_name, "8", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK9), GetPrivateProfileIntA(read_name, "9", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK10), GetPrivateProfileIntA(read_name, "10", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK11), GetPrivateProfileIntA(read_name, "11", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK12), GetPrivateProfileIntA(read_name, "12", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK13), GetPrivateProfileIntA(read_name, "13", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK14), GetPrivateProfileIntA(read_name, "14", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK15), GetPrivateProfileIntA(read_name, "15", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK16), GetPrivateProfileIntA(read_name, "16", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK17), GetPrivateProfileIntA(read_name, "17", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK18), GetPrivateProfileIntA(read_name, "18", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK19), GetPrivateProfileIntA(read_name, "19", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK20), GetPrivateProfileIntA(read_name, "20", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK21), GetPrivateProfileIntA(read_name, "21", 0, inipath)); Button_SetCheck(GetDlgItem(hWnd, IDC_CHECK22), GetPrivateProfileIntA(read_name, "22", 0, inipath)); char read_recast[50]; GetPrivateProfileStringA(read_name, "recast1", "180", read_recast, 50, inipath); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT1), read_recast); GetPrivateProfileStringA(read_name, "recast2", "180", read_recast, 50, inipath); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT3), read_recast); GetPrivateProfileStringA(read_name, "recast3", "180", read_recast, 50, inipath); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT4), read_recast); GetPrivateProfileStringA(read_name, "recast4", "180", read_recast, 50, inipath); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT5), read_recast); GetPrivateProfileStringA(read_name, "recast5", "180", read_recast, 50, inipath); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT6), read_recast); GetPrivateProfileStringA(read_name, "recast6", "180", read_recast, 50, inipath); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT7), read_recast); GetPrivateProfileStringA(read_name, "recast7", "180", read_recast, 50, inipath); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT8), read_recast); GetPrivateProfileStringA(read_name, "recast8", "180", read_recast, 50, inipath); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT9), read_recast); GetPrivateProfileStringA(read_name, "recast9", "180", read_recast, 50, inipath); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT10), read_recast); GetPrivateProfileStringA(read_name, "recast10", "180", read_recast, 50, inipath); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT11), read_recast); GetPrivateProfileStringA(read_name, "2nd", "9", read_recast, 50, inipath); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT12), read_recast); GetPrivateProfileStringA(read_name, "1st", "0", read_recast, 50, inipath); SetWindowTextA(GetDlgItem(hWnd, IDC_EDIT13), read_recast); } i want to make a dll with SendKey function so heres my source code SendFunc.cpp #include "stdafx.h" #include <windows.h> extern "C" __declspec(dllexport) int __cdecl SendKey(WPARAM VK); DWORD _PMA = (DWORD)GetProcAddress(LoadLibraryA("user32.dll"), "PostMessageA") + 5; __declspec(naked) BOOL WINAPI _PostMessageA(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { __asm { mov edi, edi push ebp mov ebp, esp jmp dword ptr ds:[_PMA] } } __declspec(dllexport) int __cdecl SendKey(WPARAM VK) { HWND hWnd = FindWindowA("Notepad", "Untitled - Notepad"); HWND hWnd2 = FindWindowExA(hWnd, 0, "Edit", 0); _PostMessageA(hWnd2, WM_KEYDOWN, VK, 0); return 0; } DllTest2.def LIBRARY DllTest2 EXPORTS SendKey @1 and i want to call it using AutoIT $Test = DllCall("DllTest2.dll","int","SendKey","int","0x31") If @error Then MsgBox(0,"",@error) but AutoIT crashs everytime =\ Edited October 24, 2011 by SalehSouqi
SalehSouqi Posted October 24, 2011 Author Posted October 24, 2011 oh , nvm , it works this way$Test = DllCall("DllTest2.dll","int:cdecl","SendKey","int","0x31")
Shaggi Posted October 24, 2011 Posted October 24, 2011 (edited) lol who uses inline asm code for winapi calls, are you patching something? If not, please change this: __declspec(dllexport) int __cdecl SendKey(WPARAM VK) { HWND hWnd = FindWindowA("Notepad", "Untitled - Notepad"); HWND hWnd2 = FindWindowExA(hWnd, 0, "Edit", 0); _PostMessageA(hWnd2, WM_KEYDOWN, VK, 0); return 0; }To this:__declspec(dllexport) int __cdecl SendKey(WPARAM VK) { HWND hWnd = FindWindowA("Notepad", "Untitled - Notepad"); HWND hWnd2 = FindWindowExA(hWnd, 0, "Edit", 0); PostMessageA(hWnd2, WM_KEYDOWN, VK, 0); return 0; } I do not understand why you want to write a dll for this, you can do it directly in autoit? Also, your exported function is declared as _cdecl, so in return type you need to write "int:cdecl". Also, int != wparam, this breaks on x64 compatibily, and also you're passing a string as an argument for an integer... Lastly, are you sure you are running this in x86 version of autoit? Edited October 24, 2011 by Shaggi Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG
SalehSouqi Posted October 24, 2011 Author Posted October 24, 2011 lol who uses inline asm code for winapi calls, are you patching something? If not, please change this: __declspec(dllexport) int __cdecl SendKey(WPARAM VK) { HWND hWnd = FindWindowA("Notepad", "Untitled - Notepad"); HWND hWnd2 = FindWindowExA(hWnd, 0, "Edit", 0); _PostMessageA(hWnd2, WM_KEYDOWN, VK, 0); return 0; }To this:__declspec(dllexport) int __cdecl SendKey(WPARAM VK) { HWND hWnd = FindWindowA("Notepad", "Untitled - Notepad"); HWND hWnd2 = FindWindowExA(hWnd, 0, "Edit", 0); PostMessageA(hWnd2, WM_KEYDOWN, VK, 0); return 0; } I do not understand why you want to write a dll for this, you can do it directly in autoit? Also, your exported function is declared as _cdecl, so in return type you need to write "int:cdecl". Also, int != wparam, this breaks on x64 compatibily, and also you're passing a string as an argument for an integer... Lastly, are you sure you are running this in x86 version of autoit? im not really good in c++ ( im sure you can tell ) but i want to send keys to a program that gameguard is protecting , gg blocks blocks autoit send func ( also mousemove and mouseclick ) according to this , int = wparam , and about the string passing , i realized that but forgot to edit it and maybe im having a problem reading the code you told me to replace , because both of them are identical , and yes its x86
Developers Jos Posted October 24, 2011 Developers Posted October 24, 2011 but i want to send keys to a program that gameguard is protecting , gg blocks blocks autoit send func ( also mousemove and mouseclick )Did you read the forum rules? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts