PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > php local application send mouse click
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
php local application send mouse click

Réponse
 
LinkBack Outils de la discussion
Vieux 08/04/2008, 01h59   #1
Daniel Kolbo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut php local application send mouse click

Hello,

I am mostly familiar with php for serving up web pages; however,
recently I have been writing a local command line script on my WinXP
machine. I have spent the better part of this last week and all of
today trying to figure out a way to send a mouse click to a particular
window on the screen.

I first saw w32api.dll on the php.net site. However, I cannot find this
dll, but this searching took me to winbinder and php-gtk2. It seems
that I can only get winbinder to get (not send) mouse information: event
type and x,y positions. I am not too familiar with php-gtk nor creating
dlls.

I want to use my local php command line script on my winXP machine to
send mouse events (click) to a window. I am open to any ideas on how to
do this.

For C++ and VB there seems to be the SendMessage() function. Is there a
way to tap into that function from my php script?

winbinder has a function that wraps the SendMessage() function called
wb_send_message, but after literally 9 hours i quit.

on the MSDN.microsoft site, I saw the functions mouse_event() and
SendInput() of the "user32.dll"

http://msdn2.microsoft.com/en-us/library/ms646310.aspx
http://msdn2.microsoft.com/en-us/library/aa932376.aspx

I copied the "user32.dll" to my php/ext folder and tried loading the
"user32.dll" both as an extension directive in php.ini and by using the
dl() function in my script (dl() is enabled). However, both methods
gave me a PHP warning:

as an extension in php.ini it gives the following error:

PHP Warning: PHP Startup: Invalid library (maybe not a PHP library)
'user32.dll
' in Unknown on line 0

get_loaded_extensions() confirms user32.dll never gets loaded.

invoking dl("user32.dll") yields the warning:

PHP Warning: dl(): Invalid library (maybe not a PHP library)
'user32.dll' in [my script]

Possible ideas:
-Load a dll with the dl() function? (Write the dll with VB or C++)
-use the w32api_register_function() in php somehow to 'tap' into windows
api functions.
-use a project that can assist me in this like php-gtk2 or winbinder
-maybe someone has a copy of w32api.dll
-something about COM objects, though i am really not familiar

It seems as though the C languages and VB languages can do this.
Perhaps I could write and compile a dll in that language, somehow load
it up in php (even though i am having errors doing that currently), then
I can use those functions in my dll to send my mouse clicks through php.


I am throwing out this question to the community and wondering what your
suggestions would be for how to go about sending a mouse click event to
my windows api from a php script.

I am not interested in writing javascript as this is not a web application.

Any thoughts, comments, suggestions, about how to do send mouse events
from a php script will be much appreciated.

Thanks in advance,

  Réponse avec citation
Vieux 08/04/2008, 05h52   #2
Wolf
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] php local application send mouse click



