Sign in to follow this  
Followers 0
Valuater

calling @AutoItExe & " /AutoIt3ExecuteScript

11 posts in this topic

#1 ·  Posted (edited)

I am trying to get "run-able" lines written to an external temporary script using

@AutoItExe & " /AutoIt3ExecuteScript

any help ... appreciated

#include <GuiConstants.au3>

AutoItSetOption ( "GUIOnEventMode", 1 )

Dim $bkg_color = 0xD8D8D8

GUICreate("Tester")
$Button_1 = GUICtrlCreateButton ("Test", 110, 100, 190, 20)
GUICtrlSetOnEvent( -1, "GetiT")
$Button_2 = GUICtrlCreateButton ("Exit", 110, 130, 190, 20, "LeavePrime")
GUICtrlSetOnEvent( -1, "LeaveiT")
GUISetState()
While 1
    
    
    Sleep(10)
    
    
WEnd

Func GetiT()
    $XSTitle = "Browse For Folder"
    $XSPrompt = "Folders"
    XSkin_Window($XSTitle, $XSPrompt)
    
    
    $NFolder = FileSelectFolder ( "Folders", @ProgramsDir, 2)
    MsgBox(0x0, "TestiT", $NFolder)
    FileDelete(EnvGet("temp") & "\XSkinit.au3")
EndFunc   ;==>GetPrime

Func LeaveiT()
    Exit
EndFunc


Func XSkin_Window($XSTitle, $XSPrompt = "")
    $XSnTitle = WinGetHandle(WinGetTitle(WinActive('')))
    $XStc = Hex(String($bkg_color), 6)
    $back_color = '0x' & StringMid($XStc, 5, 2) & StringMid($XStc, 3, 2) & StringMid($XStc, 1, 2)
    Local $XSfile = FileOpen(EnvGet("temp") & "\XSkinit.au3", 2)
    If $XSfile = -1 Then Return ; set error ?
    Local $XSline1 = 'AutoItSetOption(' & '"WinWaitDelay", 0' & ')'
    Local $XSline2 = 'WinWait("' & $XSTitle & '")'
    
    ; **********************************      The Problem is in this area
    ;Local $XSline3 = 'GUISetBkColor(' & $bkg_color & ', WinGetHandle("' & $XSTitle &'"))'
    
    Local $XSline3 = 'DllCall("gdi32.dll", "int", "SetBkColor", "hwnd","' & WinGetHandle(WinGetTitle(WinActive(''))) & '", "int","' & $back_color & '")'
    ; **********************************  end problem
    
    
    FileWrite($XSfile, $XSline1 & @CRLF & $XSline2 & @CRLF & $XSline3)
    FileClose($XSfile)
    Run(@AutoItExe & " /AutoIt3ExecuteScript " & EnvGet("temp") & "\XSkinit.au3")
EndFunc

I want to change the "backgound" color of the " Open File Dialog Box "

is this possible???

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What issues are you having Val?

Try to remove the quotes around $back_color

'DllCall("gdi32.dll", "int", "SetBkColor", "hwnd","' & WinGetHandle(WinGetTitle(WinActive(''))) & '", "int",' & $back_color & ')'
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

What issues are you having Val?

Try to remove the quotes around $back_color

'DllCall("gdi32.dll", "int", "SetBkColor", "hwnd","' & WinGetHandle(WinGetTitle(WinActive(''))) & '", "int",' & $back_color & ')'
its kinda "three" layerd

1

the correct syntax to output to a runable script

2

WinGetHandle(WinGetTitle(WinActive(''))) seems to get the "current" infomation on the current GUI

3

that the dll call is actually possible

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

its kinda "three" layerd

1

the correct syntax to output to a runable script

2

WinGetHandle(WinGetTitle(WinActive(''))) seems to get the "current" infomation on the current GUI

3

that the dll call is actually possible

8)

So you're getting an /AutoIt3ExecuteScript error?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

So you're getting an /AutoIt3ExecuteScript error?

no, not an actual "crash" error

( it also passes SciTe checking )

but i dont know if the dllcall is erroring or if the output to the temp file has the correct info for the folder dialog

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

; ********************************** The Problem is in this area

