Term!nX Posted August 23, 2007 Share Posted August 23, 2007 (edited) Hi there, for education purposes I rewrite my au3 macrobots for Guild Wars into C++ (further step is memory support). Actual no problem, but the simulated keystrokes do not activate Hotkeys. What I mean by this..: I simulate the press of 8 ingame. But it does not give the desired effect, namely to use skill 8. The funny thing is, that the 8 is written correctly in the ingame-chat and textdocuments. So the Guild Wars surface gets the 8 but does not trigger the Hotkey. First I tried the keybd_event function, as it did not work I tried SendInput. Here are the functions: void sendakey(int mykey) { /* YOU HAVE TO COPY #define _WIN32_WINNT 0x0501 #include <windows.h> into the header. It is important that you first write the #define stuff before you include windows.h I write this because I needed the help of a very kind person. Would have never found out on my own :) */ INPUT input[2]; memset(input, 0, sizeof(input)); input[0].type = INPUT_KEYBOARD; input[0].ki.wVk = mykey; input[0].ki.dwFlags = 0; input[0].ki.time = 0; input[0].ki.dwExtraInfo = 0; input[1].ki.wVk = mykey; input[1].ki.dwFlags = KEYEVENTF_KEYUP; input[1].ki.time = 0; input[1].ki.dwExtraInfo = 0; SendInput(2,input,sizeof(INPUT)); } 2nd keybd_event: void sendkey(int key) { keybd_event(key, 0, 0, 0); keybd_event(key, 0, KEYEVENTF_KEYUP, 0); } In both cases I tried to set the Windows digitally in the foreground: game_hwnd = FindWindow(NULL, "Guild Wars"); ShowWindow(game_hwnd, SW_RESTORE); SetForegroundWindow(game_hwnd); SetFocus(game_hwnd); Okay, my question: How does au3 simulate keystrokes? Why does the au3 Send("string") function work? I hope these aren't deep secrets greeting PS: I am NOT a C++ geek, so please take that into consideration Edited August 23, 2007 by Term!nX Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 23, 2007 Share Posted August 23, 2007 I believe that AutoIt connects itself to the process or thread to allow it to post keystrokes more accurately. Link to comment Share on other sites More sharing options...
Term!nX Posted August 23, 2007 Author Share Posted August 23, 2007 (edited) I tried this, either: HWND targetHWND=0; DWORD thisThread,otherThread; targetHWND=FindWindowA(NULL,"Guild Wars"); if(targetHWND==0) {MessageBoxA(0,"Not Found","Error",0);} //ThreadId thisThread=GetCurrentThreadId(); otherThread=GetWindowThreadProcessId(targetHWND,NULL); //Attach if(!AttachThreadInput(thisThread,otherThread,true)) { MessageBoxA(0,"Miss","not successful",0); } Desperated Edited August 23, 2007 by Term!nX Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 23, 2007 Share Posted August 23, 2007 I don't know anything about attachments to other threads. I'm afraid you will have to wait for someone with a little more background. Link to comment Share on other sites More sharing options...
piccaso Posted August 24, 2007 Share Posted August 24, 2007 how about AutoItX ? CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
Term!nX Posted August 24, 2007 Author Share Posted August 24, 2007 (edited) how about AutoItX ?Shall I post in this Forum? Dont know what you mean by this, but I wont use a different language since I want to educate myself in C++. Therefore I really need to get a solution for this problem Hm, do you think the Send("") function is included in the official SourceCode files? Then I could look up how the creators of au3 simulated a keystroke.So, I looked up the sendkeys.cpp sourcecode file and found the specified function. But however, I am not skilled enough to understand this function 100%. Is the WinAttach()-function a userdefined function or is it included in one of the headerfiles, e.g. the WinAPI? Edited August 24, 2007 by Term!nX Link to comment Share on other sites More sharing options...
piccaso Posted August 24, 2007 Share Posted August 24, 2007 You can use autoitx from c/c++ too but if you want to do it the hard way you have to study sendkeys.cpp closer. and for WinAttach() and your education: come on, read the class definition if your looking at Send(), scroll down ~2 pages. After Send() comes SendRaw() and then WinAttach() CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
Term!nX Posted August 24, 2007 Author Share Posted August 24, 2007 atm im rly drunk but i tink i can get the sense of your post.. i MUST code in c++.. it is not important to me to bot money in GW, I just want to educate myself in Cp++. I want to study C++ this is the most important goal. everything else is suvimportant Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 25, 2007 Share Posted August 25, 2007 AutoItX is a dll you can link to with your C++ application. Piccaso's idea is the easiest. The dll is part of the installation of AutoIt. Link to comment Share on other sites More sharing options...
Term!nX Posted September 2, 2007 Author Share Posted September 2, 2007 No other way? so that im completely seperated from autoit? There is an option "hardware check" in the keybd_event function. Useful for my problem? Link to comment Share on other sites More sharing options...
blahblahblah5038 Posted September 3, 2007 Share Posted September 3, 2007 any questions about whether stuff is a user defined function or not can be found on the msdn library from microsoft.here's the one for sendhttp://msdn2.microsoft.com/en-us/library/s...dkeys.send.aspx Noteworthy works:Fast Pixel SearchSigned: WG Link to comment Share on other sites More sharing options...
Administrators Jon Posted September 3, 2007 Administrators Share Posted September 3, 2007 You need to send the scan codes as well as the VK code for it to work in most games. Deployment Blog:Â https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming:Â https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Term!nX Posted September 7, 2007 Author Share Posted September 7, 2007 I tried this. I used VK_RETURN and 0x0D .. not working for GW. Nevermind, after a week of testing without a result, I decided to use autoitx. Thanks anyway Link to comment Share on other sites More sharing options...
Term!nX Posted September 8, 2007 Author Share Posted September 8, 2007 Okay some researches gave the result, that GW blocks Inputs sent by windows. It only accepts inputs directly from the device driver. Therefore I have to write a program which sends the inputs to the driver, not to the process Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 9, 2007 Share Posted September 9, 2007 How do you send something to a driver? If you can figure out how to do that, share it with us, because I'd quite like to learn that. Link to comment Share on other sites More sharing options...
jvanegmond Posted September 11, 2007 Share Posted September 11, 2007 How do you send something to a driver? If you can figure out how to do that, share it with us, because I'd quite like to learn that.Same here. Although, I think that even although all drivers are different the most of them do not allow this.. Perhaps this could be done in a hackish kind of way, but not by going through the default routes. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Term!nX Posted September 13, 2007 Author Share Posted September 13, 2007 I dont know how to.. But I am really interested how autoit sends the keystrokes. Because autoit emulated keystrokes work for gw. Can I figure the technique out by reading through the sourcecode? Link to comment Share on other sites More sharing options...
jvanegmond Posted September 13, 2007 Share Posted September 13, 2007 I dont know how to..But I am really interested how autoit sends the keystrokes. Because autoit emulated keystrokes work for gw. Can I figure the technique out by reading through the sourcecode?There's only way to find out. I say, yes. github.com/jvanegmond Link to comment Share on other sites More sharing options...
voidvoid Posted January 5, 2012 Share Posted January 5, 2012 hey man i think the problem is in this line SendInput(2,input,sizeof(INPUT));because u r not sending 8 you are sending everything that is INPUT and that includes type and whatever the structure holds Link to comment Share on other sites More sharing options...
Valik Posted January 5, 2012 Share Posted January 5, 2012 You just fucked a four year old corpse. How does that make you feel? Beege 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now