Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

My first program. I could use some pointers.


  • Please log in to reply
26 replies to this topic

#1 Abacusrex

Abacusrex

    Seeker

  • Active Members
  • 14 posts

Posted 26 January 2012 - 08:19 PM

Hello, Autoit forum members!

I have a somewhat complicated program I would like to execute. I'll write the algorithm (is algorithm the right word?) down and you can tell me if Autoit will actually be able to achieve what I desire. If it does, I would really appreciate any help so I could get the program up and running as soon as possible.

Alright, to start off I'll explain what the program will be used for. I have an entertainment room (Panasonic GT30 65" plasma, blu-ray, surround-system, etc...) and recently I got my computer a new graphics card and have been playing video games using that, instead of my Xbox 360. I routed a cable from my PC to my entertainment room and was able to get my games working with my entertainment system. The problem is bringing a keyboard and mouse into the entertainment room is clunky and bothersome. My computer is in a separate room. What I would like to do is use my Xbox 360 controller. I bought an Xbox 360 PC receiver and it works great. I can now use one of my wireless Xbox 360 controller with my computer in the entertainment room.

I downloaded a program called Xpadder which allows me to emulate a keyboard/mouse on the Xbox 360 controller. I also downloaded a program called XBMC (Xbox Media Center) which makes for easy navigation with the Xbox 360 controller due to it's Xbox 360 dashboard type design. I use Xpadder to control the Xbox 360 controller from within XBMC.

Here's where it gets tricky. There are some games (Just Cause 2...) that I prefer to use a controller with. The problem is if I launched Just Cause 2 with Xpadder running in the background Just Cause 2's internal Xbox 360 configuration gets totally messed up and the game becomes unplayable.

My algorithm or what I want to accomplish with this program:
  • Windows starts and proceeds to the desktop. Autoit is part of the start up programs.
  • Autoit has the program ready but doesn't execute it yet.
  • By presssing A on the Xbox 360 controller executes the Autoit program which in turn launches Xpadder and then XBMC. (I use the X360's A button to start so as not to accidentally hit one of the analog sticks and have the program execute).
  • Having control of XBMC I would like to play a game now. I launch Just Cause 2. I would like Autoit to close/minimize XBMC and close Xpadder. That will allow me to play Just Cause 2 without have Xpadder interfere.
  • On exiting of the game Autoit should re-launch Xpadder and re-open/maximize XBMC.
  • If I want to use the computer in my room with a mouse/keyboard by pressing the Right Mouse Button will close/minimize XBMC and either close Xpadder or minimize it--that depends on which would require more code.

I believe that's it. I'll add on to it if I remember more. Let me know what you all think.

THANKS!







#2 someone

someone

    Reformed Mass Spammer!

  • Active Members
  • PipPipPipPipPipPip
  • 536 posts

Posted 26 January 2012 - 08:48 PM

Welcome to the forum. Sounds like something you can definitely accomplish with Autoit. I don't know much though about xpadder, although a quick google shows that it uses the xbox controller to send keypresses to the computer. If that is the case I don't see why autoit can't catch that even (see hotkeyset and ispressed in the help file) and then do whatever you want.

I'll try to check back and be as much help as possible, I use XBMC and have a 360 controller I don't really use but hooked up to a media PC, and something like this sounds pretty cool.
While ProcessExists('Andrews bad day.exe')     BlockInput(1)     SoundPlay('Music.wav')     SoundSetWaveVolume('Louder') WEnd

#3 Abacusrex

Abacusrex

    Seeker

  • Active Members
  • 14 posts

Posted 26 January 2012 - 10:34 PM

Awesome! What would you recommend I do first, to begin understanding what steps to take? I'm completely lost at the moment.

I would also like to do this project so I could share it with others. I know there's a number of other people on XBMC forums that would love to have a program like this. :)

#4 someone

someone

    Reformed Mass Spammer!

  • Active Members
  • PipPipPipPipPipPip
  • 536 posts

Posted 27 January 2012 - 05:14 PM

Well in a nutshell, you want autoit to monitor processes (so you know when stuff closes, etc), and monitor certain keypresses, and do stuff.
For keypresses, your looking at Ispressed in the help file, and for the process stuff you need a loop, and processexists (you could use processwaitclose, but I think that won't be best in the long run).

I know it can seem a lot to grasp at first, I would recommend getting a handle on how ispressed works first, because in doing that you will get a basic idea of loops. Don't worry about the controller or XBMC at all at this point. Create a simple test script that will run notepad when the 'A' key is hit. Honestly the example script for ispressed is very close to what you would want.

Break it down into small steps. That way, if one piece of it doesn't work like you expect it to, you can post a fully contained reproducer that is relatively SMALL. Having a paragraph of code to look at makes it much easier to get help. Too much code or no code is a pain. Also not having to install things like XBMC or other software to run your code helps.

Lastly, talking about gaming per se or coding for bots etc is a no-no. If you can't get game xyz to launch, close or work as expected, try to make a reproducer without the game involved. If you post a topic that says Just Cause 2 won't work with Autoit, you probably won't get much help. Check out what the forum rules say on this if you haven't.

Good luck!
While ProcessExists('Andrews bad day.exe')     BlockInput(1)     SoundPlay('Music.wav')     SoundSetWaveVolume('Louder') WEnd

#5 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 20,641 posts

Posted 27 January 2012 - 05:40 PM

Abacusrex,

I was asked to take a look at this thread because it mentions games - a sensitive topic here as has already been pointed out.

I see no problem with what you want to do in that you are using the script to configure your equipment so it is ready for you to play the game, not actually helping you to play it. But please take care not to stray into the "gamebot" area - we do enforce the Forum Rules strictly. ;)

So, to anyone who wants to help you - feel free! :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#6 Abacusrex

Abacusrex

    Seeker

  • Active Members
  • 14 posts

Posted 11 February 2012 - 09:33 AM

Thanks for the help (Someone) I'll start with what you suggested.

I have no intention to 'gamebot'. Enough said. ;)

