Im trying to get the mouse to perform a drag and drop using only the api. I can get the mouse to move around and perform clicks for me but the challenge is the drag and drop operation. im trying to store the previous state of the mouse (*ie when it was pressed down*) and then while the previous state==mousedown start dragging and holding it down, until i get a left mouse up message. but i cant get it to work correctly. here is the code im using Input[] input = new Input[ 1 ]; input[0].type = INPUT.MOUSE; input[0].mi.dx = x2; input[0].mi.dy = y2; //input[0].mi.dwFlags = MOUSEEVENTF.MOVE| MOUSEEVENTF.ABSOLUTE ; if(prev.wParam==UserActivityHook.WM_LBUTTONDOWN) { input[0].mi.dwFlags =MOUSEEVENTF.LEFTDOWN| MOUSEEVENTF.ABSOLUTE; SendInput( ( UInt32 ) input.Length, input, Marshal.SizeOf( input[ 0 ]) ); Console.WriteLine("test"); } input[0].mi.dwFlags = MOUSEEVENTF.MOVE| MOUSEEVENTF.ABSOLUTE ; SendInput( ( UInt32 ) input.Length, input, Marshal.SizeOf( input[ 0 ] ) ); Any ideas? i have been looking around online and will continue to. Thanks alot for your help
jtmtv18
Posts
-
making the mouse perform a Drag-Drop with api -
problem calling a P/InvokeIm trying to call the function ChildWindowFromPoint but it seems that it always asumes the Parent window is in the Upperleft hand corner, meaning even if the parent form is in the lower right it wont find the child control until i click around in the area in the upper left hand corner. Its all a little hard to describe here but in anycase ill include the code on how im calling the function. Im using global mouse cords, with the upper left of the screen being 0,0. [DllImport("User32")] public static extern IntPtr ChildWindowFromPoint(int handle, int x,int y ); int chihan = (int)Form1.ChildWindowFromPoint(handle,e.X,e.Y); //show if it found a pointer MessageBox.Show(chihan.ToString()); //try to display the window text of the child control StringBuilder s = new StringBuilder(1024); Form1.GetWindowText(chihan,s,1024); MessageBox.Show(s.ToString()); I dont know what im doing wrong, i can find the parent control without a problem, reguardless of where it is located on the screen, and im using the same cords as i use in the function above, Thanks alot for your time ~Jesse
-
finding a textbox handleim trying to write a simple app that will find the handle to a textbox of my choice so i can have it type in text for me (ie, im trying to make a app to enter a password at a login screen on my game). any ideas on how i can do this? im lost here on where to begin. Is it possible to find the textbox at a certain mouse cord? Its been a while since i have done any programming, but its slowly coming back to me. Thanks alot for your time everyone, ~jesse The Code Project Is Your Friend...
-
Drawing windows Form over DirectD appi currently have that version installed on my comp..i noticed that it seems to be d3d controls? im using direct draw and i think the best way to just show buttons and options is to pop open a standard windows form and work from that. in any case i looked through the directx documents and they seems to be lack luster to say the least. Jesse The Code Project Is Your Friend...
-
Drawing windows Form over DirectD appAny ideas to the question above? i can make the form appear but there are a few problems to note. 1. The mouse does not draw on the form that appears on top of the app. 2. you cannot move the form around or else the backround will 'brake up' The app is full screen (non-exclusive although i would like it to work with exclusive). How do i have to setup my direct draw drawing methods to work when this form i being draw? the code im using to make the form is just a test code basicly this: Form f = new Form(); f.ShowDialog(); Thanks alot for your time.
-
Socket problemEnglish is my first language actually even if it is cryptic at times.And,Dont worry about the issue, i fixed it myself. The Code Project Is Your Friend...
-
Serializethrow in some of your code you used to save the serialized arraylist. i have my serialize class wrote with this code.. among others. this will fill the memorystream and return its byte[] MemoryStream memstr = new MemoryStream(); BinaryFormatter formatter =new BinaryFormatter(); formatter.Serialize(memstr,MyObjectHere); return memstr.ToArray(); to save it i call this. Stream fs= File.Create(path); byte[] tmp = \*(The Byte Array From Above here)*\ memstr.ToArray(); fs.Write(tmp,0,tmp.Length); //the serialized object is wrote now. to open it stream= File.Open(path,FileMode.Open); // BinaryFormatter bf = new BinaryFormatter(); Object =(CastingObjectHere)bf.Deserialize(stream); hope this helps, if not. someone older and wiser will help u =) The Code Project Is Your Friend...
-
Socket problemcan someone help me with this little problem. Im trying to send a few bytes at a time over the connected network. I call socket.BeginSend() to send it async-ly. the problem is when i send my data the server is recieving to much or two little information. im positive the server is working find and im pretty sure the problem lies in the IAsyncResult method called by socket.BeginSend(). Here ill include as little code as possible (since theres alot to make this work) //i read the data here, i only want to send the ammount that //i read of by, sybolized by the variable(read) while((read=st.Read(by,0,by.Length))!= 0) { StateObject ss = new StateObject(s); ss.buffer = by; ss.Available=read; //send by,offset 0 so it reads from begining //followed by only read length incase we are //near the end of the file. s.BeginSend(by,0,read,SocketFlags.None,new AsyncCallback(sen.MainSent),ss); //Thread.Sleep(1); by = new byte[12]; Application.DoEvents(); } //now for the AsyncCallback MainSent public void MainSent(IAsyncResult e) { try { StateObject j = (StateObject)e.AsyncState; int i = j.socket.EndSend(e); if(i>0) { //if i isnt zero there is still data left to be sent. //here is the problem, how do i tell it to only send //the remaining bytes of j.buffer j.socket.BeginSend(j.buffer,i,j.buffer.Length-i,0,new AsyncCallback(MainSent),j); }catch{} } thnx for your time, i hope i can find help so i can just move on from this stupid issue. p.s: the MainSent callback was wrote with the fact in mind that i would send a entire files bytes at once. but now its wrote to only send pieces at a time (in this case 12kb at a time) ~jesse The Code Project Is Your Friend...
-
design question.is there a already established class or dll that would do the job ? i have noticed that the packets do send out of order sometimes. The Code Project Is Your Friend...
-
design question.im trying to write a effective file sharing program. The program should brake down a file into pieces (byte[]) and send them over the network to the client. The client should then return a recipt or something, letting the sender know that he just recieved the byte[] then repeat. in the event the client never sends a recipt, the sender will then resend the previous byte[]. What im asking is, what is a efficient way and effective way of doing this. obviously hashcodes would need to be employed to ensure the client has recieved the correct data. any ideas/code examples on how to do this would be much appreciated. as it stands now i wrote a dll that automaticly deserializes (spelling),compresses,encrypts and sends it. the recieved does the oposite and then sends the newly formed object back. is there a easyier way of doing this? thnx, jesse The Code Project Is Your Friend...
-
splitting stream datathank you very much for your time. your anwser fixed the problem with only 2 small mods. Thank you very much. Jesse The Code Project Is Your Friend...
-
splitting stream datahi im just looking for a simple way to split the data of a file say 7600kb long (or any length) into x amount of 1000kb pieces. The problem im having is toward the end of the file 1000kb will not divide into 7600kb evenly. aggh another complicated problem with a easy solution that i obviously dont know the anwser to. Jesse
-
Remoting QuestionIs there anyway for me to update a client app about how fast the download is going, how far along it is, using .Net remoting. I know when i used sockets, i could detect how large the file wise and divide by the currently downloaded bytes *to get the current download percent* is there a way to do this in Remoting, since the bytes and underlying information is *seemingly* hidden. Thanks you. Jesse The Code Project Is Your Friend...
-
.Net Remoting IssueThanks alot. I figured it out from what you said. Very helpfull thanks. Jesse The Code Project Is Your Friend...
-
.Net Remoting IssueI got everything working fine in my .net remoting proggy. My question is, i want to make a single instance of my obj that my server can put data in and then hand it out to the clients. I dont know how to create a instance of the object from within my server, after it is already registered as a wellknowntype. i tryed using the code from my client to init a instance of the object but it just tells me that "the http something is already in use" i.e this code wont work on the server who registered the object.
ChannelServices.RegisterChannel( new HttpChannel() ); IRemoteObj obj = (IRemoteObj) Activator.GetObject( typeof(IRemoteObj), "http://localhost:8085/ObjURI" );
Thanks for your time. Jesse The Code Project Is Your Friend... -
capturing keydown eventsI havent done any programming in a few months now, and as such i kinda forgot alot of this stuff... i used to know the anwser to this question *i wrote a program using it before* but alas, i forgot. Anyways what i need is to have my program running in the background without focus and beable to detect when i press a combo of buttons on my computer, and have it regain focus agian. Its simple i know, but i just pretty much forgot how to do alot of programming, anyways thanks for your help guys. Do i have to catch api calls, if so can you kindly provide any of them or ways of finding them, im looking now for them but i think there has to be a easyier way, a managed .Net way. anyways thanks for your time. The Code Project Is Your Friend...
-
socket listening errorI found the problem. I was using this program called steganos internet anonm sounded intresting...makes your browser essentially hidden...but it must of be acting as a firewall also...blocking the framework form listening...my firewall was off...but even when it wasnt it said the my program was listening, so steganos must of be running between the too. Anyways thanks sooo much for your help i really apreciate it. Jesse M. The Code Project Is Your Friend...
-
socket listening errori think it might be something my firewall because i cant even get a response out of this line of code serverSock.BeginAccept(new AsyncCallback(MiniWebServer.OnAcceptConnection),serverSock); it locks the program up every single time. i also noticed something strange...i like to seed my Random class with the current time..so i pass in this Random rn = new Random((int)DateTime.Now.Ticks); but every time i ran the code line above it would throw a stack overflow exception. I also tryed uninstalling / disabling the firewall and it didnt seem to do anything.Should i try reinstalling the framework or something ? any ideas ? The Code Project Is Your Friend...
-
socket listening erroryeah i do....here is the method i use. try running the code in junction with this and see if it works... private void MainListenerBeginAccept(IAsyncResult e) { try { //MessageBox.Show("Acception connection"); Socket main = (Socket)e.AsyncState; Socket secondary = main.EndAccept(e); if(secondary!=null) { StateObject tr = new StateObject(); //MessageBox.Show(secondary.Available.ToString()+" ava"); tr.buffer = new byte[bufferSize]; tr.MainSocket = main; tr.socket = secondary; // //Console.WriteLine("Beging To Accept"); // SocketsConnected.Add(secondary); // //secondary.BeginReceive(tr.buffer,0,tr.buffer.Length,SocketFlags.None,new AsyncCallback(PendingConnectionReveive),tr); } MainListener.BeginAccept(new AsyncCallback(MainListenerBeginAccept),MainListener); } catch(System.ObjectDisposedException){} catch(Exception ex) { OnError(this,ex); } } The Code Project Is Your Friend...
-
socket listening errori had wrote a set of class's for sending serialized objects over the net using sockets not to long ago..it worked perfectly then. I wrote a few programs (chat/file sharing) using the classes and they also worked perfectly. Just tonight i went back to use it agian with some new idea's and i have noticed i cant get my sockets to listen all of a sudden. i traced the error down to when the socket calls BeginAccept (the listening socket which is already done doing the setup to be in the listening state). I dont know if this is a code problem because i know for sure i havent touched the code when i used it, i just used the compiled dll's.I tryed uninstalling my old fire wall to see if thats the problem *zone alarm* but it didnt seem to fix it. The sending portion seems to work but the error only lies when i try to call begin accept intialy, This happens so when a connection does come in it is ready to accept it.here is the code with the error.
IPEndPoint ipe = new IPEndPoint(GetMachineIPAddress(),39888); MainListener= new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); MainListener.Bind(ipe); MainListener.Listen(300); Thread.Sleep(10); //code excutes fine until the line below. which locks the thread indefinitly. MainListener.BeginAccept(new AsyncCallback(MainListenerBeginAccept),MainListener);
if anyone wants to see the full code i would send it...its large and uses compression/serializing/encryption/ect/bla bla bla. thanks alot for your help with this. Jesse M The Code Project Is Your Friend...