News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Sending click buttons.

Started by Nilrem, May 05, 2005, 09:15:17 PM

Previous topic - Next topic

Nilrem

Anybody got a solution for my methods? If not can anyone enlighten me on DOM and any current asm programs that utilise it? Greatly appreciated, sorry about the *bump*.

Nilrem

I can't believe I took for granted that my project worked but not on Internet Explorer. However it doesn't work if I set it to click at a position where a program icon is (i.e. selecting it).

Has anyone written code before for this? I just cannot understand what is wrong with my code (I even swapped the values around in hiword and loword just incase they were the wrong way round).


DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL pt:POINTS
mov eax,uMsg
.if eax==WM_INITDIALOG
mov eax, 247 ; put 465 in loword
shl eax, 16     ; shift it into hiword
mov ax, 402  ; now put 273 in loword
mov position, eax ; put resultant value into variable.
.elseif eax==WM_COMMAND
mov eax,wParam
.if (eax==1001) ; GETPOS Button.
mov beenclicked, 1
invoke SetCapture,hWin
.elseif (eax==1002) ; START Button.
invoke SetForegroundWindow, hwndname
invoke SendMessage, hwndname, WM_SYSCOMMAND, SC_RESTORE, 0
invoke SetWindowPos, hwndname, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE
invoke SetCursorPos, 247, 402
invoke Sleep, 500
invoke PostMessage, hwndname, WM_LBUTTONDOWN, MK_LBUTTON, position
invoke Sleep, 500
invoke PostMessage, hwndname, WM_LBUTTONUP, MK_LBUTTON, position
.endif
.elseif (eax==WM_LBUTTONDOWN)
cmp beenclicked,1
jnz @f
invoke Sleep, 500
invoke GetForegroundWindow
mov hwndname, eax
.if (eax==NULL)
invoke MessageBox,NULL,NULL,NULL,MB_OK
.endif
invoke ReleaseCapture
mov beenclicked, 0
@@:
.elseif (eax==WM_RBUTTONDOWN)
cmp beenclicked, 1
jnz @f
invoke GetCursorPos, ADDR click_crd
invoke MessageBox, hWin, ustr$(click_crd.x), ustr$(click_crd.y), MB_OK
mov beenclicked, 1
@@:
.elseif eax==WM_CLOSE
invoke EndDialog,hWin,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret

DlgProc endp

sluggy

You are assuming that the fault is in your code. Remember a while back when i said that this method was buggy and unreliable? All these controls are *rendered* inside IE, that doesn't mean that you can access them at will like you can in regular dialogs.
You should try the method i mentioned earlier  :wink :wink

Nilrem

I meant it doesn't work outside of IE. I tested it in the following way.

Got the location of an icon (a program in an actual window, not a brower window).
Then tried my code on that, I used setcursorpos to make sure the location was right, which it was, however sending the mouse button doesn't select it.
I'm guessing this method doesn't work very well (though I presumed macro programs used a similar approach, trap movements and mouse clicks and repeat them).
So firstly I need to learn (get help with) how to make my code select things (outside of IE and any other browser).
And then I need to find a paper/(s) on DOM, though the only thing I found was a VB DOM parser.

sluggy

Umm, in a standard windows dialog you can't select, or set the focus to, a normal icon. If you can it is because the author has actually hosted the icon inside of a control that does accept focus.
Does this make any sense? Are we talking about the same thing?

Robert Collins

If you are trying to automatically 'simulate' the clicking of the submit button or an image that represents the submit button on an HTML document page then you are trying to do the same thing that I am working on. In my case, I am writing a Window's application that uses the WebBrowser OCX control to load up the HTML document into my application and then after using the OCX to place data in some of the input fields I want my application to then 'send' the data back to the HTML Web server. In my research on this I have found nothing yet to do this by using the OCX but it can be done if you are willing to write the intricate steps using, say for example, Winsock instead of the WebBrowser or Inet OCX controls.

A 'submit' button that is represented by a picture instead of the actual button is usually nothing more that a hyper-link passing the parameters to the Web server usually calling for a CGI program on the server to process the data. The way I did it is first I got all the HTML pages that I needed to correspond to and manually search through them until I found the <a href="url" ........> or the <form action="URL" method="post" .....> tag associated with the picture and then simply copied the link into my application as a string. Then using Winsock I simply make a connection to the Web site and after my connection is confirmed I would send the link information including the paramters back to the server, etc, etc.

To use this approach means you have to have a good understanding of Winsock and also understand the contents of the HTML document. I am almost sure that there exists a better way (some hidden or undocumented feature of the WebBrowser OCX) but this is how I do it and it always works.       

Nilrem

Firstly Sluggy no the icon is not in the dialog, it is in a folder (e.g. C:\windows\desktop\shortcuts\), so I set the shortcuts as the foregroundwindow and then send a mouse click button (wm_lbuttondown) to the locations of the icon (program shortcut) however it doesn't work.

Secondly, wow Robert that sounds very interesting, I'm going to have to find the links and stuff that you mentioned though (it is an image I want to click - hyperlink) but the code is hidden in frames and .jsp
Perhaps you could post some code, or send me a demo of your program? It would be most appreciated.

Didn't know this project was such a huge undertaking hehe. 8-)

Robert Collins

Nilrem

Before I post anything on this subject let me say a few things.

First, this is not hacking. It is simply a method of automating through a program what one would normally do by manually entering data in the required fields then sending that information back to the server by clicking on the submit button. Some companies do not like automation and have in essense stopped it by implementing security pictures that you must copy the text from that picture into a input field before replying back to the server. If this is the case I cannot be of any help since there is no practcal way of automating security pictures.

