phatblinkie Posted October 4, 2006 Share Posted October 4, 2006 can anyone think of a reason that a compiled script would work on a win 2000 box and not on a xp box. (probably 1000's just the most likely would be best) on the xp box it starts to open and puts the little icon in the bottom right corner for like half a second then it dissappears. i have tested it on 5 win 2000 boxes and it works, and it doesnt work on any XP boxes,(tested on 4) i have no way of seeing why, it doesn't open a error windows or anything like that. this is compiled with the beta version cause its using GUIRegisterMsg i have provided a stripped down version of the code here, which also doesnt run on xp here it is, its been shorted and my company info removed from a few places expandcollapse popup;If UBound(ProcessList(@ScriptName)) > 1 Then Exit; only allow one instance ; - SCRIPT START #include <GUIConstants.au3> #include <GuiTreeView.au3> #include <Inet.au3> #include <IE.au3> ; Constants Global Const $INIPATH = @AppDataDir & "\Authtool\" Global Const $INIFILE = "authtool.ini" Global Const $INIPATHFILE = $INIPATH & $INIFILE ; Constants Const $TITLE = "AuthTool"; not used yet Const $LTITLE = "AuthTool-GUI"; not used yet Const $VERSION = "0.8" ; General Vars Global $gui = ""; main window Global $toolid = ""; toolid from db Global $id = @UserName Global $debug = 0 ; Global $inifile = @AppDataDir & "/toolinfo.ini" <-- is now defined as $INIPATHFILE in ini-inc.au3 ;Events Global Const $WM_NOTIFY = 0x004E Global Const $NM_FIRST = 0 Global Const $NM_CLICK = ($NM_FIRST - 2) Global Const $NM_DBLCLK = ($NM_FIRST - 3) Global Const $NM_RCLICK = ($NM_FIRST - 5) Global Const $TVM_HITTEST = ($TV_FIRST + 17) Global $gui_tv ; user credential handling ; check for ini, create blank one if not found ;If not FileExists($inifile) Then ; IniWrite($inifile, "toolinfo.ini", "created", @AppDataDir) ;EndIf ;$environment = "prod"; sets $authserver to niprc2.sbcglobal.net $environment = "test"; tsets $authserver to niprcdev.sbcglobal.net if $environment == "test" then $authserver = "test.test.net";changed to protect the innocent endif if $environment == "prod" then $authserver = "prod.test.net";changed to protect the innocent endif #region Options ;_IELoadWaitTimeout (6) ; copy any you want to change ;default value is listed first ;Opt("CaretCoordMode", 1) ;1=absolute, 0=relative, 2=client ;Opt("ColorMode", 0) ;0=RRGGBB color, 1=BBGGRR color ;Opt("ExpandEnvStrings", 0) ;0=don't expand, 1=do expand ;Opt("ExpandVarStrings", 0) ;0=don't expand, 1=do expand ;Opt("FtpBinaryMode", 1) ;1=binary, 0=ASCII ;Opt("GUICloseOnESC", 1) ;1=ESC closes, 0=ESC won't close ;Opt("GUICoordMode", 1) ;1=absolute, 0=relative, 2=cell ;Opt("GUIDataSeparatorChar","|");"|" is the default ;Opt("GUIOnEventMode", 0) ;0=disabled, 1=OnEvent mode enabled ;Opt("GUIResizeMode", 0) ;0=no resizing, <1024 special resizing ;Opt("GUIEventOptions",0) ;0=default, 1=just notification, 2=GuiCtrlRead tab index ;Opt("MouseClickDelay", 10) ;10 milliseconds ;Opt("MouseClickDownDelay", 10) ;10 milliseconds ;Opt("MouseClickDragDelay", 250);250 milliseconds ;Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client ;Opt("MustDeclareVars", 0) ;0=no, 1=require pre-declare ;Opt("OnExitFunc","OnAutoItExit");"OnAutoItExit" called ;Opt("PixelCoordMode", 1) ;1=absolute, 0=relative, 2=client Opt("RunErrorsFatal", 1) ;1=fatal, 0=silent set @error ;Opt("SendAttachMode", 0) ;0=don't attach, 1=do attach ;Opt("SendCapslockMode", 1) ;1=store and restore, 0=don't ;Opt("SendKeyDelay", 5) ;5 milliseconds ;Opt("SendKeyDownDelay", 1) ;1 millisecond ;Opt("TCPTimeout",100) ;100 milliseconds ;Opt("TrayAutoPause",1) ;0=no pause, 1=Pause Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info ;Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon Opt("TrayMenuMode",4) ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID not return ;Opt("TrayOnEventMode",0) ;0=disable, 1=enable ;Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect ;Opt("WinSearchChildren", 1) ;0=no, 1=search children also ;Opt("WinTextMatchMode", 1) ;1=complete, 2=quick ;Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced ;Opt("WinWaitDelay", 250) ;250 milliseconds #endregion Options Dim $ini_file[5][70] $ini_file[0][0] = 4 Func _GetMenu($id) $webfile = $INIPATH & "\auto.ini" InetGet("http://" & $authserver & "/authtool/autologin/menu.php?&suits=" & $id & "", $webfile, 1, 0) ;create dummy file is web server unavailable if @InetGetBytesRead < 0 Then IniWrite ( $webfile, "Parent 1", "1", "test1" ) IniWrite ( $webfile, "Parent 2", "2", "test1" ) IniWrite ( $webfile, "Parent 3", "3", "test1" ) IniWrite ( $webfile, "Parent 4", "4", "test1" ) EndIf $sec_names = IniReadSectionNames($webfile) If $debug >= 1 Then $msg = "" For $i = 1 to $sec_names[0] $msg &= $i & " - " & $sec_names[$i] & @CRLF Next ConsoleWrite("Section Names" & @CRLF & $msg) EndIf $ini_file[1][0] = $sec_names[1] $ini_file[2][0] = $sec_names[2] $ini_file[3][0] = $sec_names[3] $ini_file[4][0] = $sec_names[4] $var1 = IniReadSection($webfile, $ini_file[1][0]) $var2 = IniReadSection($webfile, $ini_file[2][0]) $var3 = IniReadSection($webfile, $ini_file[3][0]) $var4 = IniReadSection($webfile, $ini_file[4][0]) If IsArray($var1) Then If $debug >=1 Then ConsoleWrite("Total in menu 1 = " & $var1[0][0]) For $i = 1 To $var1[0][0] If $debug >=1 Then ConsoleWrite("Key: " & $var1[$i][0] & @CRLF & "Value: " & $var1[$i][1]) ;set menu items values $ini_file[1][$i] = $var1[$i][1] Next EndIf If IsArray($var2) Then If $debug >=1 Then ConsoleWrite("Total in menu 2 = " & $var2[0][0]) For $i = 1 To $var2[0][0] If $debug >=1 Then ConsoleWrite("Key: " & $var2[$i][0] & @CRLF & "Value: " & $var2[$i][1]) $ini_file[2][$i] = $var2[$i][1] Next EndIf If IsArray($var3) Then If $debug >=1 Then ConsoleWrite("Total in menu 3 = " & $var3[0][0]) For $i = 1 To $var3[0][0] If $debug >=1 Then ConsoleWrite("Key: " & $var3[$i][0] & @CRLF & "Value: " & $var3[$i][1]) $ini_file[3][$i] = $var3[$i][1] Next EndIf If IsArray($var4) Then If $debug >=1 Then ConsoleWrite("Total in menu 4 = " & $var4[0][0]) For $i = 1 To $var4[0][0] If $debug >=1 Then ConsoleWrite("Key: " & $var4[$i][0] & @CRLF & "Value: " & $var4[$i][1]) $ini_file[4][$i] = $var4[$i][1] Next EndIf Return $ini_file; return is good EndFunc Func _Gettoolinfo($id, $toolname) $toolfile = $INIPATH & "\toolinfo.ini" ;gets information on tool from api, ;if external then process other checks and possibly call autologin routine for actually logging in ;INI file will look like this if successful, otherwise error code 1 or 2 and blank values. ;code 1 = no seesion ;code 2 = account disabled ; ;example ini file ;[toolinfo] ;errorcode=3 ;toolname=some toolname ;externallogin=yes ;url=https://iservice.test.com/csr/csrLogin.jsp ;formname=frmMain ;form_username=LogonUserID ;form_pass=LogonPassword ;form_submit=Enter ;get ini of info about tool requested InetGet("http://" & $authserver & "/authtool/autologin/toolinfo.php?toolname=" & $toolname & "&suits=" & $id & "", $toolfile, 1, 0) ;make dummy ini file is web server unavailable, of course it wont do much though if @InetGetBytesRead < 0 Then $errcode = "3"; 3 is the good one $toolname = "NotFound" $toolid = "0" $externallogin = "no" $url = "" $formname = "" $form_username = "" $form_pass = "" Else $errcode = IniRead($toolfile, "toolinfo", "errorcode", "NotFound") $toolname = IniRead($toolfile, "toolinfo", "toolname", "NotFound") $toolid = IniRead($toolfile, "toolinfo", "toolid", "NotFound") $externallogin = IniRead($toolfile, "toolinfo", "externallogin", "NotFound") $url = IniRead($toolfile, "toolinfo", "url", "NotFound") $formname = IniRead($toolfile, "toolinfo", "formname", "NotFound") $form_username = IniRead($toolfile, "toolinfo", "form_username", "NotFound") $form_pass = IniRead($toolfile, "toolinfo", "form_pass", "NotFound") EndIf ;need error handling here if $errcode == 2 then MsgBox(4096, "", "Your Account is deactivated in the Auth Tool") Return EndIf if $errcode == 1 then MsgBox(4096, "", "Your Not logged into the Auth Tool") _IECreate("http://" & $authserver & "/authtool/", 0, 1, 0, 1); no attach, make visible, no wait, take focus ; ok for now, but i want to be able to have this part automated too. possibly via an api for invisible login Return EndIf ; errorcode 3 is the good one!! ; ; Based on what menu item is selected, you'll either get a custom login script ; or you'll just get a new IE window navigated to the tool URL. ; ; toolname could change, toolid will alway be the same ; toolid comes from the userdb.tools table ; user credential handling needs to be in the functions Switch $toolid Case "25"; test application ; function checks credentials from local INI, opens if found. ; if not found, GUI opens to populate creds in local INI file from user. ;not included in this file for testing ;OpenEhelp($toolname, $url, $formname, $form_username, $form_pass) Case "24"; another test application ;test for set credentials ;$credtest = test_if_cred_set($toolid) ;if $credtest == "False" then ; makecredentials_for_tool($toolid, $toolname) ;elseif $credtest == "True" then ;not included in this file for testing ;OpenIAF($toolname, $url, $formname, $form_username, $form_pass) ;EndIf Case Else; if no custom script is available, just open IE to the URL. If $url == "" Or $url == "NotFound" Then ; If no URL was found display error and quit MsgBox(0, "AuthTool Error", "The URL could not be found for this tool" & @CRLF & "url=" & $url) Else ; URL exists! Open IE and navigate to it. _IECreate($url, 0, 1, 0, 1); no attach, make visible, no wait, take focus EndIf EndSwitch ; Return EndFunc ; ; Create GUI ; _GetMenu($id); run _GetMenu to get array populated with menu items Const $GUI_OPT = BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_GROUP, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX) $gui_width = 150 $gui_height = 375 $gui_left = -1 $gui_top = -1 $gui = GUICreate($LTITLE, $gui_width, $gui_height, $gui_left, $gui_top, $GUI_OPT) $gui_tv = GUICtrlCreateTreeView (-1, 1, $gui_width-2, $gui_height-30) GUICtrlSetBkColor(-1,0xEFF3F7) ; ltblue For $i = 1 To $ini_file[0][0] ; set the primary root menus $gui_tv_item_parent = GUICtrlCreateTreeViewItem ($ini_file[$i][0], $gui_tv) ; would like to set state $GUI_EXPAND for users custom menu ? ; setup the childeren For $j = 1 to UBound($ini_file, 2) - 1 If Not $ini_file[$i][$j] = "" Then $gui_tv_item = GUICtrlCreateTreeViewItem ($ini_file[$i][$j], $gui_tv_item_parent) EndIf Next Next ;Register WM_NOTIFY events GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") GUISetState (@SW_SHOW) While 1 $gui_msg = GUIGetMsg() Select Case $gui_msg = $GUI_EVENT_CLOSE GUIDelete($gui) ExitLoop EndSelect WEnd ; WM_NOTIFY event handler Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $gui_tv Select ;Case $event = $NM_CLICK ;TreeView_Click() Case $event = $NM_DBLCLK ;Launch_App() $item = GUICtrlRead($gui_tv) $text = GUICtrlRead($item, 1); Get the text of the treeview item If $item == 0 or $text == "Parent 1" or $text == "Parent 2" or $text == "Parent 3" or $text == "Parent 4" Then ;$item == 0 or $item == 56 Then ;MsgBox(64, "TreeView Demo", "No item currently selected") Else ;$text = GUICtrlRead($item, 1); Get the text of the treeview item If $text == "" Then MsgBox(16, "Error", "Error while retrieving infos about item") Else _Gettoolinfo($id, $text) EndIf EndIf EndSelect EndSelect $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc ;==>WM_Notify_Events Link to comment Share on other sites More sharing options...
rbhkamal Posted October 4, 2006 Share Posted October 4, 2006 (edited) Try to remove this line:;If UBound(ProcessList(@ScriptName)) > 1 Then Exit; only allow one instanceEdit: Sorry I didn't notice it was committed out.RK Edited October 4, 2006 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
lod3n Posted October 4, 2006 Share Posted October 4, 2006 how does the auto.ini file it downloaded look? good? [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
phatblinkie Posted October 5, 2006 Author Share Posted October 5, 2006 actually it didnt look good, i wasnt creating the folder needed to store it in apparently. i added this small check to one of the functions (i had this in there once before, guess i removed it accidentally) Func _GetMenu($id) If not FileExists($INIPATH) Then DirCreate($INIPATH) EndIf and fixed a few duplicated backslashes in the file paths and recompiled on my xp box at home. it did the same errors before fixing it, then after fixing that part it was able to compile and run successfully. thanks for the help. Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 5, 2006 Share Posted October 5, 2006 (edited) can anyone think of a reason that a compiled script would work on a win 2000 box and not on a xp box. (probably 1000's just the most likely would be best) on the xp box it starts to open and puts the little icon in the bottom right corner for like half a second then it dissappears. i have tested it on 5 win 2000 boxes and it works, and it doesnt work on any XP boxes,(tested on 4) i have no way of seeing why, it doesn't open a error windows or anything like that. this is compiled with the beta version cause its using GUIRegisterMsg i have provided a stripped down version of the code here, which also doesnt run on xp here it is, its been shorted and my company info removed from a few places Logging is your friend: expandcollapse popup#include <file.au3> $LogFile = @ScriptDir & "\" & @ComputerName & "_" & @UserName & "_" & @YEAR & @MON & @MDAY & "_" & @Hour & @MIN & @SEC & ".log" _FileWriteLog($LogFile, "Start script: " & @ScriptFullPath) _FileWriteLog($LogFile, "Computer: " & @ComputerName & " User: " & @UserName) ; More of your script... If $environment == "test" Then $authserver = "test.test.net";changed to protect the innocent ElseIf $environment == "prod" Then $authserver = "prod.test.net";changed to protect the innocent EndIf _FileWriteLog($LogFile, "$environment = " & $environment & ", and $authserver = " & $authserver) ; More of your script... Func _GetMenu($id) $webfile = $INIPATH & "\auto.ini" Local $WebUrl = "http://" & $authserver & "/authtool/autologin/menu.php?&suits=" & $id & "" InetGet($WebUrl, $webfile, 1, 0) ;create dummy file is web server unavailable If @InetGetBytesRead < 0 Then _FileWriteLog($LogFile, "Web server unavailable: " & $WebUrl) IniWrite($webfile, "Parent 1", "1", "test1") IniWrite($webfile, "Parent 2", "2", "test1") IniWrite($webfile, "Parent 3", "3", "test1") IniWrite($webfile, "Parent 4", "4", "test1") EndIf $sec_names = IniReadSectionNames($webfile) If Not @error Then _FileWriteLog($LogFile, "Read " & $sec_names[0] & " section names from ini file: " & $webfile) Else _FileWriteLog($LogFile, "Error! Error occured reading section names from: " & $webfile) EndIF ; More of your script... EndFunc This is just an example of how you might put some logging into your script. Everywhere there is a critical decision point of file access, log it. The log files will tell you what happened. How much to log is up to you. Another technique is to put debug MsgBox() statements in the script (which pauses execution), or display traytip messages with current status, but you seem to be failing too quickly to see much from that. Again, logging is your friend... Edited October 5, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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