Jump to content

Why does this program stall?


Bubnoff
 Share

Recommended Posts

Fellow A3 junkies -

This program is basically just an Auto-login gui for another program. I don't know if this matters or not but the program in question is a 3rd party php program that allows the person logging into it to perform remote commands on other machines.

It is hosted on the machines (Linux) in question. (good idea for a future Autoit project?). These are public internet machines in a Library. This program works, but could be improved. The staff likes to login to these remotely-hosted command modules at the beginning of the day then leave them open. This causes my autologin module to lock-up every once in a while. Is it because of the php program taxing the CPU, or is it my sloppily cobbled together program?

CODE
; *******************************************************

;;Autologin Module

; *******************************************************

#include <GUIConstants.au3>

#include <XSkin.au3>

#include <XSkinShell.au3>

#include <IE.au3>

AutoItSetOption ( "GUIOnEventMode", 1 )

HotKeySet ("^!m", "_minimize")

HotKeySet ("^!d", "_restore")

Global $oIE, $EventObject, $URL, $IEWnd, $guifile, $guiCorners, $guiWidth, $guiHeader, $guiHeight, $guiTitle, $XSkinGui,$XSkinGui2,$Button_5,$buttontxt1, $nButtonChild,$combo1, $XSkinGui3, $XSkinGui4, $XSkinGui5, $XSkinGui6

_main()

Func _main()

$guiWidth = 250

$guiHeight = 140

$guiTitle = "AutoLogin"

$guiHeader = 1

$guiCorners = 15

$Skin_Folder = IniRead("C:\Program Files\3rd Party\My.ini", "skins","skin","")

$XSkinGui = XSkinGUICreate( $guiTitle, $guiWidth, $guiHeight, $Skin_Folder, $guiHeader, $guiCorners)

$button1 = GUICtrlCreateButton ("1", 10,20,35,35,$BS_ICON)

GUICtrlSetCursor(-1, 0)

GUICtrlSetImage ($button1, "shell32.dll",23,1)

GUICtrlSetOnEvent ($button1, "_help")

$button2 = GUICtrlCreateButton ("1", 50,20,35,35,$BS_ICON)

GUICtrlSetCursor(-1, 0)

GUICtrlSetImage ($button2, "C:\Program Files\Junk\eye.ico","",1)

GUICtrlSetOnEvent ($button2, "_appearance")

$nButton3 = XSkinButton("X", 210, 20, 30, 30, "_close")

$nButton4 = XSkinButton("--", 175, 20, 30, 30, "_minimize")

$nButtonChild3 = XSkinButton("Reset", 10, 70, 35, 30,"_reset")

$npic=GUICtrlCreatePic("C:\Program Files\3rd Party\ncrllog.gif",60, 60, 175,55)

GUICtrlSetOnEvent ($npic, "_link")

GUICtrlSetCursor(-1, 0)

GUISetState()

$guifile = IniRead("C:\Program Files\3rd Party\My.ini","Stations","units","")

Sleep(500)

Select

Case $guifile = "1"

_addhost1()

Case $guifile = "2"

_addhost2()

Case $guifile = "3"

_addhost3()

Case $guifile = "4"

_addhost4()

EndSelect

While 1

Sleep(10)

Mouseover() ; required

WEnd

EndFunc

Func _addhost1()

HotKeySet ("^1", "_server1")

$buttontxt1 = IniRead("C:\Program Files\3rd Party\My.ini","buttons","button1","")

$guiWidth2=250

$guiHeight2=70

$guicorners2=15

$XSkinGui2 = XSkinGUICreate ($guiTitle, $guiWidth2, $guiHeight2, $Skin_Folder, $guiHeader, $guiCorners)

$nButtonChildx = XSkinButton($buttontxt1, 85, 20, 80, 30,"_server1")

WinMove($XSkinGui2, "", 385, 435)

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $XSkinGui2, "int", 1000, "long", 0x00040004);slide-in from top

GUISetState()

EndFunc

Func _addhost2()

