Sign in to follow this  
Followers 0
Lemonadez

Hi.

19 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

DELETE ME...I READ THE POST WRONG

Edited by kabalarian

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
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.

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

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())

Share this post


Link to post
Share on other sites

Huh, sorry about that extra endif. I accidently copied a little too far into my code :whistle: . As far as "doing something" I put that little snit bit of code as an example the Send command should be removed and replaced with your own stuff.

Share this post


Link to post
Share on other sites

i got error about this line

HotKeySet("^x", "FunRuler")

Share this post


Link to post
Share on other sites

Change the FunRuler to FunCommand, I'll fix that above too


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

thanks now its working :whistle: i appreciate for all ur help...dunno how to spell i suck at english spelling :dance:....

thanks!

Share this post


Link to post
Share on other sites

lol u spelled appreciate right

Share this post


Link to post
Share on other sites

lol u spelled appreciate right

<{POST_SNAPBACK}>

cuz i google it LOL :(:D:D :D :D:whistle::dance::dance:

Share this post


Link to post
Share on other sites

it would be googled it not google it :whistle: lol

Share this post


Link to post
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
Sign in to follow this  
Followers 0