Jump to content



Photo

Setting Up Hotkey Activation And Deactivation


  • Please log in to reply
20 replies to this topic

#1 Onikage

Onikage

    Seeker

  • New Members
  • 8 posts

Posted 25 January 2004 - 11:34 PM

Ok so I'm using Z33to's script, but I notice that sometimes i want to stop the script and do something else. How would i use the Hotkey command so that the script does not start up until i hit something like say CTRL+` . Also it stops if i hit it again and I can always start it up again without exiting FFXI if i repeat the keystroke. Thanks.





#2 CyberSlug

CyberSlug

    Overwhelmed with work....

  • MVPs
  • 3,587 posts

Posted 26 January 2004 - 12:53 AM

The easiest way is to use a key that toggles whether the script is running or paused:

Here's an example from the soon-to-be updated help docs. Change the hotkeys to whatever you want; you may not even want the termination hotkey.

Edit: If you want the script to begin in a paused state, then change $paused = 0 to $paused = 1

Plain Text         
; Press Esc to terminate script, Pause/Break to pause Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") $Paused = 0 While 1;infinite loop     If $Paused then         Sleep(1000);avoid maxing out cpu     Else       ; MAIN BODY OF SCRIPT GOES HERE     EndIf Wend Func TogglePause()     $Paused = NOT $Paused EndFunc Func Terminate()     MsgBox(4096,"", "The End")     Exit EndFunc

Edited by CyberSlug, 26 January 2004 - 12:57 AM.

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

#3 Onikage

Onikage

    Seeker

  • New Members
  • 8 posts

Posted 26 January 2004 - 04:21 AM

Yes that sounds very good. Just one problem, I'm trying to modify the script i mentioned. When I insert that code and also when I was experimenting with putting it in a loop it keeps saying no terminating statement for whatever the loop I put in. I guess it is not distinguishing what start and end statements belong together. I can't use brackets like other languages? (e.g. C++) so it knows what is for what. For example in the following code it says "Line 48: EndIf with no If"

Plain Text         
; Made by z33to ; Version 0.75 ; Press Esc to terminate script, Pause/Break to pause Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("^`", "Terminate") $Paused = 0 While 1;infinite loop    If $Paused then        Sleep(1000); avoid maxing out cpu    Else      Sleep(100000);give time to open FFXI      $fisha = 2;      $biteyes = 0;      $bite = 0;      $failsafe=0;      $sortnow = 1;      $logtime = 0;      WinWaitActive("FFXiApp");      While $fisha > 1        AutoItSetOption("SendKeyDelay", 20);        If $sortnow = 1 Then        autosort()        Send("/equip ammo ""Insect Ball""{ENTER}");        Else        Sleep(Random(4000,6000));        EndIf        Send("/fish{ENTER}"); fishing macro        $biteyes = 0;        $failsafe = 0;        $sortnow = 0;        Do          Sleep(250);            If PixelGetColor(228,735) = 16777215 AND PixelGetColor(200,735) = 16777215 _          AND PixelGetColor(175, 735) = 16777215 Then AutoItSetOption("SendKeyDelay", 20);          Sleep(Random(2000,3000));          Send("{ENTER}");          Sleep(2500);          If PixelGetColor(128,735) = 16777215 AND PixelGetColor(74,1168) = 16777215 _          Then $logtime = $logtime + 1;          EndIf          Sleep(9000);          $biteyes = 1;          $sortnow = 1;          EndIf            If PixelGetColor(194,735) = 16777215 Then _          AutoItSetOption("SendKeyDelay", 20);          $biteyes = 1;          Sleep(9000);          EndIf                $failsafe = $failsafe+1;          If $failsafe = 175 Then          $biteyes = 1;          EndIf          Until $biteyes = 1      Sleep(12000);      If $logtime = 2 Then $logtime = 0;      Send("/logout{ENTER}");      $fisha = 1      EndIf      WEnd      Func autosort()      AutoItSetOption("SendKeyDelay", 85);slow key delay a bit      Send("{NUMPADSUB}");      Sleep(1000);      MouseMove(973,109,3);      Sleep(500);      Send("{ENTER}");      Sleep(500);      Send("{NUMPADADD}");      Sleep(1000);      Send("{ENTER}");      Sleep(1000);      MouseMove(964,121,3);      Sleep(500);      Send("{ENTER}");      Sleep(500);      Send("{ESC}");      Sleep(500);      Send("{ESC}");      Sleep(500);        EndFunc     EndIf Wend Func TogglePause()    $Paused = NOT $Paused EndFunc Func Terminate()    Exit EndFunc ; Made by z33to

Edited by Onikage, 26 January 2004 - 04:43 AM.


#4 CyberSlug

CyberSlug

    Overwhelmed with work....

  • MVPs
  • 3,587 posts

Posted 26 January 2004 - 07:53 AM

EDIT: Ah, the problem is probably Func autosort(). It should be put outside of the While...WEndLoop.

Hmm..
1) Try the most recent version of AutoIt. Some features have been changing recently. (In general, older scripts should work with newer AutoIt releases.)

2) Maybe try wrapping z33to's script in a function:

Plain Text         
; Press Esc to terminate script, Pause/Break to pause Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("^`", "Terminate") $Paused = 0 While 1;infinite loop    If $Paused then        Sleep(1000);avoid maxing out cpu    Else        z33toScript()    EndIf Wend Func TogglePause()    $Paused = NOT $Paused EndFunc Func Terminate()    MsgBox(4096,"", "The End")    Exit EndFunc Func z33toScript()     $fisha = 2;     $biteyes = 0;     $bite = 0;     $failsafe=0;     $sortnow = 1;     $logtime = 0;     WinWaitActive("FFXiApp"); ;... ; etc etc ; ... EndFunc Func autosort()     AutoItSetOption("SendKeyDelay", 85);slow key delay a bit     Send("{NUMPADSUB}");     Sleep(1000);     MouseMove(973,109,3);     Sleep(500);     Send("{ENTER}"); ;... ; etc etc ; ... EndFunc

Edited by CyberSlug, 26 January 2004 - 07:57 AM.

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

#5 Onikage

Onikage

    Seeker

  • New Members
  • 8 posts

Posted 26 January 2004 - 08:00 AM

Hmmm see anything wrong with this? Line 60 EndIf without If. Btw, using latest stable version of AutoIt.

Plain Text         
; Made by z33to ; Version 0.75 ; Press Esc to terminate script, Pause/Break to pause Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("^`", "Terminate") $Paused = 0 While 1;infinite loop    If $Paused then        Sleep(1000); avoid maxing out cpu    Else      z33toScript()    EndIf Wend Func TogglePause()    $Paused = NOT $Paused EndFunc Func Terminate()    Exit EndFunc Func z33toScript() Sleep(100000);give time to open FFXI      $fisha = 2;      $biteyes = 0;      $bite = 0;      $failsafe=0;      $sortnow = 1;      $logtime = 0;      WinWaitActive("FFXiApp");      While $fisha > 1        AutoItSetOption("SendKeyDelay", 20);        If $sortnow = 1 Then        autosort()        Send("/equip ammo ""Insect Ball""{ENTER}");        Else        Sleep(Random(4000,6000));        EndIf        Send("/fish{ENTER}"); fishing macro        $biteyes = 0;        $failsafe = 0;        $sortnow = 0;        Do          Sleep(250);            If PixelGetColor(228,735) = 16777215 AND PixelGetColor(200,735) = 16777215 _          AND PixelGetColor(175, 735) = 16777215 Then AutoItSetOption("SendKeyDelay", 20);          Sleep(Random(2000,3000));          Send("{ENTER}");          Sleep(2500);          If PixelGetColor(128,735) = 16777215 AND PixelGetColor(74,1168) = 16777215 _          Then $logtime = $logtime + 1;          EndIf          Sleep(9000);          $biteyes = 1;          $sortnow = 1;          EndIf          If PixelGetColor(194,735) = 16777215 Then _          AutoItSetOption("SendKeyDelay", 20);          $biteyes = 1;          Sleep(9000);          EndIf                $failsafe = $failsafe+1;          If $failsafe = 175 Then _          $biteyes = 1;          EndIf          Until $biteyes = 1      Sleep(12000);      If $logtime = 2 Then $logtime = 0;      Send("/logout{ENTER}");      $fisha = 1      EndIf      WEnd      Func autosort()      AutoItSetOption("SendKeyDelay", 85);slow key delay a bit      Send("{NUMPADSUB}");      Sleep(1000);      MouseMove(973,109,3);      Sleep(500);      Send("{ENTER}");      Sleep(500);      Send("{NUMPADADD}");      Sleep(1000);      Send("{ENTER}");      Sleep(1000);      MouseMove(964,121,3);      Sleep(500);      Send("{ENTER}");      Sleep(500);      Send("{ESC}");      Sleep(500);      Send("{ESC}");      Sleep(500);        EndFunc EndFunc ; Made by z33to

Edited by Onikage, 26 January 2004 - 08:08 AM.


#6 CyberSlug

CyberSlug

    Overwhelmed with work....

  • MVPs
  • 3,587 posts

Posted 26 January 2004 - 08:14 AM

I should clarify: Move Func autosort() outside of all functions. (Do not have any nested functions)
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

#7 Onikage

Onikage

    Seeker

  • New Members
  • 8 posts

Posted 26 January 2004 - 08:22 AM

Ok so the script runs now. Though the hotkeys and pausing doesn't seem to be working hahaha. This is sad. Wouldn't it forever get stuck in z33t's script portion and never do the check for $PAUSE because his is looping?

#8 CyberSlug

CyberSlug

    Overwhelmed with work....

  • MVPs
  • 3,587 posts

Posted 26 January 2004 - 09:13 AM

I think we're getting there.... I'm not a gamer, so I usually avoid such questions :whistle:

IDEA ONE:
Change TogglePause to this:
Func TogglePause()      MsgBox(0,"","Press OK")      sleep(1000) EndFunc

This makes a message box pop up. The script will resume 1 second after you press OK.


IDEA TWO:
Try adding the following statements at places within the main game script:
If $Paused Then PauseLoop()
At the very end of the code (after the very last EndFunc) add this:
Func PauseLoop()    While $Paused       sleep(500)    WEnd EndFunc


Note: These ideas are intended to be implemented separately!

Edited by CyberSlug, 26 January 2004 - 09:19 AM.

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

#9 CyberSlug

CyberSlug

    Overwhelmed with work....

  • MVPs
  • 3,587 posts

Posted 26 January 2004 - 09:47 AM

I see that gaming scripts are not my expertise. This is my very last try:

Plain Text         
Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") AutoItSetOption("SendKeyDelay", 20); While $fisha > 1 IF $Paused THEN;*****      sleep(1000)       ELSE;*****  If $sortnow = 1 Then  autosort()  Send("/equip ammo ""Insect Ball""{ENTER}");  Else  Sleep(Random(4000,6000));  EndIf  Send("/fish{ENTER}"); fishing macro  $biteyes = 0;  $failsafe = 0;  $sortnow = 0;  Do    Sleep(250);    If PixelGetColor(228,735) = 16777215 AND PixelGetColor(200,735) = 16777215 _    AND PixelGetColor(175, 735) = 16777215 Then AutoItSetOption("SendKeyDelay", 20);    Sleep(Random(2000,3000));    Send("{ENTER}");    Sleep(2500);    If PixelGetColor(128,735) = 16777215 AND PixelGetColor(74,1168) = 16777215 _    Then $logtime = $logtime + 1;    EndIf    Sleep(9000);    $biteyes = 1;    $sortnow = 1;    EndIf    If PixelGetColor(194,735) = 16777215 Then _    AutoItSetOption("SendKeyDelay", 20);    $biteyes = 1;    Sleep(9000);    EndIf    $failsafe = $failsafe+1;    If $failsafe = 175 Then    $biteyes = 1;    EndIf  Until $biteyes = 1 Sleep(12000); If $logtime = 2 Then $logtime = 0; Send("/logout{ENTER}"); $fisha = 1 EndIf ENDIF;***** WEnd Func autosort()     AutoItSetOption("SendKeyDelay", 85);slow key delay a bit     Send("{NUMPADSUB}");     Sleep(1000);     MouseMove(973,109,3);     Sleep(500);     Send("{ENTER}");     Sleep(500);     Send("{NUMPADADD}");     Sleep(1000);     Send("{ENTER}");     Sleep(1000);     MouseMove(964,121,3);     Sleep(500);     Send("{ENTER}");     Sleep(500);     Send("{ESC}");     Sleep(500);     Send("{ESC}");     Sleep(500); EndFunc     Func TogglePause()    $Paused = NOT $Paused EndFunc Func Terminate()    MsgBox(4096,"", "The End")    Exit EndFunc

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

#10 Onikage

Onikage

    Seeker

  • New Members
  • 8 posts

Posted 27 January 2004 - 01:07 AM

Ah I was able to do it using your IDEA #2. Here is the result in case anyone else wants to use it. Basically its z33tos script with a modification that allows pausing. My preference was to pause it using CTRL+P, so that is what its setup for. You can change the hotkey to be anything that fits your taste. You unpause the script with the same key. This will stop the annoyance of having to make a quick run to the AH and it constantly typing /fish or opening your inventory. Big thanks to z33to for the script in the first place and to CyberSlug for pretty much writing the addition haha. Keydelay has also been increased because it was typing too fast sometimes. It would hit enter then try to type "/fish" , but sometimes it would end up with just sh or something.

Plain Text         
; Original Script by z33to Global $Paused HotKeySet("^p", "TogglePause") Sleep(100000);give time to open FFXI $fisha = 2; $biteyes = 0; $bite = 0; $failsafe=0; $sortnow = 1; $logtime = 0; WinWaitActive("FFXiApp"); While $fisha > 1 AutoItSetOption("SendKeyDelay", 40); If $Paused Then PauseLoop() If $sortnow = 1 Then autosort() Send("/equip ammo ""Insect Ball""{ENTER}"); Else Sleep(Random(4000,6000)); EndIf If $Paused Then PauseLoop() Send("/fish{ENTER}"); fishing macro $biteyes = 0; $failsafe = 0; $sortnow = 0; Do  Sleep(250);    If PixelGetColor(228,735) = 16777215 AND PixelGetColor(200,735) = 16777215 AND PixelGetColor(175,735) = 16777215 Then  AutoItSetOption("SendKeyDelay", 40);   Sleep(Random(2000,3000));  Send("{ENTER}");  Sleep(2500);  If PixelGetColor(128,735) = 16777215 AND PixelGetColor(74,1168) = 16777215 Then    $logtime = $logtime + 1;  EndIf   Sleep(9000);  $biteyes = 1;  $sortnow = 1;  EndIf    If PixelGetColor(194,735) = 16777215 Then  AutoItSetOption("SendKeyDelay", 40);  $biteyes = 1;  Sleep(9000);  EndIf        $failsafe = $failsafe+1;  If $failsafe = 175 Then  $biteyes = 1;  EndIf  If $Paused Then PauseLoop()   Until $biteyes = 1 Sleep(12000); If $logtime = 2 Then $logtime = 0; Send("/logout{ENTER}"); $fisha = 1 EndIf WEnd Func autosort() AutoItSetOption("SendKeyDelay", 85);slow key delay a bit Send("{NUMPADSUB}"); Sleep(1000); MouseMove(973,109,3); Sleep(500); Send("{ENTER}"); Sleep(500); Send("{NUMPADADD}"); Sleep(1000); Send("{ENTER}"); Sleep(1000); MouseMove(964,121,3); Sleep(500); Send("{ENTER}"); Sleep(500); Send("{ESC}"); Sleep(500); Send("{ESC}"); Sleep(500); EndFunc Func TogglePause()   $Paused = NOT $Paused EndFunc Func PauseLoop()   While $Paused      sleep(1000)   WEnd EndFunc


#11 Deathgigas

Deathgigas

    Seeker

  • Active Members
  • 13 posts

Posted 27 January 2004 - 02:10 AM

There's an mistake that I think I found the solution to in that, even though I'm a complete noob to scripting. Since this is a forum you can't cram everything into one line and instead the line gets linebreak/tab/whatever you call it.

Plain Text         
If $Paused Then PauseLoop() Send("/fish{ENTER}"); fishing macro $biteyes = 0; $failsafe = 0; $sortnow = 0; Do Sleep(250); If PixelGetColor(228,735) = 16777215 AND PixelGetColor(200,735) = 16777215 AND PixelGetColor(175,735) = 16777215 Then AutoItSetOption("SendKeyDelay", 40);  Sleep(Random(2000,3000)); Send("{ENTER}"); Sleep(2500); If PixelGetColor(128,735) = 16777215 AND PixelGetColor(74,1168) = 16777215 Then   $logtime = $logtime + 1; EndIf  Sleep(9000); $biteyes = 1; $sortnow = 1; EndIf


This section has the mistake, where it shows AND having its own line, it shouldn't.

If PixelGetColor(228,735) = 16777215 AND PixelGetColor(200,735) = 16777215 AND PixelGetColor(175,735) = 16777215 Then


Put all this stuff into one line. Don't know how to explain it any easier. Notepad will let you do this, not a forum.

Edited by Deathgigas, 27 January 2004 - 02:12 AM.


#12 Deathgigas

Deathgigas

    Seeker

  • Active Members
  • 13 posts

Posted 27 January 2004 - 02:36 AM

Works really well I like it. Though I had to make some changes to the timing since it isn't that time efficient. Changing the Sleep(Random(2000,3000)); to Sleep(Random(1000,1100)); is much faster

Not sure how this pausing thing works, when i do ctrl+p it does /party chatmode. I'm gonna have to figure out a key that isn't used in-game.

Good job and thanks to the both of you.

#13 Onikage

Onikage

    Seeker

  • New Members
  • 8 posts

Posted 28 January 2004 - 06:27 AM

It seems that FFXI also doesn't allow certain key commands to be put through. Experiment with a hotkey combo but some are not working for me just to let you know.

#14 LifestoneExpress

LifestoneExpress

    Seeker

  • Active Members
  • 15 posts

Posted 28 January 2004 - 08:23 PM

I can not seem to get the Pause / Unpause toggle to work, at all.


The macros themselves run flawlessly, very nice work.


Both Z33to's and Onikage's / Cybor Slug's rewrite. Both work perfectly, exept for the actual ability to pause.



I am using the newest Beta 3.0.90 and this is the first time i have ever tried to use Auto It. Is there sometihng i need to DL to enable using hotkeys? Or did that come in the install of Beta 3.0.90.


Any info is appreciated. Great work btw too.

#15 evl

evl

    Seeker

  • Active Members
  • 11 posts

Posted 29 January 2004 - 11:34 AM

I have the same problem with Hotkeys also.
The only progress I made was, using the earlier methods I was able to start the game / script PAUSED and unpause it when i wanted, but after that I was not able to pause it. Copying the code exact I am still unable to get hotkeys to function properly. Using .90 / xp Pro / Hotkeys set as {F11} and {F12} - Also tried {RALT} and {RCTRL}. No dice.

#16 saltytaco

saltytaco

    Seeker

  • Active Members
  • 13 posts

Posted 29 January 2004 - 06:05 PM