;Local $XSline3 = 'GUISetBkColor(' & $bkg_color & ', WinGetHandle("' & $XSTitle &'"))'

Local $XSline3 = 'DllCall("gdi32.dll", "int", "SetBkColor", "hwnd","' & WinGetHandle(WinGetTitle(WinActive(''))) & '", "int","' & $back_color & '")'

; ********************************** end problem

FileWrite($XSfile, $XSline1 & @CRLF & $XSline2 & @CRLF & $XSline3)

FileClose($XSfile)

Run(@AutoItExe & " /AutoIt3ExecuteScript " & EnvGet("temp") & "\XSkinit.au3")

EndFunc

[/autoit]

I would expect the return of $XSline3 to be an array from DllCall(), so your FileWrite() may not be right.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Here, this should send an @error to your message box

Func XSkin_Window($XSTitle, $XSPrompt = "")
    $XSnTitle = WinGetHandle(WinGetTitle(WinActive('')))
    $XStc = Hex(String($bkg_color), 6)
    $back_color = '0x' & StringMid($XStc, 5, 2) & StringMid($XStc, 3, 2) & StringMid($XStc, 1, 2)
    Local $XSfile = FileOpen(EnvGet("temp") & "\XSkinit.au3", 2)
    If $XSfile = -1 Then Return ; set error ?
    Local $XSline1 = 'AutoItSetOption(' & '"WinWaitDelay", 0' & ')'
    Local $XSline2 = 'WinWait("' & $XSTitle & '")'
   
    ; **********************************      The Problem is in this area
    ;Local $XSline3 = 'GUISetBkColor(' & $bkg_color & ', WinGetHandle("' & $XSTitle &'"))'
   
    Local $XSline3 = 'DllCall("gdi32.dll", "int", "SetBkColor", "hwnd","' & $XSnTitle & '", "int",' & $back_color & ')'
    ; **********************************  end problem
   $XSline4 = 'ConsoleWrite(@Error)'
   
    FileWrite($XSfile, $XSline1 & @CRLF & $XSline2 & @CRLF & $XSline3 & @CRLF $XSline4)
    FileClose($XSfile)
    $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & EnvGet('temp') & '\XSkinit.au3"', '', @SW_HIDE, 6)
    $iSTD = StdoutRead($iPID)
    MsgBox(0,'', $iSTD)
    FileDelete(EnvGet('temp') & '\XSkinit.au3')
EndFunc

Edit:

Oops, I still had quotes around the back_color... fixed.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

nopper

1

the standout read is like a runwait... it waits for the info, and that doesnt help

2

then consolewrite doesnt seem to work, it doesn't show up in SciTE

#include <GuiConstants.au3>

AutoItSetOption("GUIOnEventMode", 1)

Dim $bkg_color = "0xF13F3F"

GUICreate("Tester")
$Button_1 = GUICtrlCreateButton("Test", 110, 100, 190, 20)
GUICtrlSetOnEvent(-1, "GetiT")
$Button_2 = GUICtrlCreateButton("Exit", 110, 130, 190, 20, "LeavePrime")
GUICtrlSetOnEvent(-1, "LeaveiT")
GUISetState()
While 1
    Sleep(10)
WEnd

Func GetiT()
    $XSTitle = "Browse For Folder"
    $XSPrompt = "Folders"
    XSkin_Window($XSTitle, $XSPrompt)
    
    $NFolder = FileSelectFolder("Folders", @ProgramsDir, 2)
    MsgBox(0x0, "TestiT", $NFolder)
    ;FileDelete(EnvGet("temp") & "\XSkinit.au3")
EndFunc   ;==>GetiT

Func LeaveiT()
    Exit
EndFunc   ;==>LeaveiT

