home *** CD-ROM | disk | FTP | other *** search
- /*
- * C-Includes, C-Definitionen
- *
- */
-
- #define class _class
- #define template _template
-
- extern "C" {
- #include <exec/types.h>
- #include <exec/ports.h>
- #include <exec/memory.h>
- #include <exec/execbase.h>
-
- #include <dos/dos.h>
- #include <dos/dosextens.h>
- #include <dos/exall.h>
- #include <dos/rdargs.h>
-
- #include <clib/alib_protos.h>
- #include <clib/alib_stdio_protos.h>
-
- #include <devices/input.h>
- #include <devices/keymap.h>
- #include <devices/inputevent.h>
- #include <intuition/intuitionbase.h>
- #include <intuition/classusr.h>
-
- #include <workbench/workbench.h>
- #include <workbench/startup.h>
- #include <workbench/icon.h>
- #include <graphics/gfxbase.h>
- #include <inline/stubs.h>
-
- #ifdef __OPTIMIZE__
- #include <inline/exec.h>
- #include <inline/dos.h>
- #include <inline/intuition.h>
- #include <inline/utility.h>
- #include <inline/keymap.h>
- #include <inline/icon.h>
- #else
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/utility_protos.h>
- #include <clib/keymap_protos.h>
- #include <clib/icon_protos.h>
- #endif
-
- int atexit(void (*)(void));
- }
-
- #undef template
- #undef class
-
-
- extern "C" {
-
- /* dont mangle our global symbols */
-
- IntuitionBase *IntuitionBase;
- GfxBase *GfxBase;
- Library *GadToolsBase;
- Library *UtilityBase;
- Library *WorkbenchBase;
- Library *IconBase;
- Library *CxBase;
- Library *IFFParseBase;
- Library *AslBase;
- Device *KeymapBase;
-
- extern ExecBase *SysBase;
-
- extern BPTR stdin;
- extern BPTR stdout;
- }
-
-
- /*
- * C++-Includes, C++-Definitionen
- *
- */
-
- #include "../../add/baserel/add.h" // prototypes for all new C-functions
- #include "../../add/baserel/couta.h" // defines cout
- #include "../../add/baserel/OwnError.h" // defines err
-
-
- /*
- * our function-prototypes
- *
- */
-
- void MyExit();
- BOOL MyInit(int alen, char *aptr);
- int main(int alen, char *aptr);
- void OutputError(void);
- void Mouse_SetPosition(UBYTE *x, UBYTE *y, BOOL relative=FALSE);
- void Chars_InsertRawKey(LONG ch);
- void Chars_InsertVanilla(UBYTE *chs);
- void File_Handle(UBYTE *filename);
- void Line_Handle(UBYTE *line);
- void Mouse_Click(UWORD Code);
- int myatoi(char *str);
- void Window_Move_to_Front_and_activate(char *wintitle);
- void Mouse_Move_to_LeftUpperActWindow(void);
- void Screen_to_Front_and_activate(char *screentitle);
- void PubScreen_to_Front_and_activate(UBYTE *pubscreentitle);
- void Icon_Handle(UBYTE *filename);
-
-
- /* Version-String */
-
- char *version = "\0$VER: InsertEvent 1.0 (26.10.93)";
-
-
- #define TEMPLATE "MX=MOUSEX/K,MY=MOUSEY/K," \
- "RX=RELMOUSEX/K,RY=RELMOUSEY/K," \
- "LM=LEFT_MOUSE/S,LMU=LEFT_MOUSE_UP/S,LMD=LEFT_MOUSE_DOWN," \
- "RM=RIGHT_MOUSE/S,RMU=RIGHT_MOUSE_UP/S,RMD=RIGHT_MOUSE_DOWN/S," \
- "D=DOUBLECLICK/S," \
- "AW=ACTIVATEWINDOW/K,AS=ACTIVATESCREEN/K,APS=ACTIVATEPUBSCREEN/K," \
- "PUL=POINTERUPPERLEFT/S," \
- "RAWKEY/N,CHARS/K," \
- "FN=FILENAME/K"
-
- #define TEMPLATE_HELP "InsertEvent V1.0 (c) by Gerhard Müller in 1993\n" \
- "[MOUSEX=<mouse x position in pixel>]\n" \
- "[MOUSEY=<mouse y position in pixel>]\n" \
- "[RELMOUSEX=<mouse x change in pixel>]\n" \
- "[RELMOUSEY=<mouse y change in pixel>]\n" \
- "[LEFT_MOUSE (simulates click with left mouse button)]\n" \
- "[LEFT_MOUSE_UP (simulates release of left mouse button)]\n" \
- "[LEFT_MOUSE_DOWN (simulates press of left mouse button)]\n" \
- "[RIGHT_MOUSE (simulates click with right mouse button)]\n" \
- "[RIGHT_MOUSE_UP (simulates release of right mouse button)]\n" \
- "[RIGHT_MOUSE_DOWN (simulates press of right mouse button)]\n" \
- "[DOUBLECLICK (simulates double-click with left mouse button)]\n" \
- "[ACTIVATEWINDOW=<windowtitle of window to activate, with *,?,etc.>]\n" \
- "[ACTIVATESCREEN=<screen name of screen to activate>]\n" \
- "[ACTIVATEPUBSCREEN=<public screen name of screen to activate>]\n" \
- "[POINTERUPPERLEFT=<set mouse to upper-left in active window>]\n" \
- "[RAWKEY=<rawkey-number>]\n" \
- "[CHARS=<string to insert>]\n" \
- "[FILENAME=<filename to use as input>]\n"
-
- typedef struct {
- UBYTE *mouse_x; UBYTE *mouse_y;
- UBYTE *mouse_x_rel; UBYTE *mouse_y_rel;
- ULONG *left_mouse;
- ULONG *left_mouse_up;
- ULONG *left_mouse_down;
- ULONG *right_mouse;
- ULONG *right_mouse_up;
- ULONG *right_mouse_down;
- ULONG *doubleclick;
- char *activatewindow; char *activatescreen; UBYTE *pubactivatescreen;
- ULONG *upperleft;
- LONG *rawkey; UBYTE *chars;
- UBYTE *filename;}
- ARGS;
-
- #define DEFAULT { NULL,NULL,NULL,NULL,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL }
-
- LONG rawkey=0;
-
- ARGS args = DEFAULT; /* here the arguments are stored */
-
- struct RDArgs *rda = NULL; /* for CLI-startup */
- UBYTE **ToolTypes; /* for WB-startup */
-
-
-
- struct IOStdReq *InputIO; /* I/O request block */
- struct MsgPort *InputMP; /* Message port */
- struct InputEvent *FakeEvent; /* InputEvent pointer */
- struct IEPointerPixel *NeoPix; /* New mouse position pointer */
- struct Screen *PubScreen; /* Screen pointer */
- BOOL OpenInputDevice = FALSE; /* To know what to free...*/
-
-
- int main(int arglen, char *argptr)
- {
- if(MyInit(arglen, argptr))
- {
- if(arglen)
- {
- // We were called from CLI
-
- // Handle Params
-
- UBYTE *mouse_x=NULL;
-
- if(args.activatescreen)
- {
- Screen_to_Front_and_activate(args.activatescreen);
- }
-
- if(args.pubactivatescreen)
- {
- PubScreen_to_Front_and_activate(args.pubactivatescreen);
- }
-
- if(args.activatewindow)
- {
- Window_Move_to_Front_and_activate(args.activatewindow);
- }
-
- if(args.upperleft)
- {
- Mouse_Move_to_LeftUpperActWindow();
- }
-
- if(args.mouse_y)
- {
- mouse_x=args.mouse_x;
- }
-
- if(args.mouse_x)
- {
- Mouse_SetPosition(mouse_x, args.mouse_y);
- }
-
- if(args.mouse_x_rel)
- {
- Mouse_SetPosition(args.mouse_x_rel, 0, TRUE);
- }
-
- if(args.mouse_x_rel)
- {
- Mouse_SetPosition(0, args.mouse_y_rel, TRUE);
- }
-
- if(args.left_mouse)
- {
- Mouse_Click(IECODE_LBUTTON);
- Mouse_Click(IECODE_LBUTTON|IECODE_UP_PREFIX);
- }
-
- if(args.left_mouse_up)
- {
- Mouse_Click(IECODE_LBUTTON|IECODE_UP_PREFIX);
- }
-
- if(args.left_mouse_down)
- {
- Mouse_Click(IECODE_LBUTTON);
- }
-
- if(args.right_mouse)
- {
- Mouse_Click(IECODE_RBUTTON);
- Mouse_Click(IECODE_RBUTTON|IECODE_UP_PREFIX);
- }
-
- if(args.right_mouse_up)
- {
- Mouse_Click(IECODE_RBUTTON|IECODE_UP_PREFIX);
- }
-
- if(args.right_mouse_down)
- {
- Mouse_Click(IECODE_RBUTTON);
- }
-
- if(args.doubleclick)
- {
- Mouse_Click(IECODE_LBUTTON);
- Mouse_Click(IECODE_LBUTTON|IECODE_UP_PREFIX);
- Mouse_Click(IECODE_LBUTTON);
- Mouse_Click(IECODE_LBUTTON|IECODE_UP_PREFIX);
- }
-
- if(args.rawkey)
- {
- Chars_InsertRawKey(*(args.rawkey));
- }
-
- if(args.chars)
- {
- Chars_InsertVanilla(args.chars);
- }
-
- if(args.filename)
- {
- File_Handle(args.filename);
- }
-
- }
- else
- {
- // We were called from WB
-
- // Take all arguements from ToolType-Array
-
- if(ToolTypes)
- {
- int x=0;
-
- while(ToolTypes[x])
- {
- Line_Handle(ToolTypes[x]);
-
- x++;
- }
- }
-
- /* Did we get any arguments passed in? */
-
- UBYTE FileName[256];
-
- WBStartup *WBenchMsg=(WBStartup *)argptr;
-
- if(WBenchMsg -> sm_NumArgs > 1)
- {
- LONG i;
-
- /* Run down the list of arguments. */
-
- for(i = 1 ; i < WBenchMsg -> sm_NumArgs ; i++)
- {
- /* Does the argument have a filelock attached? */
-
- if(WBenchMsg -> sm_ArgList[i] . wa_Lock)
- {
- /* Turn the filelock into a file name. */
-
- if(NameFromLock(WBenchMsg -> sm_ArgList[i] . wa_Lock, FileName,256))
- {
- AddPart(FileName, (UBYTE *)WBenchMsg ->sm_ArgList[i] . wa_Name, 256);
-
- /* We have a filename */
-
- Icon_Handle(FileName);
- }
- }
- }
- }
-
- }
- }
-
- OutputError();
-
- return RETURN_OK;
- }
-
- /*
- * Open some libraries and make the commandline-parsing
- *
- */
-
- BOOL MyInit(int alen, char *aptr)
- {
- BOOL ok=FALSE;
-
- /* Are we running under control of Kickstart 2.0 or higher? */
-
- if(SysBase -> LibNode . lib_Version < 37)
- {
- err.NotifyError("needs Workbench & Kickstart Version 2.04 and above !\n");
- return FALSE;
- }
-
-
- atexit(MyExit); // the function MyExit should be called at exit()-time
-
-
- /* open some libraries, not really needed in this programm, just to show how to do */
-
- if(IntuitionBase = (struct IntuitionBase *)OpenLibrary((UBYTE *)"intuition.library",37))
- {
- if(GfxBase = (struct GfxBase *)OpenLibrary((UBYTE *)"graphics.library",37))
- {
- if(GadToolsBase = OpenLibrary((UBYTE *)"gadtools.library",37))
- {
- if(UtilityBase = OpenLibrary((UBYTE *)"utility.library",37))
- {
- if(WorkbenchBase = OpenLibrary((UBYTE *)"workbench.library",37))
- {
- if(IconBase = OpenLibrary((UBYTE *)"icon.library",37))
- {
- if(CxBase = OpenLibrary((UBYTE *)"commodities.library",37))
- {
- if(IFFParseBase = OpenLibrary((UBYTE *)"iffparse.library",37))
- {
- if(AslBase = OpenLibrary((UBYTE *)"asl.library",37))
- {
- if(KeymapBase = (Device *)OpenLibrary((UBYTE *)"keymap.library", 0))
- {
- // we have all our libraries
- ok=TRUE;
- }
- else err.NotifyError("unable to open keymap.library !");
- }
- else err.NotifyError("unable to open asl.library !");
- }
- else err.NotifyError("unable to open iffparse.library !");
- }
- else err.NotifyError("unable to open commodities.library !");
- }
- else err.NotifyError("unable to open icon.library !");
- }
- else err.NotifyError("unable to open workbench.library !");
- }
- else err.NotifyError("unable to open utility.library !");
- }
- else err.NotifyError("unable to open gadtools.library !");
- }
- else err.NotifyError("unable to open graphics.library !");
- }
- else err.NotifyError("unable to open intuition.library !");
-
- if(!ok) return FALSE;
-
-
- /* normal startup-code.... */
-
- ok=FALSE;
-
- if(alen)
- {
- /* start from CLI */
- /* parse arguements */
-
- if(rda = (RDArgs *)AllocDosObject( DOS_RDARGS, NULL ))
- {
- rda->RDA_ExtHelp = (UBYTE *)TEMPLATE_HELP;
-
- if(ReadArgs( (UBYTE *)TEMPLATE, (LONG *) &args, rda ) )
- {
- /* Args erfolgreich gelesen */
-
- ok=TRUE;
- }
- else
- {
- err.DosError(IoErr(), "Error parsing commandline"); /* prints the appropriate err message */
- }
- }
- else
- err.NotifyError("Out of memory error !");
- }
- else
- {
- /* Workbench-Start */
-
- ToolTypes = (UBYTE **)ArgArrayInit((LONG)alen,(UBYTE **)aptr);
-
- if(ToolTypes)
- {
- ok=TRUE;
- }
- }
-
-
- if(!ok) return FALSE;
-
-
- /* open things that are necessary for our fake-events, look at
- Set_Mouse.c in rkrm/dev/input */
-
- if (InputMP = CreateMsgPort())
- {
- if (FakeEvent = (InputEvent *)AllocMem(sizeof(struct InputEvent),MEMF_PUBLIC))
- {
- if (NeoPix = (IEPointerPixel *)AllocMem(sizeof(struct IEPointerPixel),MEMF_PUBLIC))
- {
- if (InputIO = (IOStdReq *)CreateIORequest(InputMP,sizeof(struct IOStdReq)))
- {
- if (!OpenDevice((UBYTE *)"input.device",NULL,
- (struct IORequest *)InputIO,NULL))
- {
- OpenInputDevice=TRUE;
- ok=TRUE;
- }
- else
- err.NotifyError("Error: Could not open input.device");
- }
- else
- err.NotifyError("Error: Could not create IORequest");
- }
- else
- err.NotifyError("Error: Could not allocate memory for NeoPix");
- }
- else
- err.NotifyError("Error: Could not allocate memory for FakeEvent");
- }
- else
- err.NotifyError("Error: Could not create message port");
-
-
- return ok;
- }
-
-
- /*
- * This function gets called by exit(), look im MyInit() for corresponding atexit() call
- * frees all system-depended things
- */
-
-
- void MyExit()
- {
-
- if(OpenInputDevice)
- CloseDevice((struct IORequest *)InputIO);
-
- if(InputIO)
- DeleteIORequest(InputIO);
-
- if(NeoPix)
- FreeMem(NeoPix,sizeof(struct IEPointerPixel));
-
- if(FakeEvent)
- FreeMem(FakeEvent,sizeof(struct InputEvent));
-
- if(InputMP)
- DeleteMsgPort(InputMP);
-
-
- /* free WB-arguments */
-
- if( ToolTypes )
- {
- ArgArrayDone();
- }
-
-
- /* Free arguments passed by commandline allocated by ReadArgs() */
-
- if( rda )
- {
- FreeArgs( rda );
- FreeDosObject( DOS_RDARGS, rda );
- }
-
-
- /* close all our libraries */
-
- /* Close keymap.library */
-
- if(KeymapBase)
- CloseLibrary((struct Library *)KeymapBase);
-
- /* Close asl.library. */
-
- if(AslBase)
- CloseLibrary(AslBase);
-
- /* Close iffparse.library. */
-
- if(IFFParseBase)
- CloseLibrary(IFFParseBase);
-
- /* Close commodities.library. */
-
- if(CxBase)
- CloseLibrary(CxBase);
-
- /* Close icon.library. */
-
- if(IconBase)
- CloseLibrary(IconBase);
-
- /* Close workbench.library. */
-
- if(WorkbenchBase)
- CloseLibrary(WorkbenchBase);
-
- /* Close utility.library. */
-
- if(UtilityBase)
- CloseLibrary(UtilityBase);
-
- /* Close gadtools.library. */
-
- if(GadToolsBase)
- CloseLibrary(GadToolsBase);
-
- /* Close graphics.library. */
-
- if(GfxBase)
- {
- struct Library *dummy=(struct Library *)GfxBase;
- CloseLibrary(dummy);
- }
-
- /* Close intuition.library. */
-
- if(IntuitionBase)
- {
- struct Library *dummy=(struct Library *)IntuitionBase;
- CloseLibrary(dummy);
- }
-
- }
-
-
- /*
- * Output error-message if we have one
- *
- */
-
-
- void OutputError(void)
- {
- if(err)
- {
- char *err_mem=0;
- char *es;
- LONG err_nr=err.SetErrorNumber(0);
-
- if(es=err.have_error_string())
- {
- if(stdout)
- {
- cout << es << endl;
- }
- else
- ShowRequest(NULL, (UBYTE *)"Error:",
- (UBYTE *)es,
- (UBYTE *)"OK", err_nr);
-
- }
- else
- {
- if(err_nr)
- {
- if(stdout)
- cout << "Error-Number: " << err_nr << endl;
- else
- {
- ShowRequest(NULL, (UBYTE *)"Error:",
- (UBYTE *)"Error-Number %ld\n",
- (UBYTE *)"OK", err_nr);
- }
- }
- }
- }
-
- err.Clear();
- }
-
-
- void Mouse_SetPosition(UBYTE *x, UBYTE *y, BOOL relative=FALSE)
- {
- /* Set up IEPointerPixel fields */
-
- ULONG IBaseLock = LockIBase(0);
-
- NeoPix->iepp_Screen = IntuitionBase -> ActiveScreen;
-
- UnlockIBase(IBaseLock);
-
- NeoPix->iepp_Position.X = myatoi((char *)x); /* put pointer at x = 100 */
-
- NeoPix->iepp_Position.Y = myatoi((char *)y); /* put pointer at y = 200 */
-
- /* Set up InputEvent fields */
- FakeEvent->ie_EventAddress = (APTR)NeoPix; /* IEPointerPixel */
- FakeEvent->ie_NextEvent = NULL;
- FakeEvent->ie_Class = IECLASS_NEWPOINTERPOS; /* new mouse pos */
- FakeEvent->ie_SubClass = IESUBCLASS_PIXEL; /* on pixel */
- FakeEvent->ie_Code = IECODE_NOBUTTON;
-
- if(relative)
- FakeEvent->ie_Qualifier = IEQUALIFIER_RELATIVEMOUSE; /* absolute positioning */
- else
- FakeEvent->ie_Qualifier = NULL; /* absolute positioning */
-
- InputIO->io_Data = (APTR)FakeEvent; /* InputEvent */
- InputIO->io_Length = sizeof(struct InputEvent);
- InputIO->io_Command = IND_WRITEEVENT;
- DoIO((struct IORequest *)InputIO);
- }
-
- void Chars_InsertRawKey(LONG ch)
- {
-
- /* Set up InputEvent fields */
- FakeEvent->ie_EventAddress = NULL;
- FakeEvent->ie_NextEvent = NULL;
- FakeEvent->ie_Class = IECLASS_RAWKEY;
- FakeEvent->ie_SubClass = NULL;
- FakeEvent->ie_Code = ch;
- FakeEvent->ie_Qualifier = NULL; /* absolute positioning */
-
- InputIO->io_Data = (APTR)FakeEvent; /* InputEvent */
- InputIO->io_Length = sizeof(struct InputEvent);
- InputIO->io_Command = IND_WRITEEVENT;
- DoIO((struct IORequest *)InputIO);
-
- }
-
- void Chars_InsertVanilla(UBYTE *chs)
- {
- /* puts the given string into the input stream */
- int i;
- struct cq_pair {UBYTE code, qual;} raw_char;
-
- /* Set up InputEvent fields */
- FakeEvent->ie_EventAddress = NULL;
- FakeEvent->ie_NextEvent = NULL;
- FakeEvent->ie_Class = IECLASS_RAWKEY;
- FakeEvent->ie_SubClass = NULL;
-
- for(i=0; chs[i]!=0; i++)
- {
- MapANSI(&chs[i],(long int)1,(unsigned char *)&raw_char,1,NULL);
- FakeEvent->ie_Code = raw_char.code;
- FakeEvent->ie_Qualifier = raw_char.qual;
-
- InputIO->io_Data = (APTR)FakeEvent; /* InputEvent */
- InputIO->io_Length = sizeof(struct InputEvent);
- InputIO->io_Command = IND_WRITEEVENT;
- DoIO((struct IORequest *)InputIO);
- }
-
- for(int x=0; x<strlen((char *)chs); x++)
- {
-
- }
- }
-
- void File_Handle(UBYTE *filename)
- {
- BPTR fh;
-
- if(fh=Open(filename,MODE_OLDFILE))
- {
- UBYTE Buffer[200];
- UBYTE *buf;
-
- while(buf=FGets(fh, Buffer, 200))
- {
- Line_Handle(buf);
- }
-
- Close(fh);
- }
- else
- {
- UBYTE Buffer[250];
- sprintf(Buffer, (UBYTE *)"Unable to open file \"%s\"!", filename);
- err.NotifyError((char *)Buffer);
- OutputError();
- }
- }
-
- void Line_Handle(UBYTE *line)
- {
- static UBYTE *mouse_x=NULL;
-
- /* Search for "=" */
-
- UBYTE *after_equal=NULL;
-
- while((*line) && (( *line==' ') || (*line == '\t'))) line++;
- UBYTE *s=line;
-
- /* Skip comment lines */
-
- if( (*s=='#') || (*s=='|') || (*s==';') || (*s=='\n')) return;
-
- while(*s)
- {
- if(*s=='\n') *s=0;
-
- if( *s== '=')
- {
- *s=0;
- s++;
- after_equal=s;
- }
- else s++;
- }
-
- if(Stricmp((UBYTE *) "MOUSEX", line)==0)
- {
- mouse_x=after_equal;
- }
- else
- if(Stricmp((UBYTE *) "MOUSEY", line)==0)
- {
- Mouse_SetPosition(mouse_x, after_equal);
- }
- else
- if(Stricmp((UBYTE *) "LEFT_MOUSE_UP", line)==0)
- {
- Mouse_Click(IECODE_LBUTTON|IECODE_UP_PREFIX);
- }
- else
- if(Stricmp((UBYTE *) "LEFT_MOUSE_DOWN", line)==0)
- {
- Mouse_Click(IECODE_LBUTTON);
- }
- else
- if(Stricmp((UBYTE *) "LEFT_MOUSE", line)==0)
- {
- Mouse_Click(IECODE_LBUTTON);
- Mouse_Click(IECODE_LBUTTON|IECODE_UP_PREFIX);
- }
- else
- if(Stricmp((UBYTE *) "RIGHT_MOUSE_UP", line)==0)
- {
- Mouse_Click(IECODE_RBUTTON|IECODE_UP_PREFIX);
- }
- else
- if(Stricmp((UBYTE *) "RIGHT_MOUSE_DOWN", line)==0)
- {
- Mouse_Click(IECODE_RBUTTON);
- }
- else
- if(Stricmp((UBYTE *) "RIGHT_MOUSE", line)==0)
- {
- Mouse_Click(IECODE_RBUTTON);
- Mouse_Click(IECODE_RBUTTON|IECODE_UP_PREFIX);
- }
- else
- if(Stricmp((UBYTE *) "DOUBLECLICK", line)==0)
- {
- Mouse_Click(IECODE_LBUTTON);
- Mouse_Click(IECODE_LBUTTON|IECODE_UP_PREFIX);
- Mouse_Click(IECODE_LBUTTON);
- Mouse_Click(IECODE_LBUTTON|IECODE_UP_PREFIX);
- }
- else
- if(Stricmp((UBYTE *) "RAWKEY", line)==0)
- {
- Chars_InsertRawKey(myatoi((char *)after_equal));
- }
- else
- if(Stricmp((UBYTE *) "CHARS", line)==0)
- {
- Chars_InsertVanilla(after_equal);
- }
- else
- if(Stricmp((UBYTE *) "DELAY", line)==0)
- {
- Delay(myatoi((char *)after_equal));
- }
- else
- if(Stricmp((UBYTE *) "FILENAME", line)==0)
- {
- File_Handle(after_equal);
- }
- else
- if(Stricmp((UBYTE *) "RELMOUSEX", line)==0)
- {
- Mouse_SetPosition(after_equal,0,TRUE);
- }
- else
- if(Stricmp((UBYTE *) "RELMOUSEY", line)==0)
- {
- Mouse_SetPosition(0, after_equal,TRUE);
- }
- else
- if(Stricmp((UBYTE *) "ACTIVATEWINDOW", line)==0)
- {
- Window_Move_to_Front_and_activate((char *)after_equal);
- }
- else
- if(Stricmp((UBYTE *) "POINTERUPPERLEFT", line)==0)
- {
- Mouse_Move_to_LeftUpperActWindow();
- }
- else
- if(Stricmp((UBYTE *) "ACTIVATESCREEN", line)==0)
- {
- Screen_to_Front_and_activate((char *)after_equal);
- }
- else
- if(Stricmp((UBYTE *) "ACTIVATEPUBSCREEN", line)==0)
- {
- PubScreen_to_Front_and_activate(after_equal);
- }
- else
- {
- if(stdout)
- cout << "Ignoring unrecognize keyword " << (char *)line <<endl;
- else
- ShowRequest(NULL,(UBYTE *)"Error:",(UBYTE *)"Ignoring unrecognize keyword %s", (UBYTE *) "OK", line);
- }
- }
-
- void Mouse_Click(UWORD Code)
- {
- /* Set up InputEvent fields */
- FakeEvent->ie_EventAddress = NULL;
- FakeEvent->ie_NextEvent = NULL;
- FakeEvent->ie_Class = IECLASS_RAWMOUSE;
- FakeEvent->ie_SubClass = NULL;
- FakeEvent->ie_Code = Code;
- FakeEvent->ie_Qualifier = NULL; /* absolute positioning */
-
- InputIO->io_Data = (APTR)FakeEvent; /* InputEvent */
- InputIO->io_Length = sizeof(struct InputEvent);
- InputIO->io_Command = IND_WRITEEVENT;
- DoIO((struct IORequest *)InputIO);
- }
-
- int myatoi(char *str)
- {
- LONG x;
-
- if(str)
- {
- int len=strlen(str);
-
- if(len==StrToLong((STRPTR)str,&x))
- {
- return x;
- }
- else
- {
- char Buffer[250];
- sprintf((UBYTE *)Buffer, (UBYTE *)"Unable to convert \"%s\" to a number, taking default value 0",str);
- err.NotifyError(Buffer);
- OutputError();
- return 0;
- }
- }
- else
- return 0;
- }
-
- void Mouse_Move_to_LeftUpperActWindow(void)
- {
- ULONG IBaseLock = LockIBase(0);
-
- NeoPix->iepp_Screen = IntuitionBase -> ActiveScreen;
- NeoPix->iepp_Position.X = IntuitionBase ->ActiveWindow->LeftEdge;
- NeoPix->iepp_Position.Y = IntuitionBase ->ActiveWindow->TopEdge;
-
- UnlockIBase(IBaseLock);
-
- /* Set up InputEvent fields */
- FakeEvent->ie_EventAddress = (APTR)NeoPix; /* IEPointerPixel */
- FakeEvent->ie_NextEvent = NULL;
- FakeEvent->ie_Class = IECLASS_NEWPOINTERPOS; /* new mouse pos */
- FakeEvent->ie_SubClass = IESUBCLASS_PIXEL; /* on pixel */
- FakeEvent->ie_Code = IECODE_NOBUTTON;
-
- FakeEvent->ie_Qualifier = NULL; /* absolute positioning */
-
- InputIO->io_Data = (APTR)FakeEvent; /* InputEvent */
- InputIO->io_Length = sizeof(struct InputEvent);
- InputIO->io_Command = IND_WRITEEVENT;
- DoIO((struct IORequest *)InputIO);
- }
-
-
- void Window_Move_to_Front_and_activate(char *wintitle)
- {
- if(wintitle)
- {
- ULONG IBaseLock = LockIBase(0);
-
- struct Window *act_win = IntuitionBase -> ActiveScreen -> FirstWindow;
-
- UBYTE *Buffer= (UBYTE *)AllocVec(strlen(wintitle)+10,MEMF_CLEAR);
- if(Buffer)
- {
- Window *found=NULL;
-
- ParsePattern((UBYTE *)wintitle, Buffer, strlen(wintitle)+10);
-
- if(act_win)
- {
- while(!found && act_win)
- {
- if(act_win->Title)
- {
- if(MatchPattern(Buffer, act_win->Title))
- {
- found=act_win;
- }
- }
- act_win=act_win->NextWindow;
- }
- }
-
- UnlockIBase(IBaseLock);
-
- if(found)
- {
- ActivateWindow(found);
- if(!(found->Flags & WFLG_BACKDROP))
- WindowToFront(found);
- }
-
- FreeVec(Buffer);
- }
- }
- }
-
- void Screen_to_Front_and_activate(char *screentitle)
- {
- if(screentitle)
- {
- ULONG IBaseLock = LockIBase(0);
-
- struct Screen *act_scr = IntuitionBase -> FirstScreen;
-
- UBYTE *Buffer= (UBYTE *)AllocVec(strlen(screentitle)+10,MEMF_CLEAR);
- if(Buffer)
- {
- Screen *found=NULL;
-
- ParsePattern((UBYTE *)screentitle, Buffer, strlen(screentitle)+10);
-
- if(act_scr)
- {
- while(!found && act_scr)
- {
- if(act_scr->Title)
- {
- if(MatchPattern(Buffer, act_scr->Title))
- {
- found=act_scr;
- }
- }
- act_scr=act_scr->NextScreen;
- }
- }
-
- UnlockIBase(IBaseLock);
-
- if(found)
- {
- ScreenToFront(found);
- if(found->FirstWindow)
- {
- ActivateWindow(found->FirstWindow);
- }
- }
-
- FreeVec(Buffer);
- }
- }
- }
-
- void PubScreen_to_Front_and_activate(UBYTE *pubscreentitle)
- {
- if(pubscreentitle)
- {
- Screen *scr;
- if(scr=LockPubScreen(pubscreentitle))
- {
- ScreenToFront(scr);
- if(scr->FirstWindow)
- {
- ActivateWindow(scr->FirstWindow);
- }
-
- UnlockPubScreen(NULL, scr);
- }
- }
- }
-
- void Icon_Handle(UBYTE *filename)
- {
- struct DiskObject *Icon;
-
- if(Icon = GetDiskObject(filename))
- {
- UBYTE **argptr=(UBYTE **)(Icon -> do_ToolTypes);
-
- int x=0;
-
- while(argptr[x])
- {
- Line_Handle(argptr[x]);
- x++;
- }
- }
- }
-