$buttontxt1 = IniRead("C:\Program Files\3rd Party\My.ini","buttons","button1","")

$buttontxt2 = IniRead("C:\Program Files\3rd Party\My.ini","buttons","button2","")

HotKeySet ("^2", "_server2")

$guiWidth2=250

$guiHeight2=75

$guicorners2=15

$XSkinGui3 = XSkinGUICreate ($guiTitle, $guiWidth2, $guiHeight2, $Skin_Folder, $guiHeader, $guiCorners)

$nButtonChildx = XSkinButton($buttontxt1, 20, 20, 80, 30,"_server1")

$nButtonChild2 = XSkinButton($buttontxt2, 150, 20, 80, 30,"_server2")

WinMove($XSkinGui3, "", 385, 435)

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $XSkinGui3, "int", 1000, "long", 0x00040004);slide-in from top

GUISetState()

EndFunc

Func _addhost3()

$buttontxt1 = IniRead("C:\Program Files\3rd Party\My.ini","buttons","button1","")

$buttontxt2 = IniRead("C:\Program Files\3rd Party\My.ini","buttons","button2","")

$buttontxt3 = IniRead("C:\Program Files\3rd Party\My.ini","buttons","button3","")

HotKeySet ("^2", "_server2")

HotKeySet ("^3", "_server3")

$guiWidth2=270

$guiHeight2=85

$guicorners2=15

$XSkinGui4 = XSkinGUICreate ($guiTitle, $guiWidth2, $guiHeight2, $Skin_Folder, $guiHeader, $guiCorners)

$nButtonChildx = XSkinButton($buttontxt1, 10, 30, 80, 30,"_server1")

$nButtonChild2 = XSkinButton($buttontxt2, 95, 30, 80, 30,"_server2")

$nButtonChild3 = XSkinButton($buttontxt3, 180, 30, 80, 30,"_server3")

WinMove($XSkinGui4, "", 375, 435)

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $XSkinGui4, "int", 1000, "long", 0x00040004);slide-in from left

GUISetState()

EndFunc

Func _addhost4()

$buttontxt1 = IniRead("C:\Program Files\3rd Party\My.ini","buttons","button1","")

$buttontxt2 = IniRead("C:\Program Files\3rd Party\My.ini","buttons","button2","")

$buttontxt3 = IniRead("C:\Program Files\3rd Party\My.ini","buttons","button3","")

$buttontxt4 = IniRead("C:\Program Files\3rd Party\My.ini","buttons","button4","")

HotKeySet ("^2", "_server2")

HotKeySet ("^3", "_server3")

HotKeySet ("^4", "_server4")

$guiWidth2=250

$guiHeight2=150

$guicorners2=15

$XSkinGui5 = XSkinGUICreate ($guiTitle, $guiWidth2, $guiHeight2, $Skin_Folder, $guiHeader, $guiCorners)

$nButtonChildx = XSkinButton($buttontxt1, 20, 20, 80, 30,"_server1")

$nButtonChild2 = XSkinButton($buttontxt2, 150, 20, 80, 30,"_server2")

$nButtonChild3 = XSkinButton($buttontxt3, 20, 80, 80, 30,"_server3")

$nButtonChild4 = XSkinButton($buttontxt4, 150, 80, 80, 30,"_server4")

WinMove($XSkinGui5, "", 385, 435)

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $XSkinGui5, "int", 1000, "long", 0x00040004);slide-in from top

GUISetState()

EndFunc

Func _server1()

$password = IniRead("C:\Program Files\3rd Party\My.ini", "credentials", "password","")

$username = IniRead("C:\Program Files\3rd Party\My.ini", "credentials", "user","")

$URL = IniRead("C:\Program Files\3rd Party\My.ini", "stations", "station1","")

$oIE = _IECreate ($URL)

$oForm = _IEFormGetCollection ($oIE, 0)

$oQuery = _IEFormElementGetCollection ($oForm, 0)

$oQuery2 = _IEFormElementGetCollection ($oForm, 1)

