Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

nwin32api.keybd_event(9,0,0,0)-Need/Want all other key #'s

If you have a question or need help, this is the place to be.
Post Reply
User avatar
zian
Site Admin
Posts: 569
Joined: Wed Jun 24, 2009 3:54 pm

nwin32api.keybd_event(9,0,0,0)-Need/Want all other key #'s

Post by zian »

Hi There,

I'm looking for a webpage or artical that lists all the keyboard characters for use with Python. I have looked all over the net and not found exactly what I'm looking for.

Below is a small part of code/script that Paco made for some of us having issues using EG for Alt/Tab-TaskSwitching....

Push and hold ALT, send TAB

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1066">
    <Action>
        EventGhost.PythonScript(u'import win32api\nwin32api.keybd_event(18,0,0,0)\nwin32api.keybd_event(9,0,0,0)\nwin32api.keybd_event(9,0,2,0)')
    </Action>
</EventGhost>
That was just one part of a three Macro code that Paco shared with us. I used it after tweaking it and it works real nice. What I'm looking for is what numbers all the other keyboard characters would be.

I'm just guessing but it looks like the....
"(18,0,0,0)" = Alt key down
"(9,0,0,0)" = Tab key down
"(9,0,2,0)" = Tab key up etc.

A Bonus would be to know what all other variables can be called up with the other numbers/zeros in that code.

Thanks much for any info or pointing me to the right place on the net to find/learn this.
eventghost.net
Be there or be square.
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: nwin32api.keybd_event(9,0,0,0)-Need/Want all other key #'s

Post by jinxdone »

Well, this is not really just an eg-specific thing. What you are infact doing is accessing the win32 api with python.

You can find out everything there is to know about win32 api at MSDN
list of keycodes, remember to convert the hex value to integer before using it with the python function.
keybd_event function syntax

As you can see you could also give the function a scancode instead of virtual keycode, but I guess either will work just fine. :)

Btw. you can probably find all sorts of useful snipplets that use the win32 api coded with different languages. You can do all the same things with python even if bit you found was written in another language, you just have to recreate whatever the script does in python for use in EG.


PS. Sorry, I don't know any really good tutorials/where to learn about the win32 api, perhaps googling will help..

-jinxdone
Last edited by jinxdone on Wed Jul 15, 2009 6:18 am, edited 1 time in total.
User avatar
zian
Site Admin
Posts: 569
Joined: Wed Jun 24, 2009 3:54 pm

Re: nwin32api.keybd_event(9,0,0,0)-Need/Want all other key #'s

Post by zian »

...remember to convert the hex value to integer before using it with the python function.
Yup jinxdone, that is what I was missing. I didn't know a thing about converting the numbers.

Thanks for the links and big thanks for the info.
eventghost.net
Be there or be square.
Post Reply