flat assembler
Message board for the users of flat assembler.

Index > Windows > How make program proceed when it's window is inactive (NEWB)

Author
Thread Post new topic Reply to topic
barmentalisk



Joined: 06 Sep 2005
Posts: 36
barmentalisk 09 Apr 2007, 14:15
Sorry for my english, I'm a newbee from white-russia(Byelarus).
I made a proc which reads joystick and emulate key pressings
when joy buttons are pressed.It reads twice with optional delay
and proceed keypress emulating only if results equ.

Now I want to include my proc in FASM-tray-example, but
I get my proc working only when tray-example window is
active and is under cursor.I have no idea what to do to
make program proceed my proc when program is background.
Help me please.
Source hear:
Code:
proc PPJReadProc
     joygetpos:
       invoke joyGetPos,0,pji
       invoke Sleep,0
       invoke joyGetPos,0,pji2
       mov eax,[pji.dwButtons]
       mov ebx,[pji2.dwButtons]
       cmp eax,ebx
       je buttons
       ret


     buttons:
       mov ax,[but_old]
       mov [but_result],ax
       mov eax,[pji.dwButtons]
       mov [but_old],ax
       xor [but_result],ax



     but0:;A
       mov bx,[but_result]
       bt  bx,0
       jnc but1
       mov ax,[but_old]
       bt  ax,0
       jc  but0dn
       invoke keybd_event,70,33,2h,0;70 - F-key   2h - KeyUp
       jmp but1
     but0dn:
       invoke MessageBox,0,0,0,0
       invoke keybd_event,70,33,0,0;70 - F-key     KeyDown


     but1:;B
       mov bx,[but_result]
       bt  bx,1
       jnc but2
       mov ax,[but_old]
       bt  ax,1
       jc  but1dn
       invoke keybd_event,71,34,2h,0 ;71 - G-key
       jmp but2
     but1dn:
       invoke keybd_event,71,34,0,0


     but2:;C
       mov bx,[but_result]
       bt  bx,2
       jnc but3
       mov ax,[but_old]
       bt  ax,2
       jc  but2dn
       invoke keybd_event,72,35,2h,0  ;72 - H
       jmp but3
     but2dn:
       invoke keybd_event,72,35,0,0


     but3:;Start
       mov bx,[but_result]
       bt  bx,3
       jnc but4
       mov ax,[but_old]
       bt  ax,3
       jc  but3dn
       invoke keybd_event,81,16,2h,0   ;81 - Q
       jmp but4
     but3dn:
       invoke keybd_event,81,16,0,0


     but4:;X
       mov bx,[but_result]
       bt  bx,4
       jnc but5
       mov ax,[but_old]
       bt  ax,4
       jc  but4dn
       invoke keybd_event,84,20,2h,0  ;84 - T
       jmp but5
     but4dn:
       invoke keybd_event,84,20,0,0


     but5:;Y
       mov bx,[but_result]
       bt  bx,5
       jnc but6
       mov ax,[but_old]
       bt  ax,5
       jc  but5dn
       invoke keybd_event,89,21,2h,0  ;89 - Y
       jmp but6
     but5dn:
       invoke keybd_event,89,21,0,0


     but6:;Z
       mov bx,[but_result]
       bt  bx,6
       jnc but7
       mov ax,[but_old]
       bt  ax,6
       jc  but6dn
       invoke keybd_event,85,22,2h,0  ;85 - U
       jmp but7
     but6dn:
       invoke keybd_event,85,22,0,0


     but7:;Mode
       mov bx,[but_result]
       bt  bx,7
       jnc but8
       mov ax,[but_old]
       bt  ax,7
       jc  but7dn
       invoke keybd_event,69,18,2h,0   ;69 - E
       jmp but8
     but7dn:
       invoke keybd_event,69,18,0,0


     but8:
        ret
endp    
Post 09 Apr 2007, 14:15
View user's profile Send private message Reply with quote
Mr_Silent



Joined: 25 Apr 2006
Posts: 30
Mr_Silent 10 Apr 2007, 14:31
joySetCapture ?
Post 10 Apr 2007, 14:31
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 10 Apr 2007, 15:30
read about "threads", "multithreading" etc...

good luck Wink
Post 10 Apr 2007, 15:30
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
barmentalisk



Joined: 06 Sep 2005
Posts: 36
barmentalisk 10 Apr 2007, 18:13
vid wrote:
read about "threads", "multithreading" etc...

You mean I have to put my proc into dll and run it in its own thread
or I even can make thread without dll?
I will try to learn threads, thank you!
Mr_Silent wrote:
joySetCapture ?

Thank you, but I can't use this API because joySetCapture
can be used only with one window at a time but I need
other program be able to capture joyinput
Post 10 Apr 2007, 18:13
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 10 Apr 2007, 19:29
you're welcome

Quote:
or I even can make thread without dll?

yes, you can run procedure as thread. Study MSDN about Multithreading, look at API CreateThread (i think)
Post 10 Apr 2007, 19:29
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
barmentalisk



Joined: 06 Sep 2005
Posts: 36
barmentalisk 11 Apr 2007, 04:51
Thank you, VID, I always have a problem to find a subject which I need because this forum, MSDN, everything is in English and I am not so experienced in special termins written on foreign lang, how can I find what I need? But when a subj is found I have an opportunity to learn it with the help of dictionary and study is going up!
Post 11 Apr 2007, 04:51
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 11 Apr 2007, 08:44
try google to search MSDN. For example google terms: MSDN CreateThread"
Post 11 Apr 2007, 08:44
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
barmentalisk



Joined: 06 Sep 2005
Posts: 36
barmentalisk 12 Apr 2007, 11:10
Thank you I understand how to create thread.You helped me to find the right API!
Would you be so pleased to help me one more time?
That proc reads virtual joypad which reads sega joypad
conected to parport via adapter.
Now I want to read data directly from parport
what functions can read/write parport under NT/2k/XP?
and how to set logical 1 on parport's pins?
Post 12 Apr 2007, 11:10
View user's profile Send private message Reply with quote
barmentalisk



Joined: 06 Sep 2005
Posts: 36
barmentalisk 27 Apr 2007, 07:02
I have the only way to write kernel mode driver and cant find any way to read port from user mode?
Post 27 Apr 2007, 07:02
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.