WinWaitActive("Userful Management Portal")

_IEFormElementSetValue ($oQuery, $username)

_IEFormElementSetValue ($oQuery2, $password)

_IEFormSubmit ($oForm)

EndFunc

Func _server2()

$password = IniRead("C:\Program Files\3rd Party\My.ini", "credentials", "password","")

$username = IniRead("C:\Program Files\3rd Party\My.ini", "credentials", "user","")

$URL = IniRead("C:\Program Files\3rd Party\My.ini", "stations", "station2","")

$oIE = _IECreate ($URL)

$oForm = _IEFormGetCollection ($oIE, 0)

$oQuery = _IEFormElementGetCollection ($oForm, 0)

$oQuery2 = _IEFormElementGetCollection ($oForm, 1)

WinWaitActive("Userful Management Portal")

_IEFormElementSetValue ($oQuery, $username)

_IEFormElementSetValue ($oQuery2, $password)

_IEFormSubmit ($oForm)

EndFunc

Func _server3()

$password = IniRead("C:\Program Files\3rd Party\My.ini", "credentials", "password","")

$username = IniRead("C:\Program Files\3rd Party\My.ini", "credentials", "user","")

$URL = IniRead("C:\Program Files\3rd Party\My.ini", "stations", "station3","")

$oIE = _IECreate ($URL)

$oForm = _IEFormGetCollection ($oIE, 0)

$oQuery = _IEFormElementGetCollection ($oForm, 0)

$oQuery2 = _IEFormElementGetCollection ($oForm, 1)

WinWaitActive("Userful Management Portal")

_IEFormElementSetValue ($oQuery, $username)

_IEFormElementSetValue ($oQuery2, $password)

_IEFormSubmit ($oForm)

EndFunc

Func _server4()

$password = IniRead("C:\Program Files\3rd Party\My.ini", "credentials", "password","")

$username = IniRead("C:\Program Files\3rd Party\My.ini", "credentials", "user","")

$URL = IniRead("C:\Program Files\3rd Party\My.ini", "stations", "station4","")

$oIE = _IECreate ($URL)

$oForm = _IEFormGetCollection ($oIE, 0)

$oQuery = _IEFormElementGetCollection ($oForm, 0)

$oQuery2 = _IEFormElementGetCollection ($oForm, 1)

WinWaitActive("Userful Management Portal")

_IEFormElementSetValue ($oQuery, $username)

_IEFormElementSetValue ($oQuery2, $password)

_IEFormSubmit ($oForm)

EndFunc

Func _help()

$oIE=ObjCreate("InternetExplorer.Application.1")

With $oIE

.Top = 10

.Height=700

.Width=520

.Left=0

.Toolbar=0

.Silent=1 ; Don't show IE's dialog boxes

.Visible=1

$IEWnd=HWnd(.hWnd) ; Remember the Window, in case user decides to close it

EndWith

$EventObject=ObjEvent($oIE,"IEEvent_","DWebBrowserEvents") ; Start receiving Events.

$URL = "file:///C:/Program%20Files/Junk/LibSource2.htm"

$oIE.Navigate( $URL )

$EventObject.stop ; Tell IE we want to stop receiving Events

$EventObject=0 ; Kill the Event Object

EndFunc

Func _appearance()

$guiWidth2=125

$guiHeight2=135

$guicorners2=15

$XSkinGui6 = XSkinGUICreate ($guiTitle, $guiWidth2, $guiHeight2, $Skin_Folder, $guiHeader, $guiCorners2)

$combo1 = GUICtrlCreateCombo("", 10, 20, 105, 20, $CBS_DROPDOWNLIST)

GUICtrlSetData($combo1,"Prodbox|Sand-Paper|Sand-Desert|Rose-Wood|Blue-Metal|XP-Shutdown|XP-Shutdown2","")

WinMove($XSkinGui6, "", 630, 300)

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $XSkinGui6, "int", 1000, "long", 0x00040001);slide-in from top

