AndyG Posted September 23, 2018 Share Posted September 23, 2018 I am a novice. My knowledge is based on IT classes I took in high school and on what I could find on Google. Nevertheless I managed to scrap up a PHP script in connection with a database I set up on Apache2. In simple terms, the script takes info from the database and sends it to a website. Everything works fine, but I want to make things easier by sending a 10 digits code via simulated keystrokes to the website: access website wait for page to load send 10 digit code + Enter I'm trying to do this both for Windows 10 and Linux. On linux, thus far I've stumbled in permission issues for xdotool, and implementing the "wait for page to load". On Windows 10 I'm clueless since sendkeys no longer works with Windows 10. Thank you for your help. Quote Link to comment https://forums.phpfreaks.com/topic/307715-simulate-keystrokes-from-php-script/ Share on other sites More sharing options...
phpmillion Posted September 23, 2018 Share Posted September 23, 2018 You can easily do this using curl, it will work on all platforms where PHP is installed. Quote Link to comment https://forums.phpfreaks.com/topic/307715-simulate-keystrokes-from-php-script/#findComment-1561039 Share on other sites More sharing options...
requinix Posted September 23, 2018 Share Posted September 23, 2018 You will not be sending keystrokes. The internet does not work that way. phpmillion mentioned cURL. What you will be doing is submitting the form that page uses for the code - just like if the browser had done it. Quote Link to comment https://forums.phpfreaks.com/topic/307715-simulate-keystrokes-from-php-script/#findComment-1561057 Share on other sites More sharing options...
ginerjm Posted September 23, 2018 Share Posted September 23, 2018 Why do you need to "send keystrokes"? Is this some automated process? Why does your parent script have to send a page to the client only to have it somehow send some digits to another script? Is the user irrelevant here? Quote Link to comment https://forums.phpfreaks.com/topic/307715-simulate-keystrokes-from-php-script/#findComment-1561058 Share on other sites More sharing options...
AndyG Posted September 24, 2018 Author Share Posted September 24, 2018 (edited) Thank you all for your answers. I will definitely look into cURL. The script should do the following things: take specific information from a local database - DONE accordingly to the information selected, will activate several local physical locations (lockers, doors etc) - DONE send specific information (related to which door was accessed) to a website - the 10 digit code+Enter - IN PROGRESS This website that I'm trying to access is owned by a different company. It is usable now by inputting this 10 digits code+Enter(they used access cards before). I know that the easiest way would be for them just to change the input method to something like accessing "www.example.com/code", but that would cost a lot of money. So in fact my question is, should I just pay the money, or is there an easy way to do this as things stand now. Thank you again for your answers ? Edited September 24, 2018 by AndyG Quote Link to comment https://forums.phpfreaks.com/topic/307715-simulate-keystrokes-from-php-script/#findComment-1561069 Share on other sites More sharing options...
requinix Posted September 24, 2018 Share Posted September 24, 2018 If it's on a website then it uses HTTP to send and receive data. You can do the exact same thing with cURL. Quote Link to comment https://forums.phpfreaks.com/topic/307715-simulate-keystrokes-from-php-script/#findComment-1561080 Share on other sites More sharing options...
phpmillion Posted September 24, 2018 Share Posted September 24, 2018 55 minutes ago, requinix said: If it's on a website then it uses HTTP to send and receive data. You can do the exact same thing with cURL. Yes, it's on website, as per original OP's message - the script takes info from the database and sends it to a website It's the main reason I suggested him curl. Quote Link to comment https://forums.phpfreaks.com/topic/307715-simulate-keystrokes-from-php-script/#findComment-1561082 Share on other sites More sharing options...
AndyG Posted September 24, 2018 Author Share Posted September 24, 2018 (edited) I don't think cURL is usable in my situation. I think there's a misunderstanding, so I'll try to explain things better. All of this is related to a kiosk app tracking employees status. I'll give you an example: Jack comes to work 08:00, he checks in with the kiosk app the app recognizes his credentials and starts the automation process accordingly the app accesses a specific website, waits for it to load, then types in the 10 digit code+Enter related to Jacks credentials then Jack has to undergo specific checks on that website, but that's not my problem anymore. So everything happens on the same computer. The script opens the website, waits for it to load, types the code - all of this while the user is in front of the PC seeing everything. Before, we had just the website where people used access cards to login. Now I want to bypass those access cards, so I need something to simulate keystrokes. Probably you know that when swiping access cards you actually just type a code+Enter. This website login is quite simple. It's just a page, you use the access card and you login. I can take the access card, swipe it with notepad open. Copy/paste that code into the site+Enter, and it works. Or type the code+Enter and it works again. So cURL has to target a specific window, input the 10 digit code+Enter. It cannot do that, as far as I can see. I appreciate all your help so far, but my initial question still stands: Can keystrokes be simulated from php script ? Edited September 24, 2018 by AndyG Quote Link to comment https://forums.phpfreaks.com/topic/307715-simulate-keystrokes-from-php-script/#findComment-1561087 Share on other sites More sharing options...
requinix Posted September 24, 2018 Share Posted September 24, 2018 No. PHP cannot solve this problem. Quote Link to comment https://forums.phpfreaks.com/topic/307715-simulate-keystrokes-from-php-script/#findComment-1561091 Share on other sites More sharing options...
phpmillion Posted September 25, 2018 Share Posted September 25, 2018 OP, if I understand right, if credentials are submitted to website from other place (let's say you manually submit them via browser), it won't work in your situation? Quote Link to comment https://forums.phpfreaks.com/topic/307715-simulate-keystrokes-from-php-script/#findComment-1561098 Share on other sites More sharing options...
AndyG Posted September 25, 2018 Author Share Posted September 25, 2018 @phpmillion I don't exactly understand what you mean. @requinix already answered me, and I believe he is right. So I decided no longer to pursue this. Thank you all for your help ? Quote Link to comment https://forums.phpfreaks.com/topic/307715-simulate-keystrokes-from-php-script/#findComment-1561109 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.