Daniel Kolbo wrote:
> Hello,
>
> I am mostly familiar with php for serving up web pages; however,
> recently I have been writing a local command line script on my WinXP
> machine. I have spent the better part of this last week and all of
> today trying to figure out a way to send a mouse click to a particular
> window on the screen.
>
> I first saw w32api.dll on the php.net site. However, I cannot find this
> dll, but this searching took me to winbinder and php-gtk2. It seems
> that I can only get winbinder to get (not send) mouse information: event
> type and x,y positions. I am not too familiar with php-gtk nor creating
> dlls.
>
> I want to use my local php command line script on my winXP machine to
> send mouse events (click) to a window. I am open to any ideas on how to
> do this.
>
> For C++ and VB there seems to be the SendMessage() function. Is there a
> way to tap into that function from my php script?
>
> winbinder has a function that wraps the SendMessage() function called
> wb_send_message, but after literally 9 hours i quit.
>
> on the MSDN.microsoft site, I saw the functions mouse_event() and
> SendInput() of the "user32.dll"
>
> http://msdn2.microsoft.com/en-us/library/ms646310.aspx
> http://msdn2.microsoft.com/en-us/library/aa932376.aspx
>
> I copied the "user32.dll" to my php/ext folder and tried loading the
> "user32.dll" both as an extension directive in php.ini and by using the
> dl() function in my script (dl() is enabled). However, both methods
> gave me a PHP warning:
>
> as an extension in php.ini it gives the following error:
>
> PHP Warning: PHP Startup: Invalid library (maybe not a PHP library)
> 'user32.dll
> ' in Unknown on line 0
>
> get_loaded_extensions() confirms user32.dll never gets loaded.
>
> invoking dl("user32.dll") yields the warning:
>
> PHP Warning: dl(): Invalid library (maybe not a PHP library)
> 'user32.dll' in [my script]
>
> Possible ideas:
> -Load a dll with the dl() function? (Write the dll with VB or C++)
> -use the w32api_register_function() in php somehow to 'tap' into windows
> api functions.
> -use a project that can assist me in this like php-gtk2 or winbinder
> -maybe someone has a copy of w32api.dll
> -something about COM objects, though i am really not familiar
>
> It seems as though the C languages and VB languages can do this. Perhaps
> I could write and compile a dll in that language, somehow load it up in
> php (even though i am having errors doing that currently), then I can
> use those functions in my dll to send my mouse clicks through php.
>
>
> I am throwing out this question to the community and wondering what your
> suggestions would be for how to go about sending a mouse click event to
> my windows api from a php script.
>
> I am not interested in writing javascript as this is not a web application.
>
> Any thoughts, comments, suggestions, about how to do send mouse events
> from a php script will be much appreciated.
>
> Thanks in advance,



Trying to send one TO a screen? Good luck with that. But you really
should wait at least for a few days for a response from the list before
reposting the same question with no further information...

What code have you tried? What code works to a point but fails?

Wolf

  Réponse avec citation
Vieux 12/04/2008, 00h13   #3
Daniel Kolbo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] php local application send mouse click

Wolf wrote:
>
>
> Daniel Kolbo wrote:
>> Hello,
>>
>> I am mostly familiar with php for serving up web pages; however,
>> recently I have been writing a local command line script on my WinXP
>> machine. I have spent the better part of this last week and all of
>> today trying to figure out a way to send a mouse click to a particular
>> window on the screen.
>>
>> I first saw w32api.dll on the php.net site. However, I cannot find
>> this dll, but this searching took me to winbinder and php-gtk2. It
>> seems that I can only get winbinder to get (not send) mouse
>> information: event type and x,y positions. I am not too familiar with
>> php-gtk nor creating dlls.
>>
>> I want to use my local php command line script on my winXP machine to
>> send mouse events (click) to a window. I am open to any ideas on how
>> to do this.
>>
>> For C++ and VB there seems to be the SendMessage() function. Is there
>> a way to tap into that function from my php script?
>>
>> winbinder has a function that wraps the SendMessage() function called
>> wb_send_message, but after literally 9 hours i quit.
>>
>> on the MSDN.microsoft site, I saw the functions mouse_event() and
>> SendInput() of the "user32.dll"
>>
>> http://msdn2.microsoft.com/en-us/library/ms646310.aspx
>> http://msdn2.microsoft.com/en-us/library/aa932376.aspx
>>
>> I copied the "user32.dll" to my php/ext folder and tried loading the
>> "user32.dll" both as an extension directive in php.ini and by using
>> the dl() function in my script (dl() is enabled). However, both
>> methods gave me a PHP warning:
>>
>> as an extension in php.ini it gives the following error:
>>
>> PHP Warning: PHP Startup: Invalid library (maybe not a PHP library)
>> 'user32.dll
>> ' in Unknown on line 0
>>
>> get_loaded_extensions() confirms user32.dll never gets loaded.
>>
>> invoking dl("user32.dll") yields the warning:
>>
>> PHP Warning: dl(): Invalid library (maybe not a PHP library)
>> 'user32.dll' in [my script]
>>
>> Possible ideas:
>> -Load a dll with the dl() function? (Write the dll with VB or C++)
>> -use the w32api_register_function() in php somehow to 'tap' into
>> windows api functions.
>> -use a project that can assist me in this like php-gtk2 or winbinder
>> -maybe someone has a copy of w32api.dll
>> -something about COM objects, though i am really not familiar
>>
>> It seems as though the C languages and VB languages can do this.
>> Perhaps I could write and compile a dll in that language, somehow load
>> it up in php (even though i am having errors doing that currently),
>> then I can use those functions in my dll to send my mouse clicks
>> through php.
>>
>>
>> I am throwing out this question to the community and wondering what
>> your suggestions would be for how to go about sending a mouse click
>> event to my windows api from a php script.
>>
>> I am not interested in writing javascript as this is not a web
>> application.
>>
>> Any thoughts, comments, suggestions, about how to do send mouse events
>> from a php script will be much appreciated.
>>
>> Thanks in advance,

