It is currently Sat May 25, 2013 9:47 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Checking for key presses
PostPosted: Fri Mar 16, 2012 7:56 pm 
Offline
User
User

Joined: Thu Feb 04, 2010 7:34 am
Posts: 88
Location: Decatur, TX
Hello everyone, can someone please get me an example of how to do the following in PB for Linux?
Code:
Repeat
    Delay(100)
Until (GetAsyncKeyState_(#VK_ESCAPE) & 32768)  = 32768
End 1


Top
 Profile  
 
 Post subject: Re: Checking for key presses
PostPosted: Fri Mar 16, 2012 9:55 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 2488
Location: New Zealand
try this and see here
http://developer.gnome.org/gtk-tutorial/2.22/x182.html
Code:

Global gkey

Procedure KeyPressedCallback(*widget,*event.GdkEventKey,*udata );
  gkey =  *event\keyval & $FF
  Debug PeekS(*event\string) + " " + Str(gkey)
EndProcedure   

OpenWindow(0,0,0,200,100,"keyPress")
g_signal_connect_(WindowID(0),"key_press_event",@KeyPressedCallback(),0);

Repeat
  ev = WaitWindowEvent()
 
Until gkey = #PB_Key_Escape   


Top
 Profile  
 
 Post subject: Re: Checking for key presses
PostPosted: Fri Mar 16, 2012 10:08 pm 
Offline
User
User

Joined: Thu Feb 04, 2010 7:34 am
Posts: 88
Location: Decatur, TX
The only thing is I'm trying to do it without opening a window. Console or otherwise. Actually, It's only curiosity now. I am writing a server application for linux (my first linux app) and I was trying to decide how I was going to signal it to start, stop, or restart. What I decided to do is to have the program listen on two ports, one for internet clients and data, and one for localhost, so IT people can start it and stop it from bash. If they run the program with certain parameters, it will just send itself a command locally. I'm sure there are other ways to do it, but I don't know them yet.


Top
 Profile  
 
 Post subject: Re: Checking for key presses
PostPosted: Tue Mar 20, 2012 12:13 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 814
Location: Germany
In idle's code example Procedure has to be changed to ProcedureC.
Otherwise you will receive the following error on pressing a key:
PB IDE wrote:
Line: 6 - Invalid memory access


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye