Jump to content

Hi.


Recommended Posts

Is it possible to do macro on certain program?

Example: I run the autoit and the command just press ctrl+x

and the exe name of the program WoW.exe

then im on other games like counter strike...can autoit still pressing ctrl+x on WoW.exe?

and the Ctrl+X -> must not work on counter strike...only on wow.exe

is that possible....

thanks

Link to comment
Share on other sites

Yup

try the Winactive command, it detects what app you are currently in so if you put an if statment you can get...

Func FunCommand()
    If WinActive("Wow") Then
        mouseclick("Right")
        Send("{Down},{Down},{Right},{Enter}")
        mouseclick("Left")
    Else
            HotKeySet("^x")
            Send("^x")
            HotKeySet("^x", "FunRuler")
        Endif
    Endif
Endif
EndFunc

This is assuming that ^x fires off the function "FunCommand". The second portion of the if the statement basically send ^x to the screen so any app you are using that actually uses ctrl+x would still fire off.

Hope this helps

Link to comment
Share on other sites

confusing....but i go try..

ty

EDIT:

give me error

Posted Image

Can we do it like? im playing counter strike and my other game is minimized but still it keep pressing ctrl+x on that game...

i try to remove endif...but the program dont open at all...just close fast.

Edited by Lemonadez
Link to comment
Share on other sites

Func FunCommand()
    If WinActive("Wow") Then
        mouseclick("Right")
        Send("{Down},{Down},{Right},{Enter}")
        mouseclick("Left")
    Else
            HotKeySet("^x")
            Send("^x")
            HotKeySet("^x", "FunRuler")
        Endif
EndFunc

... u had 3 endifs

Edited by thatsgreat2345
Link to comment
Share on other sites

removed the extra endif statements

Func FunCommand()
    If WinActive("Wow") Then
        MouseClick("Right")
        Send("{Down},{Down},{Right},{Enter}")
        MouseClick("Left")
    Else
        HotKeySet("^x")
        Send("^x")
        HotKeySet("^x", "FunRuler")
    EndIf
EndFunc  ;==>FunCommand

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

this script doesnt work at all it just close down everytime u run it...example

Func FunCommand()
    If WinActive("Notepad") Then
        MouseClick("Right")
        Send("{Down},{Down},{Right},{Enter}")
        MouseClick("Left")
    Else
        HotKeySet("x")
        Send("x")
        HotKeySet("x", "FunRuler")
    EndIf
EndFunc ;==>FunCommand

i minimize my notepad....it doesnt and went to im browsing on internet...on notepad it doesnt even type xxxxxxxxxx and also the script just close down...I copy it and save it as blabla.au3 ->then run script...it doesnt run at all

Link to comment
Share on other sites

what are you trying to do i thought this was for wow the proper script is

Func FunCommand()
    If WinActive("Wow") Then
        MouseClick("Right")
        Send("{Down},{Down},{Right},{Enter}")
        MouseClick("Left")
    Else
        HotKeySet("^x")
        Send("^x")
        HotKeySet("^x", "FunRuler")
    EndIf
EndFunc;==>FunCommand

u forgot the ^x for the ctrl x but what are u doing and for notepad it wouldnt be notepad it would be

Untitled - Notepad or whatever the title of that window is

Edited by thatsgreat2345
Link to comment
Share on other sites

k the game called Monster and me...and active windows its "Monster&Me" without the "....i try to load it..but it doesnt work (i mean it just close by it self) it doesnt run at all

Func FunCommand()
    If WinActive("Monster&Me") Then
        MouseClick("Right")
        Send("{Down},{Down},{Right},{Enter}")
        MouseClick("Left")
    Else
        HotKeySet("^x")
        Send("^x")
        HotKeySet("^x", "FunRuler")
    EndIf
EndFunc;==>FunCommand
Edited by Lemonadez
Link to comment
Share on other sites

That's because your script isn't programmed to do anything -- you define a function so that AutoIt knows about it when you call it.

Add this above your current code:

HotkeySet("^z", "FunCommand")
HotkeySet("^x", "Quit")
While (1)
    Sleep(0x7FFFFFFF)
WEnd

Func Quit()
    Exit
EndFunc

; Remaining code goes here

Ctrl+Z calls FunCommand(); Ctrl+X quits the script. Feel free to change the keys.

Link to comment
Share on other sites

LxP, ^x is sent by that one function...so setting it to close may not help him.

#region functions
Func FunCommand()
    If WinActive("Wow") Then
        MouseClick("Right")
        Send("{Down},{Down},{Right},{Enter}")
        MouseClick("Left")
    Else
        HotKeySet("^x")
        Send("^x")
        HotKeySet("^x", "FunCommand")
    EndIf
EndFunc;==>FunCommand

Func Quit()
    Exit
EndFunc
#endregion

HotkeySet("^x", "FunCommand")
HotkeySet("^z", "Quit")
While (1)
    Sleep(0x7FFFFFFF)
WEnd

; Remaining code goes here

I reversed the hotkeys, I would check to make sure none of those games use the Ctrl-z in game, else Ctrl+Shift+Del maybe?

Edited by MSLx Fanboy

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

Sorry about the confusion here is code that, when you are in a program called Wow a dialoge box will pop up if you press i. If you are not in wow you will simply type i.

HotKeySet("i", "FunCommand")
While 1
    Sleep(100)
WEnd

Func FunCommand()
If WinActive("Wow") Then
    MsgBox(0,"Test", "You are in Wow!!!")

Else
    HotKeySet("i")
    Send("i")
    HotKeySet("i", "FunCommand")
Endif
Endfunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...