>
>
> Trying to send one TO a screen? Good luck with that. But you really
> should wait at least for a few days for a response from the list before
> reposting the same question with no further information...
>
> What code have you tried? What code works to a point but fails?
>
> Wolf
>
>


Thanks for your response Wolf.

Sorry for the double email, i had just signed up, and I thought the
original didn't go through, b/c i hadn't completed all the verification
steps.

What is TO? You referenced it in your reply.

In addition to the function i mentioned from winbinder wb_send_message()
I have tried:

I tried loading in the user32.dll extension from within the php.ini,
this failed.
I tried loading in the user32.dll from within the script, this failed.

dl("user32.dll")

I tried loading in the php_w32api.dll from within the script (i copied
the php_w32api.dll from php4 into my ext/ folder in php5.

dl("php_w32api.dll");

this worked; however, when I tried registering the functions from within
the script it failed on me.

w32api_register_function("User32.dll",
"mouse_event",
"void");

I really am at a lose of how to even begin. How would I execute a mouse
click from a php script on a console application?

Thanks,

  Réponse avec citation
Vieux 12/04/2008, 10h01   #4
Stut
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] php local application send mouse click

On 12 Apr 2008, at 00:13, Daniel Kolbo wrote:
> In addition to the function i mentioned from winbinder
> wb_send_message() I have tried:
>
> I tried loading in the user32.dll extension from within the php.ini,
> this failed.
> I tried loading in the user32.dll from within the script, this failed.
>
> dl("user32.dll")


The dl function is for loading PHP extensions, not any old DLL. The
same goes for the extensions section of php.ini.

> I tried loading in the php_w32api.dll from within the script (i
> copied the php_w32api.dll from php4 into my ext/ folder in php5.
>
> dl("php_w32api.dll");
>
> this worked; however, when I tried registering the functions from
> within the script it failed on me.
>
> w32api_register_function("User32.dll",
> "mouse_event",
> "void");
>
> I really am at a lose of how to even begin. How would I execute a
> mouse click from a php script on a console application?


1) You should be using SendInput not mouse_event unless you're on
Windows 9x.

2) Why are you trying to do this in PHP? It would be much easier to
develop and test in C# or VB or even C++. At the very least I'd
recommend doing that to get the sequence of API calls worked out and
then port it over to PHP.

-Stut

--
http://stut.net/
  Réponse avec citation
Vieux 12/04/2008, 15h25   #5
Daniel Kolbo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] php local application send mouse click



Stut wrote:
> On 12 Apr 2008, at 00:13, Daniel Kolbo wrote:
>> In addition to the function i mentioned from winbinder
>> wb_send_message() I have tried:
>>
>> I tried loading in the user32.dll extension from within the php.ini,
>> this failed.
>> I tried loading in the user32.dll from within the script, this failed.
>>
>> dl("user32.dll")