I'll keep this updated when I further my progress. Talk to you later.

PS: Anyone else wants to add their helping hand, feel free! :)

#7 Abacusrex

Abacusrex

    Seeker

  • Active Members
  • 14 posts

Posted 13 February 2012 - 10:31 AM

Okay, how would I write code that does this:

On exiting of a game a program also exits.

Example: I'm playing Just Cause 2, I'm done playing. I exit the game. After I exit, Steam.exe (which is required to run as well) is automatically closed by the Autoit script.

#8 Jos

Jos

    ...

  • Developers
  • 22,856 posts

Posted 13 February 2012 - 11:31 AM

Okay, how would I write code that does this:

On exiting of a game a program also exits.

Example: I'm playing Just Cause 2, I'm done playing. I exit the game. After I exit, Steam.exe (which is required to run as well) is automatically closed by the Autoit script.

edit: Lets how this develops.

Edited by Jos, 13 February 2012 - 12:08 PM.

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#9 Blue_Drache

Blue_Drache

    Revolutionary Flavour

  • Active Members
  • PipPipPipPipPipPip
  • 3,487 posts

Posted 13 February 2012 - 11:54 AM

Steam's a launcher. Not a game?

Jos: From what I understand, he's not automating the game, but the game platform and wishes to close it after he's finished? The thread was green-lighted by Melba a few posts ago.
Lofting the cyberwinds on teknoleather wings, I am...The Blue DrachePosted ImagePosted Image

#10 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 20,641 posts

Posted 13 February 2012 - 12:32 PM

Blue_Drache,

I "green-lighted" a question about configuring the OP's equipment - that does not mean that subsequent posts within the same thread on more "sensitive" subjects are also permitted. This new post is getting very close to the limits as it requires interaction - albeit limited - with a game GUI. ;)

So as Jos has said - we will wait and see where this thread goes from here. :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#11 Blue_Drache

Blue_Drache

    Revolutionary Flavour

  • Active Members
  • PipPipPipPipPipPip
  • 3,487 posts

Posted 13 February 2012 - 05:17 PM

@Abacusrex: I'd approach this the same way I'd approach closing any other program.

WinClose() if you can get the window's name and/or handle. (Preferred method)

If that doesn't work, try ProcessClose()

See the help file for the syntax.
Lofting the cyberwinds on teknoleather wings, I am...The Blue DrachePosted ImagePosted Image

#12 Abacusrex

Abacusrex

    Seeker

  • Active Members
  • 14 posts

Posted 15 February 2012 - 12:01 AM

I'm sorry if this is getting to close to a game-cheating-script. It's not intended. I solemnly swear that all the scripting advice I ask for has nothing to do with obtaining an advantage in games. All advice I ask for adheres to automating the game launchers or related applications so as to simplify repetitive tasks. I'll say again: All the scripting information I'm gathering is to be applied outside of games and will not, in anyway, give me an advantage in game either offline or online.

The major script I want to write, that is laid out in my original post, is too complex for me to pursue at the moment. I'm trying to build my scripting skills right now with simpler scripts.

