boltc Posted January 5, 2008 Share Posted January 5, 2008 iv made a script for a project for school where i have to teach someone about game maker in 'e-learning'.I want to load 'Game-Maker 7 Lite' in my own gui.. (download: http://www.yoyogames.com/gamemaker/try)my code:expandcollapse popup#include <GUIConstants.au3> Opt('WinTitleMatchMode', 2) Global $OldControl = '' Global $dllUser32 = DllOpen("user32.dll") Global $dllGdi32 = DllOpen("gdi32.dll") $hGUI = GUICreate("E-Learning (Game Maker 7.0)", 1000, 600, -1, -1, BitOr($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_CLIPCHILDREN)) Func WinSetStyle($hWnd, $Style = -1, $ExStyle = 0) Local Const $GWL_STYLE = -16 Local Const $GWL_EXSTYLE = -20 Local Const $SWP_NOMOVE = 0x2 Local Const $SWP_NOSIZE = 0x1 Local Const $SWP_SHOWWINDOW = 0x40 Local Const $SWP_NOZORDER = 0x4 Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER) If $Style = -1 Then $Style = $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $Style) DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $ExStyle) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, "int", 0, "int", 0, "int", $iFlags) EndFunc func _load() $PID = Run("C:\Program Files\Game_Maker7\Game_Maker.exe", "", @SW_HIDE) $hWnd = 0 $stPID = DllStructCreate("int") Do $WinList = WinList() For $i = 1 To $WinList[0][0] If $WinList[$i][0] <> "" Then DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $WinList[$i][1], "ptr", DllStructGetPtr($stPID)) If DllStructGetData($stPID, 1) = $PID Then $hWnd = $WinList[$i][1] ExitLoop EndIf EndIf Next sleep(100) Until $hWnd <> 0 If $hWnd <> 0 Then $nExStyle = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -20) $nExStyle = $nExStyle[0] DllCall("user32.dll", "int", "SetParent", "hwnd", $hWnd, "hwnd", $hGUI) DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", -20, "int", BitOr($nExStyle, $WS_EX_MDICHILD)) WinMove($hWnd, "", 0, 0, 815, 600) WinSetStyle($hWnd, $WS_POPUPWINDOW, $WS_EX_CLIENTEDGE + $WS_EX_TOOLWINDOW) EndIf $stPID = 0 EndFunc $label1 = GUICtrlCreateLabel($text_welkom_1, 820, 20, 175, 50) GUICtrlSetFont(-1, 12, 800, 0, "Arial") $label2 = GUICtrlCreateLabel($text_welkom_2, 820, 65, 175, 400) GUICtrlSetFont(-1, 10, 400, 0, "Arial") $but_starting = GUICtrlCreateButton ("loading..", 820, 510, 175, 40, $WS_DISABLED) $but_starting_exit = GUICtrlCreateButton ("Exit", 820, 555, 175, 40) GUISetState() _load() ;~ skip the pop-up screen WinWaitActive("Upgrade to the Pro Edition") ControlClick("Upgrade to the Pro Edition", "" ,"[CLASS:TBitBtn; INSTANCE:4;]") $title = "E-Learning (Game Maker 7.0)" $title_size = WinGetPos($title) WinMove($title, "", $title_size[0] -1, $title_size[1] -1) WinMove($title, "", $title_size[0], $title_size[1])sometimes it load proper in my gui, but sometimes it does not. and then it load normaly and my gui is empty.i can not find the problem, i spent already over 5 hours to this problem.can someone help me please? Link to comment Share on other sites More sharing options...
Zedna Posted January 5, 2008 Share Posted January 5, 2008 (edited) I like your script/idea. Maybe place some "little wait" logic between Run and WinList. Or try comment line "If $WinList[$i][0] <> "" Then" inside FOR loop Maybe immediately after Run doesn't exist Hwnd or title yet - just idea I don't know about that so much. Edited January 5, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
boltc Posted January 5, 2008 Author Share Posted January 5, 2008 I like your script/idea. Maybe place some "little wait" logic between Run and WinList. Or try comment line "If $WinList[$i][0] <> "" Then" inside FOR loop Maybe immediately after Run doesn't exist Hwnd or title yet - just idea I don't know about that so much. the sleeps does not work, i tried them everywhere.. i maybe need to add a checksum of something that makes sure it has the right handle, and if not then repeat it.. thats what im going to try now.. Link to comment Share on other sites More sharing options...
boltc Posted January 5, 2008 Author Share Posted January 5, 2008 I like your script/idea. Maybe place some "little wait" logic between Run and WinList. Or try comment line "If $WinList[$i][0] <> "" Then" inside FOR loop Maybe immediately after Run doesn't exist Hwnd or title yet - just idea I don't know about that so much. thanks for your little help:) i did some further research and i found out when he succeeded the value of $WinList[$i][0] was "Game Maker".. When he fails to load in my gui value was "Game_Maker".. i changed my script: Do $WinList = WinList() For $i = 1 To $WinList[0][0] If $WinList[$i][0] == "Game Maker" Then DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $WinList[$i][1], "ptr", DllStructGetPtr($stPID)) If DllStructGetData($stPID, 1) = $PID Then $hWnd = $WinList[$i][1] ClipPut($WinList[$i][0] & ", " & $WinList[$i][1]) ExitLoop EndIf EndIf Next sleep(100) Until $hWnd <> 0 and it works! . Link to comment Share on other sites More sharing options...
boltc Posted January 7, 2008 Author Share Posted January 7, 2008 this is working more accurate: Do $WinList = WinList() For $i = 1 To $WinList[0][0] If $WinList[$i][0] <> "" Then DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $WinList[$i][1], "ptr", DllStructGetPtr($stPID)) If $WinList[$i][0] == "Game Maker" Then If DllStructGetData($stPID, 1) = $PID Then $hWnd = $WinList[$i][1] ClipPut($WinList[$i][0] & ", " & $WinList[$i][1]) ExitLoop EndIf EndIf EndIf Next sleep(100) Until $hWnd <> 0 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now