>
> The dl function is for loading PHP extensions, not any old DLL. The same
> goes for the extensions section of php.ini.
>
>> I tried loading in the php_w32api.dll from within the script (i copied
>> the php_w32api.dll from php4 into my ext/ folder in php5.
>>
>> dl("php_w32api.dll");
>>
>> this worked; however, when I tried registering the functions from
>> within the script it failed on me.
>>
>> w32api_register_function("User32.dll",
>> "mouse_event",
>> "void");
>>
>> I really am at a lose of how to even begin. How would I execute a
>> mouse click from a php script on a console application?

>
> 1) You should be using SendInput not mouse_event unless you're on
> Windows 9x.
>
> 2) Why are you trying to do this in PHP? It would be much easier to
> develop and test in C# or VB or even C++. At the very least I'd
> recommend doing that to get the sequence of API calls worked out and
> then port it over to PHP.
>
> -Stut
>


RE: 1) I agree. I read a lot of people were having problems with
SendInput, so I just tried it with mouse_event.

RE: 2) I am choosing PHP b/c i am better skilled in PHP. Alas, I have
pretty much resigned to having to develop this in C# of VB. I am
reading the zend page on developing php extensions. I figure I will
develop the php extension in C# or VB, then load it in php. Is this
what you mean by "port" to PHP?

Thanks for your ,
DanK
  Réponse avec citation
Vieux 12/04/2008, 15h44   #6
Stut
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] php local application send mouse click

On 12 Apr 2008, at 15:25, Daniel Kolbo wrote:
> Stut wrote:
>> On 12 Apr 2008, at 00:13, Daniel Kolbo wrote:
>>> In addition to the function i mentioned from winbinder
>>> wb_send_message() I have tried:
>>>
>>> I tried loading in the user32.dll extension from within the
>>> php.ini, this failed.
>>> I tried loading in the user32.dll from within the script, this
>>> failed.
>>>
>>> dl("user32.dll")

>> The dl function is for loading PHP extensions, not any old DLL. The
>> same goes for the extensions section of php.ini.
>>> I tried loading in the php_w32api.dll from within the script (i
>>> copied the php_w32api.dll from php4 into my ext/ folder in php5.
>>>
>>> dl("php_w32api.dll");
>>>
>>> this worked; however, when I tried registering the functions from
>>> within the script it failed on me.
>>>
>>> w32api_register_function("User32.dll",
>>> "mouse_event",
>>> "void");
>>>
>>> I really am at a lose of how to even begin. How would I execute a
>>> mouse click from a php script on a console application?

>> 1) You should be using SendInput not mouse_event unless you're on
>> Windows 9x.
>> 2) Why are you trying to do this in PHP? It would be much easier to
>> develop and test in C# or VB or even C++. At the very least I'd
>> recommend doing that to get the sequence of API calls worked out
>> and then port it over to PHP.
>> -Stut

>
> RE: 1) I agree. I read a lot of people were having problems with
> SendInput, so I just tried it with mouse_event.
>
> RE: 2) I am choosing PHP b/c i am better skilled in PHP. Alas, I
> have pretty much resigned to having to develop this in C# of VB. I
> am reading the zend page on developing php extensions. I figure I
> will develop the php extension in C# or VB, then load it in php. Is
> this what you mean by "port" to PHP?


Get it working in another language so you know which API calls you
need, then work on getting access to those calls to work from PHP.

If your only reason for doing it in PHP is your experience I'd suggest
just doing it in C# and don't bother porting it. By porting it I mean
converting it from C# to PHP.

One other thing worth asking yourself... is there an easier way to
achieve what you want than simulating a mouse click? You might have
better luck telling the screen control you need to click on that it's
been clicked rather than actually programmatically clicking the mouse
button. But that's going way beyond the scope of this list. I suggest
you ask in one of the MS support forums.

-Stut

--
http://stut.net/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 04h49.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,29172 seconds with 14 queries