jjj93421
MemberAbout jjj93421
jjj93421's Achievements
0
Reputation
-
Automatiing mouse clicks
jjj93421 replied to jjj93421's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
To get that SendInput .cpp file to compile I had to change the windows.h file to 0x0501 from 0x0400 and also change stdafx.h. Are there any consequences from this later? I'm not a software developer so I wouldn't think that it is important to me. -
Automatiing mouse clicks
jjj93421 replied to jjj93421's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Ok, I got it !!!! But, I have some bad news. This is the final code that works. #include <windows.h> #include <iostream.h> #include <stdlib.h> #include <stdio.h> int main(){ cout<<"hit enter to click button"; cin.get(); cin.get(); SetCursorPos(404, 459); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); return 0; } sorry man. I couldn't ever get SendInput to work. I thought I should tell you in case you ever need to do the same thing. You the man, though. Later. -
Automatiing mouse clicks
jjj93421 replied to jjj93421's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Yes yes, thanks Hearts. It compiles now. But, it isn't working. I'm investigating right now why it isn't. I am testing it on a poker game that I have where the button is at the bottom and it will deal your hand if you click on it and it isn't dealing. I think it may have something to do with bringing the app into the foreground or making it have focus ? -
Automatiing mouse clicks
jjj93421 replied to jjj93421's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
It says XBUTTON1 "undeclared identifier" . ****, well, I guess I'll try to figure it out tomorrow. -
Automatiing mouse clicks
jjj93421 replied to jjj93421's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Crap. It didn't like that. Here is the code now if you need it. It said this: Compiling... mouse 5.cpp C:\Program Files\Microsoft Visual Studio\MyProjects\mouse 5\mouse 5.cpp(11) : warning C4005: 'WINVER' : macro redefinition c:\program files\microsoft visual studio\myprojects\mouse 5\mouse 5.cpp(0) : see previous definition of 'WINVER' C:\Program Files\Microsoft Visual Studio\MyProjects\mouse 5\mouse 5.cpp(49) : error C2143: syntax error : missing ';' before '->' C:\Program Files\Microsoft Visual Studio\MyProjects\mouse 5\mouse 5.cpp(49) : error C2501: 'InpPtr' : missing storage-class or type specifiers C:\Program Files\Microsoft Visual Studio\MyProjects\mouse 5\mouse 5.cpp(49) : error C2040: 'InpPtr' : 'int' differs in levels of indirection from 'struct tagINPUT *' C:\Program Files\Microsoft Visual Studio\MyProjects\mouse 5\mouse 5.cpp(49) : error C2143: syntax error : missing ';' before '->' C:\Program Files\Microsoft Visual Studio\MyProjects\mouse 5\mouse 5.cpp(50) : error C2143: syntax error : missing ';' before '->' C:\Program Files\Microsoft Visual Studio\MyProjects\mouse 5\mouse 5.cpp(50) : error C2501: 'InpPtr' : missing storage-class or type specifiers C:\Program Files\Microsoft Visual Studio\MyProjects\mouse 5\mouse 5.cpp(50) : error C2040: 'InpPtr' : 'int' differs in levels of indirection from 'struct tagINPUT *' C:\Program Files\Microsoft Visual Studio\MyProjects\mouse 5\mouse 5.cpp(50) : error C2143: syntax error : missing ';' before '->' C:\Program Files\Microsoft Visual Studio\MyProjects\mouse 5\mouse 5.cpp(51) : error C2143: syntax error : missing ';' before '->' C:\Program Files\Microsoft Visual Studio\MyProjects\mouse 5\mouse 5.cpp(51) : error C2501: 'InpPtr' : missing storage-class or type specifiers mouse 5.obj - 56 error(s), 1 warning(s) #include <windows.h> #include <iostream.h> #include <stdlib.h> #include <stdio.h> #include <WinUser.h> #include <stdafx.h> #define _WIN32_WINNT 0x0501 #define WINVER 0x0501 int a,b; int xstart=-10; int ystart=-20; char dd; char * pch; HWND hwnd; char texttitle[255]={0}; char word[255]; BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) { GetWindowText(hWnd, texttitle ,sizeof(texttitle)); if(texttitle[0] != 0){ pch=strstr (texttitle,word); if (pch!=NULL){ hwnd=hWnd;}} return TRUE; } INPUT *InpPtr = new INPUT; InpPtr->type = INPUT_MOUSE; InpPtr->mi.dx = 380; InpPtr->mi.dy = 457; InpPtr->mi.mouseData = XBUTTON1; InpPtr->mi.dwFlags = MOUSEEVENTF_LEFTDOWN; InpPtr->mi.time = 0; InpPtr->mi.dwExtraInfo = 0; INPUT *InpPtr2 = new INPUT; InpPtr2->type = INPUT_MOUSE; InpPtr2->mi.dx = 380; InpPtr2->mi.dy = 457; InpPtr2->mi.mouseData = XBUTTON2; InpPtr2->mi.dwFlags = MOUSEEVENTF_LEFTUP; InpPtr2->mi.time = 0; InpPtr2->mi.dwExtraInfo = 0; int main(){ loop201: cout<<"Input a word from window title \n"; cin.getline(word,255); EnumWindows(EnumWindowsProc,0); SetWindowPos( hwnd, HWND_TOP, xstart, ystart, 2, 2, SWP_NOSIZE ); cout<<"Hit enter to automatically use mouse "; cin.get(); cin.get(); SendInput(1,InpPtr,sizeof(INPUT)); SendInput(1,InpPtr2,sizeof(INPUT)); delete InpPtr; return 0; } I also tried an #endif at the end of my code with the previous way but it didn't like that either. -
Compile this please!
jjj93421 replied to XPero's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
The DLL is 240 kb and I can only attach files that are 150 kb and below. Got an e-mail address I can send it to ? -
Compile this please!
jjj93421 replied to XPero's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
I think it worked. Here you go. -
Automatiing mouse clicks
jjj93421 replied to jjj93421's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Ok, figured it out except for the unexpect end of file found. I'm looking and looking and see no missed brackets ? I'm confused here. Evidently, you need this in the file, too #if (_WIN32_WINNT > 0x0400) I found that info on another site. I would not have been able to come up with obviously since I'm new to this stuff. But what's up with the unexpected end of file found. -
Automatiing mouse clicks
jjj93421 replied to jjj93421's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Hey, Hearts, I'm back. I got 3 errors when I tried to compile it. Also, do I need to use MOUSEINPUT , or is that just FYI . Sorry for so many questions. This is what it said: Compiling... mouse click 3.cpp C:\Program Files\Microsoft Visual Studio\MyProjects\mouse click 3\mouse click 3.cpp(65) : error C2146: syntax error : missing ';' before identifier 'test' C:\Program Files\Microsoft Visual Studio\MyProjects\mouse click 3\mouse click 3.cpp(65) : error C2501: 'INPUT' : missing storage-class or type specifiers C:\Program Files\Microsoft Visual Studio\MyProjects\mouse click 3\mouse click 3.cpp(65) : fatal error C1004: unexpected end of file found Error executing cl.exe. mouse click 3.obj - 3 error(s), 0 warning(s) Do I not have an #include that I need ? Here is the code: #include <windows.h> #include <iostream.h> #include <stdlib.h> #include <stdio.h> int a,b; int xstart=-10; int ystart=-20; char dd; char * pch; HWND hwnd; char texttitle[255]={0}; char word[255]; BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) { GetWindowText(hWnd, texttitle ,sizeof(texttitle)); if(texttitle[0] != 0){ pch=strstr (texttitle,word); if (pch!=NULL){ hwnd=hWnd;}} return TRUE; } INPUT test; test.type = INPUT_MOUSE; test.mi.dx = 380; test.mi.dy = 457; test.mi.mouseData = XBUTTON1; test.mi.dwflags = MOUSEEVENTF_LEFTDOWN; test.mi.time = 0; test.mi.dwExtraInfo = 0; INPUT *InpPtr = test; int main(){ loop201: cout<<"Input a word from window title \n"; cin.getline(word,255); EnumWindows(EnumWindowsProc,0); SetWindowPos( hwnd, HWND_TOP, xstart, ystart, 2, 2, SWP_NOSIZE ); cout<<"Hit enter to automatically use mouse "; cin.get(); cin.get(); SendInput(1,InpPtr,sizeof(INPUT)); return 0; } -
Automatiing mouse clicks
jjj93421 replied to jjj93421's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Ok. I got the handle of the button. I got the caption of the button and I have the class of it. I didn't even know these things existed until 5 minutes ago. I used Spy++. Anyone have ideas of where to go from here? Is this what I put into SendInput ? -
Automatiing mouse clicks
jjj93421 replied to jjj93421's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Ok, appreciate the advice Hearts and Simon. What I don't understand is the SendInput function. I don't understand the parameters. Parameters nInputs [in] Specifies the number of structures in the pInputs array. pInputs [in] Pointer to an array of INPUT structures. Each structure represents an event to be inserted into the keyboard or mouse input stream. cbSize [in] Specifies the size, in bytes, of an INPUT structure. If cbSize is not the size of an INPUT structure, the function will fail. ************************ Number of structures in the inputs array ?? Huh ? Pointer to an array of input structures ? What does arrays have to do with this ? Ok the size of it but how do I find these things out ? Please help. The rest looks easy. -
I want to be able to automate a mouse click so that when I start up a program it will click on a button in a window automatically. I already have a handle to this window . I know the x and y coords. Can anyone help a beginning programmer out? I am using win32 and it is a console program. Also, this button won't move and the window is always in the same spot on my desktop, therefore the x and y coords will always be the same if this helps anyone out. I want to do it the easiest way possible. I know how to program with c++ but not that well and my windows programming is sketchy. If someone can get me started, a little experimenting on my part should solve what I need.
-
Thanks for the help Hearts. I finally got it working. It feels good to see your program work. I did a double take when I saw the window move. I'm new to programming as you may have guessed so it feels good when something works especially when it is windows programming. Actually, I'm not sure I would have gotten without your help. thanks. I like setwindowpos better than movewindow.
-
Thanks for the reply. The SWP_NOSIZE should make it ignore the height and width numbers (the 2's). This child window that I am trying to move wasn't created by me. It is an application. Right now, I'm having trouble getting a handle on the child window. The hwnd or whatever. Can you help? Basically, all I need to do is get a handle on the current child window on the screen just below my console program and move it over to the left and up. Thanks.