GUISetState()

EndFunc

Func _reset()

$Skin_Folder = IniRead("C:\Program Files\3rd Party\My.ini", "skins","skin","")

FileOpen ($Skin_Folder, 2)

$Skin = GUICtrlRead ($combo1)

If $Skin = "" Then

XSkinMsgBoxOK("Error alert!", "No skin selected") ; OK button only

Else

IniWrite("C:\Program Files\3rd Party\My.ini","skins","skin","C:\Program Files\Autoit\Skins\"& $Skin)

FileClose ($Skin_Folder)

GUIDelete($XSkinGui)

GUIDelete($XSkinGui2)

GUIDelete($XSkinGui3)

GUIDelete($XSkinGui4)

GUIDelete($XSkinGui5)

GUIDelete($XSkinGui6)

Sleep(1000)

_main()

EndIf

EndFunc

Func _link()

$oIE=ObjCreate("InternetExplorer.Application.1") ; Create an Internet Explorer Object

With $oIE

.Top = 10

.Height=700 ; Make it a bit smaller than our GUI.

.Width=520

.Left=0

.Toolbar=0

.Silent=1 ; Don't show IE's dialog boxes

.Visible=1

$IEWnd=HWnd(.hWnd) ; Remember the Window, in case user decides to close it

EndWith

$EventObject=ObjEvent($oIE,"IEEvent_","DWebBrowserEvents") ; Start receiving Events.

$URL = "file:///C:/Program%20Files/Junk/LibRESOURCES.htm"

$oIE.Navigate( $URL )

$EventObject.stop ; Tell IE we want to stop receiving Events

$EventObject=0 ; Kill the Event Object

EndFunc

Func _minimize()

GUISetState(@SW_MINIMIZE, $XSkinGui)

GUISetState(@SW_MINIMIZE, $XSkinGui2)

GUISetState(@SW_MINIMIZE, $XSkinGui3)

GUISetState(@SW_MINIMIZE, $XSkinGui4)

GUISetState(@SW_MINIMIZE, $XSkinGui5)

GUISetState(@SW_MINIMIZE, $XSkinGui6)

EndFunc

Func _restore()

GUISetState(@SW_RESTORE, $XSkinGui)

GUISetState(@SW_RESTORE, $XSkinGui2)

GUISetState(@SW_RESTORE, $XSkinGui3)

GUISetState(@SW_RESTORE, $XSkinGui4)

GUISetState(@SW_RESTORE, $XSkinGui5)

GUISetState(@SW_RESTORE, $XSkinGui6)

EndFunc

Func _close()

GUIDelete($XSkinGui)

Exit

EndFunc

;===============================================================================

; The end

;===============================================================================

Because of the different configurations of different locations, the gui references an .ini file for its specs. Any ideas on why this might stall if more than one computer is logged into?

Any body seen any links on this forum for creating a remote program that is hosted from the computer to be controlled and logged into through a web browser (http:// ip address/program.au3 (or whatever))? I'll do a more serious look tomorrow...

Thanks .....

Bubnoff

[quote] Use educated speculation to create the illusion of pleasure ...Its the closest you'll ever get.- Anon [/quote]

Link to comment
Share on other sites

I always check for XSkin posts to Support my XSkin.au3 Include

However that doe snot appear to be related to any problems you are having

good luck

8)

doe snot :P

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

An update:

The php program I mentioned was written for Firefox and so this may be what was causing this program to freeze (I'll check this and update). But it seems to me that IE would freeze not my program. I would be open to any ideas on improving the performance of this program, eliminating excess code etc.

Or ...as I mentioned above, ideas for remote-admin tools hosted from a computer with the ability to log in through a web browser would also be welcome. Any computer could be used to administrate this computer so long as you knew the ip and the credentials for logging in.

Thanks

Bubnoff

[quote] Use educated speculation to create the illusion of pleasure ...Its the closest you'll ever get.- Anon [/quote]

Link to comment
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
 Share

  • Recently Browsing   0 members

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