Func XSkin_Window($XSTitle, $XSPrompt = "")
    
    Local $XSfile = FileOpen(EnvGet("temp") & "\XSkinit.au3", 2)
    If $XSfile = -1 Then Return ; set error ?
    Local $XSline1 = 'AutoItSetOption(' & '"WinWaitDelay", 0' & ')'
    Local $XSline2 = 'WinWait("' & $XSTitle & '")'
    
    ; **********************************      The Problem is in this area
    Local $XSline3 = 'GUISetBkColor("' & $bkg_color & '", WinGetHandle("' & $XSTitle & '"))'
    Local $XSline4 = 'ConsoleWrite(@Error)'
    
    Local $XSline5 = 'DllCall("gdi32.dll", "int", "SetBkColor", "hwnd", WinGetHandle("' & $XSTitle & '"), "int","' & $bkg_color & '")'
    Local $XSline6 = 'ConsoleWrite(@Error)'
    ; **********************************  end problem
    
    FileWrite($XSfile, $XSline1 & @CRLF & $XSline2 & @CRLF & $XSline3 & @CRLF & $XSline4 & @CRLF & $XSline5 & @CRLF & $XSline6)
    FileClose($XSfile)
    $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & EnvGet('temp') & '\XSkinit.au3"', '', @SW_HIDE, 6)
    ;$iSTD = StdoutRead($iPID)
    ;MsgBox(0,'', $iSTD)
    ;FileDelete(EnvGet('temp') & '\XSkinit.au3')
EndFunc   ;==>XSkin_Window

IF i could get this... i could use it for many different windows.... and that would help alot

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

The stdout is waiting for the DllCall, if your not getting the @error, then your not executing the calls properly.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I changed some things up Val, like using the hdc which is required there with SetBkColor() http://msdn.microsoft.com/library/default....ntdraw_433m.asp and I also changed up what you were writing to the /autoit3executescript file, this way it's only 2 lines, and it returns the folder and I could do some error checking much easier:

#include <GuiConstants.au3>

AutoItSetOption("GUIOnEventMode", 1)

Global $bkg_color = 0xF13F3F

GUICreate("Tester")
$Button_1 = GUICtrlCreateButton("Test", 110, 100, 190, 20)
GUICtrlSetOnEvent(-1, "GetiT")
$Button_2 = GUICtrlCreateButton("Exit", 110, 130, 190, 20, "LeavePrime")
GUICtrlSetOnEvent(-1, "LeaveiT")
GUISetState()
While 1
    Sleep(10)
WEnd

Func GetiT()
    $XSTitle = "Browse For Folder"
    $XSPrompt = "Folders"
    $NFolder = XSkin_Window($XSTitle, $XSPrompt)
    MsgBox(0x0, "TestiT", $NFolder)
EndFunc   ;==>GetiT

Func LeaveiT()
    Exit
EndFunc   ;==>LeaveiT

Func XSkin_Window($XSTitle, $XSPrompt = '')
    FileClose(FileOpen(EnvGet('temp') & '\XSkinit.au3', 2))
    Local $XSline1 = '$NFolder = FileSelectFolder("Folders", @ProgramsDir, 2)'
    Local $XSline2 = 'ConsoleWrite($NFolder)'
    FileWrite(EnvGet('temp') & '\XSkinit.au3', $XSline1 & @CRLF & $XSline2)
    $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & EnvGet('temp') & '\XSkinit.au3"', '', @SW_HIDE, 6)
    WinWait('Browse For Folder', '', 5)
    Local $FBHwnd = WinGetHandle('Browse For Folder')
    Local $aDC = DllCall('user32.dll', 'ptr', 'GetDC', 'hwnd', $FBHwnd)
    If @error Then
        ProcessClose($iPID)
        Return SetError(1, 0, 0)
    EndIf
    Local $aDll = DllCall('gdi32.dll', 'int', 'SetBkColor', 'ptr', $aDC[0], 'int', $bkg_color)
    ConsoleWrite(@LF & 'SetBkColor error = ' & @error & @LF)
    $iSTD = StdoutRead($iPID)
    DLLCall('user32.dll', 'int', 'ReleaseDC', 'int', $aDC[0], 'hwnd', $FBHwnd)
    FileDelete(EnvGet('temp') & '\XSkinit.au3')
    Return $iSTD
EndFunc   ;==>XSkin_Window
It still doesn't work, so I dunno :)

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

You might want to take a look at this if you get a chance Valuater:

http://www.autoitscript.com/forum/index.ph...c=29088&hl=

I wrote this UDF specifically for dealing with executing scripts externally.


"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
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
Sign in to follow this  
Followers 0