Jump to content

FileOpenDialog Cancel


gcue
 Share

Recommended Posts

on a fileopendialog, if the user hits cancel my script exits bc it finishes the function the fileopendialog resides in..

how can i make it go back to the gui and if the user wants to try again they'd be able to later.

GUICreate("Bloomberg Info v0.1", 290,80); WS_EX_ACCEPTFILES

$btn = GUICtrlCreateButton ("Choose Asset File", 85,10,120,30,0x0300)
GUICtrlSetOnEvent($btn, "Bloomberg_Open")

GUICtrlSetState(-1, $GUI_FOCUS)

GUISetState(@SW_SHOW)

While 1
sleep(1000)
Wend

Func Bloomberg_Open()

$message = "Please choose your assets text file."

$afile = FileOpenDialog($message, @DesktopDir & "\", "Text Files (*.txt)", 1 + 4 )


If @error Then
    MsgBox(4096,"Bloomberg Info","No file was chosen")
EndIf
Link to comment
Share on other sites

heh i cut that part out - to condense the code.. but here it is =)

sorry bout that - now that i think of it.. it def might be relevant ;-)

GUICreate("Bloomberg Info v0.1", 290,80); WS_EX_ACCEPTFILES

$filemenu = GUICtrlCreateMenu ("&File")
$fileopenitem = GUICtrlCreateMenuitem ("Choose Asset File",$filemenu)
GUICtrlSetOnEvent(-1,"Bloomberg_Open")
$fileexititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
GUICtrlSetOnEvent(-1,"Xbutton")

$helpmenu = GUICtrlCreateMenu ("&Help")
$changeitem = GUICtrlCreateMenuitem ("Change Log",$helpmenu)
GUICtrlSetOnEvent(-1,"Change")
$helpitem = GUICtrlCreateMenuitem ("About",$helpmenu)
GUICtrlSetOnEvent(-1,"About")

$btn = GUICtrlCreateButton ("Choose Asset File", 85,10,120,30,0x0300)
GUICtrlSetOnEvent($btn, "Bloomberg_Open")


GUICtrlSetState(-1, $GUI_FOCUS)

GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton")

GUISetState(@SW_SHOW)

While 1
sleep(1000)
Wend

Func Bloomberg_Open()

$file = $toolsdir & "\Checkers\bloomberg_settings.csv"

If FileExists($file) Then
    FileDelete ($file)
EndIf

FileWrite($file, "Asset, Primary User, Version, Serial")

$message = "Please choose your assets text file."

$afile = FileOpenDialog($message, @DesktopDir & "\", "Text Files (*.txt)", 1 + 4 )


If @error Then
    MsgBox(4096,"Bloomberg Info","No file was chosen")
EndIf
....
...

In the code you posted the button being clicked wouldn't even be registered and Bloomberg_Open() is never being called.

Edited by gcue
Link to comment
Share on other sites

sorry fellas.. just didnt want to overwhelm u

heres Bloomberg_Open()

Bloomberg_Open()

$file = $toolsdir & "\Checkers\bloomberg_settings.csv"

If FileExists($file) Then
    FileDelete ($file)
EndIf

FileWrite($file, "Asset, Primary User, Version, Serial")

$message = "Please choose your assets text file."

$afile = FileOpenDialog($message, @DesktopDir & "\", "Text Files (*.txt)", 1 + 4 )


If @error Then
    MsgBox(4096,"Bloomberg Info","No file was chosen")
EndIf

Dim $assets
If Not _FileReadToArray($afile,$assets) Then
 Exit
EndIf

For $x = 1 to $assets[0]
$errorcount = 0
$status="1"
$user="1"
$version="1"
$serial="1"

Ping($assets[$x])
If @error Then
$status="OFFLINE"
$user="???"
$version="???"
$serial="???"
$errorcount =+1
EndIf

If $errorcount = 0 Then
RegRead ( "\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir" )
If @error Then
$status="NO_ADMIN_RIGHTS"
$user="???"
$version="???"
$serial="???"
$errorcount =+1
EndIf
EndIf

If $errorcount = 0 Then
RegRead ( "\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Bloomberg L.P.\Components", "sotr_version")
If @error Then
$status="BLOOMBERG_NOT_INSTALLED"
$user =  RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Altiris\Altiris Agent\Inventory", "PrimaryUser")
$version="???"
$serial="???"
$errorcount =+1
EndIf
EndIf

Dim $status, $user, $version, $serial
If $status = "1" Then
$status = ""
$user =  RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Altiris\Altiris Agent\Inventory", "PrimaryUser")
$version = RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Bloomberg L.P.\Components", "sotr_version")
$serial = RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Bloomberg L.P.\User Info", "Serial Number")
EndIf

FileWrite($file, '' &@CRLF & _
                $assets[$x] & "," & $user & "," & $version & "," & $serial & "," & $status)

Next

ShellExecute($file)
EndFunc ;Bloomberg
Link to comment
Share on other sites

Here's the problem:

If Not _FileReadToArray($afile, $assets) Then
    Exit
EndIfoÝ÷ ØX¥yu:®¶²È(x-¡ö¢ëÞ¯+bëax&§qé[ºÛh+)ºÈ^u·j붫z+'¡ø¥zv¦{Múiø¥y:òi×bzÛ«Æ¥'íçÇ¥nëm¢x¬¦ë!yÖ®¶­sbb33c¶ÖW76vRÒgV÷CµÆV6R6ö÷6R÷W"76WG2FWBfÆRâgV÷C°¢b33c¶fÆRÒfÆT÷VäFÆörb33c¶ÖW76vRÂFW6·F÷F"fײgV÷C²b3#²gV÷C²ÂgV÷CµFWBfÆW2¢çGBgV÷C²Â²B¤bW'&÷"FVà ×6t&÷CbÂgV÷C´&ÆööÖ&W&ræfògV÷C²ÂgV÷C´æòfÆRv26÷6VâgV÷C² &WGW&à¤VæD
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...