I asked how to automatically close the Steam.exe process on exit of another game because sometimes I want to switch to the game Battlefield 3 which requires a different game launcher, Orgin.exe. If I'm playing Just Cause 2 the Steam,exe will launch and on the exit of Just Cause 2 will stay activate until manually closed. If I play Battlefield 3 the program Origin.exe has to launch for the game to run. I don't want/need two game library/launchers running simultaneously; hence the reason I wanted to automate both the close of Steam.exe and Origin.exe on exiting of either launcher's games.

On that note. I already know how to close the program Blue_Drache, using your methods presented above. What I'm confused about is how tell the Autoit script that the game that's running off of Steam.exe or Origin.exe has closed and that it (Steam.exe/Origin.exe) should close as well.

#13 Blue_Drache

Blue_Drache

    Revolutionary Flavour

  • Active Members
  • PipPipPipPipPipPip
  • 3,487 posts

Posted 15 February 2012 - 01:10 AM

If ProcessWaitClose("Origin.exe") then
_DoSomething()
EndIf
Lofting the cyberwinds on teknoleather wings, I am...The Blue DrachePosted ImagePosted Image

#14 Abacusrex

Abacusrex

    Seeker

  • Active Members
  • 14 posts

Posted 15 February 2012 - 11:30 AM

Thanks very much Blue_Drache. It worked perfectly after I fiddled with it for a while. This proves I'll be getting my major project underway a lot faster.

I hope the code doesn't trigger any game-cheating-alarms. :)

Here's what I got:
AutoIt         
;This script will allow the user the ability to launch games using ;The programs: Steam & Origin and without the need to close the launcher after use. ;At the close of the game on either Steam or Origin, the launcher will self terminate. ;Note: This script does not require both Origin and Steam to run. ;Having one of either program is sufficient. ;Note: Origin self termination will only occur with game: Battlefield 3. Unless further updated. ;Closes Steam.exe on exit of game. While 1 If ProcessExists("GameOverlayUI.exe") Then    If ProcessWaitClose("GameOverlayUI.exe") Then    ProcessClose("Steam.exe")    EndIf EndIf ;kills process: "ESN Sonar". (DICE's useless VOIP program) ProcessClose("SonarHost.exe") ;Closes Origin.exe on exit of Battlefield 3 "Main Menu" (Google Chrome). If ProcessExists("chrome.exe") Then    If ProcessWaitClose("chrome.exe") Then    ProcessClose("Origin.exe")    EndIf EndIf WEnd ;Finished.


#15 Abacusrex

Abacusrex

    Seeker

  • Active Members
  • 14 posts

Posted 16 February 2012 - 11:16 PM

I'm trying to write my main program, but I'm stuck on using the Xbox 360 Controllers "A" button to run the two programs: Xpadder and XBMC.

I've looked at _IsPressed and I got it to work for a keyboard and it successfully opened Notepad.exe when I pressed "TAB". I don't know how to apply that to the Xbox 360 controller though.

#16 Abacusrex

Abacusrex

    Seeker

  • Active Members
  • 14 posts

Posted 18 February 2012 - 10:52 AM

Any ideas?

#17 Blue_Drache

Blue_Drache

    Revolutionary Flavour

  • Active Members
  • PipPipPipPipPipPip
  • 3,487 posts

Posted 18 February 2012 - 03:46 PM

What scancode does it transmit?
Lofting the cyberwinds on teknoleather wings, I am...The Blue DrachePosted ImagePosted Image

#18 Abacusrex

Abacusrex

    Seeker

  • Active Members
  • 14 posts

Posted 18 February 2012 - 07:01 PM

If I understand what you're asking; the scancode is the code that sends information about which button or key has been pressed and sends it to the computer?

I'm not sure exactly what it is. Here's a picture of the Xbox 360 controller device properties and Autoit Windows Informer X64:


Posted Image

Uploaded with ImageShack.us

#19 Blue_Drache

Blue_Drache

    Revolutionary Flavour

  • Active Members
  • PipPipPipPipPipPip
  • 3,487 posts

Posted 19 February 2012 - 04:25 PM

You should be able to sniff that with a DLL call. But that's wandering into keylogging territory.
Lofting the cyberwinds on teknoleather wings, I am...The Blue DrachePosted ImagePosted Image

#20 Abacusrex

Abacusrex

    Seeker

  • Active Members
  • 14 posts

Posted 19 February 2012 - 08:14 PM

How would you recommend I proceed?

I looked a little bit at key-logging (don't quite understand it), but if that's against Autoit rules than I don't want to go that route.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users