Second, I have been doing this type of programming for quite some time but I have no idea how to do it in Assembly language since I am a newbee here but have done quite alot of it in Visual Basic. So, anything I do post would be VB examples using Winsock, WebBrowser, and Inet OCXs.

Third, depending on each case the coding can be from a somewhat simple set of functions to an extremely complex set. Each HTML must be examined to see where it lies in the level of coding required to acomplish the task. Many times it turns out that it is too complex and not worth trying to implement the application (this, of course, depends on how strong your desire is to do it).

Fourth, if it turns out that the HTTP protocol is https, a secured socket, then I cannot help you in this matter since that would involve knowing the encryption of the handshaking part of the connection. This usually occurs on online accounts.

Because we are dealing with HTML documents the protocol that must be implemented is called HTTP. HTTP runs under TCP which is the very reason why you should use Winsock. Let's take a very simple situation where you need to enter your user name and password, click on the submit button to get you connected to the server. The below example assumes http and not https. This is not the actual coding but rather an illustration to how it is done.

You will need to know the complete URL. It probably will look like this:
http://www.somewebsite.com/cgi-bin/login?user=myuserid&pass=mypassword

Connect to the http server on port 80. You supply the URL as "www.somewebsite.com". Winsock will add the 'http://' protocol prefix.

If the server accepts your connection it will respond back usually with a 200 OK message.

The server is now waiting for you to send back your request. So, you send this:

"POST /cgi-bin/login HTTP/1.0"
"Content-length: 29"
""
"user=myuserid&pass=mypassword"

If the above data is correct the server will respond back to you with a positive reply indicating that you have successfully loged in. What takes place beyond this point will vary greatly from one HTML Web server to another.

The above is just a very simple example using Winsock and I do not want to get into the more complexities at this time. Using the WebBrowser or the Inet OCX will simplify all of this greatly but the one problem I have yet to solve is that I have not been able to find out how to use either one of the two to simulate the 'clicking' of the submit button.

BTW:

The 'image' that you see is not really an image (ie. it is not a .gif or a .jpg) but it is a modified submit button that looks like a picture and it has the usual tag associated with it: <input type="submit" value="Submit" .........> 

   


Nilrem

Right that is a lot of information to take in. Thankyou.

Ok, this is as much detail as I can go into

the game is called Keno over at www.pogo.com
I try and right click the image (but no menu coms up). I look at the page source and there is a .jsp extention in there, so I figure it's written in java?

Anyways I'm not sure if the image is a button or a hyperlink.
What it does is (it's called quickbet) once you click the button/image it then highlights a bunch of numbers (sort of like bingo).

Does this enlighten you at all?
Also how come my code doesn't work outside of a web-browser?

If you want more information on the actual web-browser window I am talking about then please feel free to pm, that way I can tell you how to login and see it.

mnemonic

Quote from: Nilrem on May 13, 2005, 09:36:14 AM
I look at the page source and there is a .jsp extention in there, so I figure it's written in java?
Huh?! Where is a jsp extension? In the pages HTML or in the URL (e.g. domain.com/index.jsp)?
I think you mean the URL, don´t you?

Quote from: Nilrem on May 13, 2005, 09:36:14 AM
Anyways I'm not sure if the image is a button or a hyperlink.
You can determine that by having a look at the HTML...


Anyway, I feel you should get a bit more familiar with HTML, the CGI principle, forms, links and the GET and POST methods.
You may get a start at http://php.net
If you want some local test environment I would recommend you to get EasyPHP (watch out on google).
If you get the basics you`ll quickly get an idea on how to solve your prob together with the info already given.

Regards
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

Nilrem

I know HTML, it uses frames and as the frames there is some weird link (looks like a random generated, probably for unique login number), and another one that ends in .jsp

mnemonic

Quote from: Nilrem on May 13, 2005, 04:28:16 PM
I know HTML, it uses frames and as the frames there is some weird link (looks like a random generated, probably for unique login number), and another one that ends in .jsp
And what does us tell this?
Yes, one of the frames is dynamically created via some script on the server, nothing else.
That is not a java application (or applet) which runs on your local machine but a server side script which creates dynamic HTML. And there is no difference whether it is JSP, PHP or PERL. They all get their input via GET or POST data, that´s it.
It seems as if you only looked at the HTML which describes the frameset. If you use IE do a rightclick into the frame which is dynamically created and select "show source" (or sth like that - I´m using the german version of IE). That way you should be able to examine the HTML source of the frame and then you´ll know whether your pic is a link or a submit button.
If I´d like to do the task you´re doing, I´d use Java as it provides a easy way to do URL connections.
The number you see might probably be a session key :wink

I still think you don´t know the essentials.

Knowledge is power...
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

Mark Jones

Strange... no new posts from Nilrem in two months. Was he busted by the Feds??? :lol
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Robert Collins

Quote from: Mark Jones on July 22, 2005, 05:03:09 AM
Strange... no new posts from Nilrem in two months. Was he busted by the Feds??? :lol

No he wasn't. After his last post here he contacted me personally and we worked together to resolve his problem. It turned out that what he wanted to accomplish was to create a Windows application that would run silently in the background sending 'clicks' to a web server so as to keep the server live all the time. It was a game of keno that he wanted to automate so he wouldn't have to sit in front of the game window all day submitting his bid and hitting the submit button. Well, I finally figured out how to do it and gave him the source code. After awhile of screwing around with his automated game he and I (or at least I) got tired of it and finally just ended the project. 

Mark Jones

Oh I was just questioning in general - haven't seen him around here in a long time. Was wondering if something happened, or he just decided to go his separate way, or what.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08