Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 20:01

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Need Help with Autoit Click on Image to run file for New game I made

Discussion on Need Help with Autoit Click on Image to run file for New game I made within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jul 2012
Posts: 1
Received Thanks: 0
Need Help with Autoit Click on Image to run file for New game I made

Problem is I do not know How to use Autoit to allow a user to click a button GUICtrlCreatePic and have a file run.
This is the opening Screen

But no matter what I do I can't get a click on a picture to open a file.
I need it to
have a open message for each of the levels in the game.

Please How do I code a simple user click on a picture to open a file?

Code that is useless.
Code:
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\program files (x86)\autoit3\tihgame1\julymenu.kxf
$Form1_1 = GUICreate("Trouble In Heaven", 1030, 772, 234, 21)
GUISetIcon("C:\Play.ico", -1)
$background = GUICtrlCreatePic("C:\Splash.bmp", 0, 0, 1024, 768, BitOR($GUI_SS_DEFAULT_PIC,$SS_CENTERIMAGE))
GUICtrlSetResizing(-1, $GUI_DOCKAUTO+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$EXIT = GUICtrlCreateButton("EXIT", 936, 40, 75, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetTip(-1, "EXIT")
$EXITcontext = GUICtrlCreateContextMenu($EXIT)
$MenuItem1 = GUICtrlCreateMenuItem("EXIT", $EXITcontext)
$MenuItem2 = GUICtrlCreateMenuItem("On the Run", $EXITcontext)
GUICtrlSetState(-1, $GUI_CHECKED)
$MenuItem3 = GUICtrlCreateMenuItem("Devils Slide", $EXITcontext)
$MenuItem4 = GUICtrlCreateMenuItem("Traitorous Dungeon", $EXITcontext)
$MenuItem5 = GUICtrlCreateMenuItem("Into The Dungon", $EXITcontext)
$help1 = GUICtrlCreateLabel("Hints and Help", 824, 80, 198, 36)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x008080)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
GUICtrlSetTip(-1, "Help")
$ontherun = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\TIHGame1\ONTHERUN.jpg", 16, 144, 292, 68, BitOR($GUI_SS_DEFAULT_PIC,$SS_SUNKEN))
GUICtrlSetTip(-1, "exit")
$devilSlide = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\TIHGame1\devilSlide.jpg", 336, 168, 332, 52, BitOR($GUI_SS_DEFAULT_PIC,$SS_SUNKEN))
GUICtrlSetTip(-1, "level2")
$demonhalls = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\TIHGame1\demonhalls.jpg", 344, 224, 332, 52)
GUICtrlSetTip(-1, "level 3")
$hadies = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\TIHGame1\16hadiesexpress.jpg", 688, 168, 332, 52)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
GUICtrlSetTip(-1, "level 4")
$runningpits = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\TIHGame1\runningpits.jpg", 680, 360, 348, 44)
GUICtrlSetTip(-1, "level 5")
$templepain = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\TIHGame1\templepain.jpg", 680, 224, 340, 76)
$Underworld = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\TIHGame1\Underworld.jpg", 696, 304, 324, 52)
$devilSlide2 = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\TIHGame1\devilSlide2.jpg", 8, 224, 300, 52)
$Traitor2 = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\TIHGame1\Traitorousdungeon2.jpg", 8, 288, 300, 52)
GUICtrlSetTip(-1, "Traitorous dungeon")
$Traitor1 = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\TIHGame1\Traitorousdungeon1.jpg", 8, 288, 300, 52, BitOR($GUI_SS_DEFAULT_PIC,$SS_SUNKEN))
GUICtrlSetTip(-1, "Traitorous dungeon")
$sewer1 = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\TIHGame1\sewer1.jpg", 8, 344, 300, 44)
GUICtrlSetTip(-1, "In to the sewer")
$Traitor9 = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\TIHGame1\Traitor9.jpg", 344, 368, 332, 52)
GUICtrlSetTip(-1, "Dead Reborn")
Dim $Form1_1_AccelTable[1][2] = [["^q", $EXIT]]
GUISetAccelerators($Form1_1_AccelTable)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GuiCreate("Menu", 400, 150)
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

		Case $MenuItem1
		Case $MenuItem2
		Case $MenuItem3
		Case $MenuItem4
		Case $MenuItem5

		Case $EXIT
$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
EndSwitch
		Case $help1
		Case $ontherun
		Case $devilSlide
		Case $demonhalls
		Case $runningpits
		Case $templepain
		Case $Underworld
		Case $devilSlide2
		Case $Traitor2
		Case $Traitor1
		Case $sewer1
		Case $Traitor9
	EndSwitch
WEnd
Func MenuItem1Click()
	
EndFunc
Func MenuItem2Click()

EndFunc
Func MenuItem3Click()

EndFunc
Func MenuItem4Click()

EndFunc
Func ontherunClick()

EndIf
EndFunc
Func runningpitsClick()

EndFunc
Func sewer1Click()
	MsgBox(0, "OK Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)

EndFunc
Func templepainClick()

EndFunc
Func Traitor1Click()

EndFunc
Func Traitor2Click()

EndFunc
Func Traitor9Click()

EndFunc
Func UnderworldClick()

EndFunc
I tried to get this to work and it did but you never have access to the main form only the popup boxes.

See they have to complete each level before they can play the next level.

Code:
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <Misc.au3>
If _Singleton("Trouble In Heaven", 1) = 0 Then
	; We know the script is already running. Let the user know.
	MsgBox(0, "Script Name", "This script is already running. Using multiple copies of this script at the same time is unsupported!")
	Exit
EndIf
#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_1 = GUICreate("Trouble In Heaven", 1030, 772, 234, 21)
GUISetIcon("C:\Play.ico", -1)
$Pic1 =  GUICtrlCreatePic("C:\Splash.bmp", 0, 0, 1024, 768, BitOR($GUI_SS_DEFAULT_PIC,$SS_CENTERIMAGE))
GUICtrlSetResizing(-1, $GUI_DOCKAUTO+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
;$Pic1 = GUICtrlCreatePic("C:\Splash.bmp", 0, 0, 612, 428)
$Button1 = GUICtrlCreateButton("Button1", 256, 380, 256, 32, $BS_ICON)
GUICtrlSetImage(-1, "C:\play1.ico", -1)
;GUICtrlSetColor(-1,0xFF0000) ; Makes instructions Red
GUICtrlSetTip(-1, "exit")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
	;	Case $GUI_EVENT_CLOSE
	;		Exit

		Case $Button1
Exit
	EndSwitch
;	$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,"Start your escape","Start your escape 'On the Run'")
	If $iMsgBoxAnswer = 6 Then;Yes
		FileChangeDir ( "C:\0TIH\1a" )
	$file = "C:\0TIH\1a\1a.exe"
	ShellExecuteWait($file)
	EndIf
 ;ShellExecuteWait("C:\0aTest\China1a.exe", "","C:\0aTest", "")
	If $iMsgBoxAnswer = 7 Then ;No
Exit
EndIf
#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 FileExists("C:\0aTest\level1.txt") Then
	If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(292,"Play Level 2","Play On the Run")

;
Select
	Case $iMsgBoxAnswer = 6 ;Yes
		FileChangeDir ( "C:\0TIH\2a" )
	$file = "C:\0TIH\2a\2a.exe"
	ShellExecuteWait($file)
	Case $iMsgBoxAnswer = 7 ;No
Exit

EndSelect

Else
	MsgBox(4096, "C:\0TIH", "You did not complete last level")

EndIf
;EndSelect
;Wend
#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,"Trouble In Heaven","Enter Devils Slide")
Select
	Case $iMsgBoxAnswer = 6 ;Yes
 	FileChangeDir ( "C:\0TIH\3a" )
	$file = "C:\0TIH\3a\3a.exe"
	ShellExecuteWait($file)
	Case $iMsgBoxAnswer = 7 ;No
Exit
EndSelect
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 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(60,"Play Level 4","Play Level 4")
Select
	Case $iMsgBoxAnswer = 6 ;Yes
 ShellExecuteWait("C:\0aTest\China4a.exe", "","C:\0aTest", "")
	Case $iMsgBoxAnswer = 7 ;No
Exit

EndSelect
WEnd
#EndRegion --- CodeWizard generated code End --- will repeat to China21a.exe
meows1121 is offline  
Reply

Tags
autioit, click button, user in game


Similar Threads Similar Threads
click this bar to view the full image
06/27/2012 - Off Topic - 7 Replies
Gibt es eine Möglichkeit bei meinem Banner dies zuentfernen ? click this bar to view the full image
Image i made, since i critiqued some others :)
05/20/2009 - General Art - 2 Replies
I thought it would only be fair to make an image for comments/suggestions, since I critiqued some others :) http://img34.imageshack.us/img34/2741/5hoursfinal fix1.png THANKS for any and all feedback :) *edit good or bad :)



All times are GMT +2. The time now is 20:01.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.