Has anyone though about using a get pixel command for starting stopping?
Say you just use the /echo and type ***

Have the script grab the third * and the color and that will do an if then to start, stop. It's not actaully a hot key, but it would start and stop the script, right?

#17 HBD

HBD

    Seeker

  • New Members
  • 7 posts

Posted 29 January 2004 - 06:30 PM

That seems like a really good idea, since I can't get any Hotkey to work through FFXI.

#18 dierdre

dierdre

    Seeker

  • Active Members
  • 12 posts

Posted 29 January 2004 - 07:35 PM

^o worked for me, though I found that there was assorted weirdness with the script. The original is annoying since you can't turn it off, though. I'm going to mess with this code and see if I can polish it down into a fish catching machine ....

#19 HBD

HBD

    Seeker

  • New Members
  • 7 posts

Posted 29 January 2004 - 11:53 PM

Alright, I was trying to find some way to make the pause toggle with PixelGetColor, and got:

Plain Text         
; Original Script by z33to Global $Paused Sleep(100000);give time to open FFXI $fisha = 2; $biteyes = 0; $bite = 0; $failsafe=0; $sortnow = 1; $logtime = 0; WinWaitActive("FFXiApp"); While $fisha > 1 AutoItSetOption("SendKeyDelay", 40); If PixelGetColor(24,740) = 11534335 AND PixelGetColor(33,740) = 11730943 AND PixelGetColor(42,740) = 11010047 Then TogglePause() EndIf If $Paused Then PauseLoop() If $sortnow = 1 Then autosort() Send("/equip ammo ""Insect Ball""{ENTER}"); Send("/equip range ""Carbon Fish. Rod""{ENTER}"); Else Sleep(Random(4000,6000)); EndIf If $Paused Then PauseLoop() Send("/fish{ENTER}"); fishing macro $biteyes = 0; $failsafe = 0; $sortnow = 0; Do Sleep(250); If PixelGetColor(228,735) = 16777215 AND PixelGetColor(200,735) = 16777215 AND PixelGetColor(175,735) = 16777215 Then AutoItSetOption("SendKeyDelay", 40);  Sleep(Random(2000,3000)); Send("{ENTER}"); Sleep(2500); If PixelGetColor(128,735) = 16777215 AND PixelGetColor(74,1168) = 16777215 Then   $logtime = $logtime + 1; EndIf  Sleep(9000); $biteyes = 1; $sortnow = 1; EndIf If PixelGetColor(194,735) = 16777215 Then AutoItSetOption("SendKeyDelay", 40); $biteyes = 1; Sleep(9000); EndIf     $failsafe = $failsafe+1; If $failsafe = 175 Then $biteyes = 1; EndIf If $Paused Then PauseLoop() Until $biteyes = 1 Sleep(12000); If $logtime = 2 Then $logtime = 0; Send("/logout{ENTER}"); $fisha = 1 EndIf WEnd Func autosort() AutoItSetOption("SendKeyDelay", 85);slow key delay a bit Send("{NUMPADSUB}"); Sleep(1000); MouseMove(973,109,3); Sleep(500); Send("{ENTER}"); Sleep(500); Send("{NUMPADADD}"); Sleep(1000); Send("{ENTER}"); Sleep(1000); MouseMove(964,121,3); Sleep(500); Send("{ENTER}"); Sleep(500); Send("{ESC}"); Sleep(500); Send("{ESC}"); Sleep(500); EndFunc Func TogglePause()  Send("/echo Pause");  $Paused = NOT $Paused EndFunc Func PauseLoop()  While $Paused     sleep(1000)  WEnd EndFunc


But it still won't pause. Won't even do the /echo pause. Any ideas?

#20 Deathgigas

Deathgigas

    Seeker

  • Active Members
  • 13 posts

Posted 30 January 2004 - 02:18 AM

Not sure how this echo thing works but maybe sending a tell to yourself, /t whoever Pause




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users