BrendonKoz Posted March 13, 2014 Share Posted March 13, 2014 (edited) I've got an odd one here. I've updated some old code that ran file previously. The update primarily just added the window title identification string to the INI file instead of being hardcoded in the script. I'm compiling the code on Windows 8.1 x64 and running it on Windows 8.1 x32 (previously ran fine on WinXP x32). There are restrictions on this PC. Through group policy, the C drive is hidden/inaccessible. This program is being run via the registry upon boot and is found in C:sspl_stuffkiosk. The INI file is located in the same directory as the executable. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=C:\Users\bkozlowski.SARWIN2K\Desktop\splash_on_timer.exe #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <BlockInputEx.au3> ; Attempts to block ALT+TAB from working (works in XP, sort of mimics it in >= Vista #include <GDIPlus.au3> ; Fixes issue with odd transparent pixels w/normal AutoIt image/background methods Opt('TrayIconDebug', 0); Set to 1 to view current line in tray icon via tooltip Opt('TrayIconHide', 1); Set to 1 to hide the tray icon Opt("GUIOnEventMode", 1); Can call an event on action (like button click) ; --- FORCED DISPLAY SIGNAGE CODE --- ; $minutes_until_display = IniRead("settings.ini", "TimerScreenSettings", "minutes_until_display", 10); $seconds_to_display = IniRead("settings.ini", "TimerScreenSettings", "time_delay_secs", 20); $background_color = IniRead("settings.ini", "TimerScreenSettings", "background_color", "000000"); $splash_image = IniRead("settings.ini", "TimerScreenSettings", "splash_image", "splash.jpg") $text_color = IniRead("settings.ini", "TimerScreenSettings", "text_color", "CCCCCC"); $font_size = IniRead("settings.ini", "TimerScreenSettings", "font_size", 24); $font_weight = IniRead("settings.ini", "TimerScreenSettings", "font_weight", 600); $close_msg = IniRead("settings.ini", "TimerScreenSettings", "close_msg", "I Understand"); $font_family = IniRead("settings.ini", "TimerScreenSettings", "font_family", "Verdana"); $message_text = IniRead("settings.ini", "TimerScreenSettings", "message_text", "You have a little over 10 minutes remaining." & @CRLF & "Please save your work."); $button_width = IniRead("settings.ini", "TimerScreenSettings", "button_width", 100); $button_height = IniRead("settings.ini", "TimerScreenSettings", "button_height", 30); $button_left = IniRead("settings.ini", "TimerScreenSettings", "button_left", 1024 - $button_width); $button_top = IniRead("settings.ini", "TimerScreenSettings", "button_top", 768 - $button_height); $window_width = IniRead("settings.ini", "TimerScreenSettings", "window_width", @DesktopWidth); $window_height = IniRead("settings.ini", "TimerScreenSettings", "window_height", @DesktopHeight); $image_width = IniRead("settings.ini", "TimerScreenSettings", "image_width", @DesktopHeight); $image_height = IniRead("settings.ini", "TimerScreenSettings", "image_height", @DesktopHeight); $window_class = IniRead("settings.ini", "TimerScreenSettings", "window_class", "[REGEXPTITLE:(.* minutes)]"); $left = (@DesktopWidth - $image_width) / 2; Image centering placement $top = (@DesktopHeight - $image_height) / 2; Image centering placement ;$left = (1024 - $image_width) / 2; Image centering placement ;$top = (768 - $image_height) / 2; Image centering placement ; Create newlines from the settings.ini file information $message_text = StringReplace($message_text,'\n',@CRLF); ; --- TIME/WINDOW DETECTION CODE --- ; $window = WinWait($window_class, "", 1); Pauses script execution until the Cassie timer/application toolbar window is created and active While 1 $time_remaining = WinGetTitle($window_class); Cassie displays time remaining in title of window $time_remaining = StringReplace($time_remaining, " minutes", ""); Replace "X minutes" with "X" Sleep(5000) If $time_remaining = $minutes_until_display Then ExitLoop EndIf WEnd ; --- Set the Form Controls --- ; ; Window $kiosk = GUICreate("", $window_width, $window_height, 0, 0, $WS_POPUP); WinSetOnTop($kiosk, "", 1); Set the window to show up above all other windows GuiSetBkColor("0x" & $background_color); ; Background image _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\" & $splash_image); load bitmap as GDI+ bitmap $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap); convert it to a GDI bitmap _GDIPlus_BitmapDispose($hBitmap); $iPic = GUICtrlCreatePic("", $left, $top, 640, 480); $hB = GUICtrlSendMsg($iPic, 0x0172, 0, $hHBITMAP); copy GDI bitmap to picture control If $hB Then _WinAPI_DeleteObject($hB); GuiCtrlSetState(-1,$GUI_DISABLE); ; Close button $close = GUICtrlCreateButton($close_msg, $button_left, $button_top, $button_width, $button_height); GUICtrlSetDefColor("0x" & $text_color); GUISetFont($font_size, $font_weight, '', $font_family); GUICtrlSetFont($close, $font_size, $font_weight, 0, $font_family); GUICtrlSetOnEvent($close,"Remove"); Close the window early ; Dummy button for use with blocking key commands $dummyCtrl1 = GUICtrlCreateDummy(); $dummyCtrl2 = GUICtrlCreateDummy(); ; Label text GUICtrlCreateLabel($message_text, 15, 15); Place the text in the GUI GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT); ;--- Block certain keys/combos for XP machines ---; ; Enter, Space, SHIFT+TAB, WIN+TAB, ALT+SHIFT+TAB, WIN+SHIFT+TAB Local $AccelKeys[3][2] = [["{ENTER}", $dummyCtrl1], ["{SPACE}", $dummyCtrl1], ["!{TAB}|#{TAB}|!+{TAB}|#+{TAB}", $dummyCtrl2]]; GUISetAccelerators($AccelKeys); ; --- Display the Coded Form --- ; GUISetState(@SW_SHOW); WinActivate($kiosk); ; Watch for key accelerators and perform an action while window open, or close window after set time expires $timer = TimerInit(); Do $msg = GUIGetMsg(); Select Case $msg = $dummyCtrl1 ; DO NOTHING Case $msg = $dummyCtrl2 ; DO NOTHING Case $msg = $close Remove(); EndSelect Until $msg = $close or TimerDiff($timer) > $seconds_to_display * 1000 ; --- CLOSE THE KIOSK GUI EARLY --- ; Func Remove () GUIDelete(); Exit; EndFunc Func blocked () EndFunc Lines 49-57 can be commented out to see the program run and what it's doing (it waits for a window title to update to an appropriate value, then runs - it's for a public library computer reservation system). Settings file: [SplashScreenSettings] time_delay_secs=5 background_color=000000 splash_image=splash.jpg [TimerScreenSettings] minutes_until_display=10 time_delay_secs=37 background_color="000000" splash_image="alert_1024x768.jpg" text_color="AAD4FF" font_size=20 font_weight=600 close_msg="I Understand" font_family="Cambria Bold" message_text="\nYou have under 10 minutes remaining.\nContents saved *ON THE COMPUTER* will be *ERASED* at the end of your session.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n To prevent loss of work, please save externally now.\n Please see the clerk for any assistance." button_width=300 button_height=60 button_left=493 ;1024 -> 1280 = 256 / 2 = 128 + 365 = 493 | old 365 button_top=836 ;768 -> 1024 = 256 / 2 = 128 + 708 = 836 | old 768 image_width=1024 image_height=768 window_class="[REGEXPTITLE:(.* minutes)]" ;window_width=1024 ;window_height=768 Unfortunately my customized settings are not being read, only the alternate default settings (hardcoded in the application) are being used. The application and settings.ini file are both in the same folder. A different application is using the settings file as expected (compiled from an older build of AutoIt, I'm currently running v3.3.10.2 - which doesn't seem to use the AutoIt icon for compiled executables?) Any ideas on why the INI might not be getting read on the target PC? It runs as expected when in the editor on my local dev PC. EDIT: Just in case you're being curious and are examining every single line, note that the variable $window_class is a misnomer. I simply didn't update the variable name when I switched from class to REGEXTITLE (the class kept dynamically changing on each run). Edited March 13, 2014 by BrendonKoz Link to comment Share on other sites More sharing options...
BrewManNH Posted March 13, 2014 Share Posted March 13, 2014 Try giving the script the full path and file name to the ini file instead of the relative path. Use @ScriptDir if it's in the same folder as the script. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
BrendonKoz Posted March 14, 2014 Author Share Posted March 14, 2014 That did seem to solve the issue. I thought @ScriptDir was a default when IniRead was run though? Link to comment Share on other sites More sharing options...
AZJIO Posted March 15, 2014 Share Posted March 15, 2014 FileChangeDir(@ScriptDir) My other projects or all Link to comment Share on other sites More sharing options...
BrendonKoz Posted March 17, 2014 Author Share Posted March 17, 2014 I never change the directory in my script, and running the example code associated with the FileChangeDir method (prior to actually running FileChangeDir) to determine currently working directory shows that I'm in the same directory on my development machine. I guess I can't just assume a default working directory and should explicitly state it in the future. Thank you all! 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