Jump to content

select and case confusion


Recommended Posts

can't get the program to run from the Play icon,

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#Region ### START Koda GUI section ### Form=C:\Program Files (x86)\AutoIt3\TroubleInHeaven\TIHa.kxf
$Form1 = GUICreate("Trouble In Heaven", 613, 431, 192, 132)
GUISetIcon("C:\Play.ico", -1)
$Pic1 = GUICtrlCreatePic("C:\Splash.bmp", 0, 0, 612, 428)
$Icon1 = GUICtrlCreateIcon("C:\Play1.ico", -1, 48, 80, 120, 80)
GUICtrlSetTip(-1, "Play Trouble in Heaven")
$Icon1context = GUICtrlCreateContextMenu($Icon1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
Select
  Case $Form1
  Case $Icon1
  $Icon1= ShellExecuteWait("C:\0aTest\lvl3.exe", "","C:\0aTest", "")
    ShellExecuteWait("C:\0aTest\China2a.exe", "","C:\0aTest", "")
    EndSelect
 EndSwitch
WEnd
Link to comment
Share on other sites

Yes, these select and swith statments can be a little confusing.

For example, I judt found out that this works~

#AutoIt3Wrapper_Run_AU3Check=n
GUICreate("test", 225, 100)
$Button = GUICtrlCreateButton("register", 50, 10, 130, 75)
GUISetState()

While 1
Switch GUIGetMsg()
Case -3
Exit

Case $Button

HotKeySet("{F2}", "test")

Func test()
Send("It works, what did you think would happen?!?! but as a side effect, autoit will self destruct in 10 seconds")
EndFunc
EndSwitch
WEnd

Anyway, it appears that you're interacting with a game of some kind, that isn't allowed on these forums and obviously you lack the courtesy to respect these forums by reading the rules for insight on what is acceptable and what is not.

But no bad, someone will eventually come in and lock the topic so as to make the event memorable to you that this is not allowed....

Also, try not to be one of those people who makes a secondary topic about the same thing but with a different pitch, most people on here are not as stupid as you might perceive them to be.

But if it's not a game you're automating and I am incorrect about my allegations, then damn me.

Edited by ApudAngelorum
Link to comment
Share on other sites

Anyway, it appears that you're interacting with a game of some kind, that isn't allowed on these forums and obviously you lack the courtesy to respect these forums by reading the rules for insight on what is acceptable and what is not.

Sir I make games, This is my game I made, I am trying to make A opening screen for Trouble in Heaven that will run all 21 levels of the game one after the other, please see my web site 78ez.com

Now how do I let the user click the play button so they can play the game please?

here try it for your self, first click http://www.filefactory.com/file/6d2euojy7c6t/n/TestComputer.exe

to see if your computer can play my games.

then click here to play a couple levels of the game.

http://www.filefactory.com/file/c5ac001/n/TroubleInHeaven.exe

Edited by meows
Link to comment
Share on other sites

EDIT new code.

I can't get it to run by the user pressing a button.

I can't figure out how to get

$iMsgBoxAnswer = MsgBox(36,"Play Trouble in Heaven","Trouble in Heaven by Reardon Studios")
Select
 Case $iMsgBoxAnswer = 6 ;Yes

into a graphic the player presses to play the game.

;ShellExecute("C:Program Files (x86)The Game CreatorsFPS CreatorMyGames", @ScriptDir & "China4a.exe", "", "OPEN")
;ShellExecute("C:0GameLink000Gamelaunchcreate_004data1", @ScriptDir & "1.exe", "", "run")
;Run("C:0GameLink000Gamelaunchcreate_004data1", @ScriptDir & "1.exe", "", "run")
;Run(@WindowsDir & "notepad.exe", "", @SW_MAXIMIZE)
;ShellExecute ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )
 ; ShellExecuteWait("C:0aTestlvl3.exe", "","C:0aTest", "")
  ;ShellExecuteWait("C:0aTestChina2a.exe", "","C:0aTest", "")
#Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=Question
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(36,"Play Trouble in Heaven","Trouble in Heaven by Reardon Studios")
Select
 Case $iMsgBoxAnswer = 6 ;Yes
  ShellExecuteWait("C:0aTestlvl3.exe", "","C:0aTest", "")
  ShellExecuteWait("C:0aTestChina2a.exe", "","C:0aTest", "")
 Case $iMsgBoxAnswer = 7 ;No
EndSelect
#EndRegion --- CodeWizard generated code End ---
Link to comment
Share on other sites

Alright, my bad, I read about the game over at the place you're developing it.

Since you decided to use the shell execution method to run the program instead of the RunWait() command, I believe you need to enter the verb thing to tell it what type of execution to perform.

Try adding "open" to the "verb" parameter, which is the last empty parameter in the shellexecutewait() function.

Link to comment
Share on other sites

Alright, my bad, I read about the game over at the place you're developing it.

Since you decided to use the shell execution method to run the program instead of the RunWait() command, I believe you need to enter the verb thing to tell it what type of execution to perform.

Try adding "open" to the "verb" parameter, which is the last empty parameter in the shellexecutewait() function.

Thank you ApudAngelorum for trying to help. Adding open just crashed the whole thing as I am using the

Actually I changed it all around, New Code and it runs but really want the start button towork and add a Quit Game button on the splash screen.

I will be adding ini files to track games won so they can restart at any game they have won instead of having to play them from game one.

Many Thanks.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region --- CodeWizard generated code Start ---
If Not IsDeclared('Navy') Then Local $Navy = 0x000080
GUICtrlSetColor("controlID",$Navy)
#EndRegion --- CodeWizard generated code End ---
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("test", 613, 431, 192, 132)
$Pic1 = GUICtrlCreatePic("C:Splash.bmp", 0, 0, 612, 428)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
; $nMsg = GUIGetMsg()
; Switch $nMsg
; Case $GUI_EVENT_CLOSE
; Exit
; EndSwitch
;WEnd
;;;;;;;;;;;;;; GAME ONE ;;;;;;;;;;;;;;
#Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Icon=Question
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(36,"play game","play level one")
Select
Case $iMsgBoxAnswer = 6 ;Yes
ShellExecuteWait("C:0aTestChina1a.exe", "","C:0aTest", "")
Case $iMsgBoxAnswer = 7 ;No
Exit
EndSelect
#EndRegion --- CodeWizard generated code End ---
;;;;;;;;;;;;;;; GAME TWO ;;;;;;;;;;;;;;;;;;;;;;;
#Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Default Button=Second, Icon=Question
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(292,"play 2","play 2")
Select
Case $iMsgBoxAnswer = 6 ;Yes
ShellExecuteWait("C:0aTestChina2a.exe", "","C:0aTest", "")
Case $iMsgBoxAnswer = 7 ;No
Exit
EndSelect
#EndRegion --- CodeWizard generated code End ---
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GAME THREE ;;;;;;;;;;;;;;;;;;;;;;;
#Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Default Button=Second, Icon=None
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(260,"Play Level 3","Play Level 3")
Select
Case $iMsgBoxAnswer = 6 ;Yes
ShellExecuteWait("C:0aTestChina3a.exe", "","C:0aTest", "")
Case $iMsgBoxAnswer = 7 ;No
EndSelect
Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GAME FOUR ;;;;;;;;;;;;;;;;;;;;;;;
#Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Default Button=Second, Icon=None
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(260,"Play Level 4","Play Level 4")
Select
Case $iMsgBoxAnswer = 6 ;Yes
ShellExecuteWait("C:0aTestChina4a.exe", "","C:0aTest", "")
Case $iMsgBoxAnswer = 7 ;No
Exit
EndSelect
WEnd
#EndRegion --- CodeWizard generated code End --- will repeat to China21a.exe
Edited by meows
Link to comment
Share on other sites

  • Moderators

meows,

Regardless of whether you wrote the game or not, the Forum Rules prohibit the discussion of any script which interacts with or launches a game. Your script does exactly that and so is not permitted here - this thread is now locked. :naughty:

Please make sure your future posts are within the rules. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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