Recently Browsing 0 members
No registered users viewing this page.
question about _WinAPI_CreateWindowEx
welcome autoit team
please i need your help
i've searched a lot about how to use the _WinAPI_CreateWindowEx
finally i found an example
but i found some problem i hope you can help me
firstly, i want to set the controls focussable with the keyboard input
i already used the ws_tabStop but it did not work with me.
secondly, i want to set some access keys linked with the window
such as control+o enable the open button and control+f4 exit the app
note: i need a local access keys and not a global hotkeys
such as GUISetAccelerators
finaly, before i will put the code here i must clarify a few things.
1. you will ask me why you don't use the GUICreate function
here i'll tell you that it as dialog and It is a little heavy in motion with screen readers.
the screen readers for blind has some function that work with dialogs and others work with full windows style
2. you will ask me why you didn't search the net for that?
i will tell you that all examples that i found in the internet with pdfs and Picture books.
i found some examples in microsoft but it with cpp.
ok here is the code
i hope you can help me to do what i want
thank you in advance
; Small AutoIt Application that uses Windows API ; Written by Yuraj #NoTrayIcon #include <_RegisterClassEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <FontConstants.au3> AutoItSetOption("MustDeclareVars", 1) ; Window definitions Const $WinWidth = 370 Const $WinHeight = 350 Const $WinXPos = (@DesktopWidth / 2) - ($WinWidth / 2) Const $WinYPos = (@DesktopHeight / 2) - ($WinHeight / 2) Const $WinTitle = "Win32 Application - Text reader" Const $WinClass = "mainapp" Const $WinIcon = _WinAPI_LoadIcon(_WinAPI_GetModuleHandle("shell32.dll"), 13) ; Windows handles Global $hwnd, $edit1, $btn1, $btn2 ; Fonts Global $fnt1 ; Register class, Create the window Local $retVal = __WinAPI_RegisterClassEx($WinClass, "WindowCallback", $WinIcon, 0, _WinAPI_GetSysColor($COLOR_BTNFACE), BitOR($CS_DEFAULTSTYLE, $CS_DROPSHADOW)) ; If $retVal == 0 Then ; If registerclass fails MsgBox(16, "Error", "Error while registering window class!") Exit EndIf ; Create windows/controls $hwnd = _WinAPI_CreateWindowEx($WS_EX_STATICEDGE, $WinClass, $WinTitle, BitOR($WS_OVERLAPPED,$WS_SYSMENU, $WS_MINIMIZEBOX, $WS_GROUP, $WS_DLGFRAME), $WinXPos, $WinYPos, $WinWidth, $WinHeight, 0) $btn1 = _WinAPI_CreateWindowEx(0, "button", "Open file ...", BitOR($WS_VISIBLE, $WS_CHILD, $WS_TABSTOP, $WS_CLIPCHILDREN), 25, 270, 100, 30,$hwnd) $btn2 = _WinAPI_CreateWindowEx(0, "Button", "Exit", BitOR($WS_VISIBLE, $WS_CHILD, $WS_TABSTOP, $WS_CLIPCHILDREN), 235, 270, 100, 30, $hwnd) $edit1 = _WinAPI_CreateWindowEx(0, "edit", "text", BitOR($WS_VISIBLE, $WS_CHILD, $WS_VSCROLL, $ES_AUTOVSCROLL, $es_readOnly, $WS_TABSTOP), 5, 5, $WinWidth - 15, $WinHeight - 100, $hwnd) ; Set controls identifiers _WinAPI_SetWindowLong($btn1,$GWL_ID,150) _WinAPI_SetWindowLong($btn2,$GWL_ID,160) ; Set (controls) fonts $fnt1 = _CreateFont("MS Sans Serif", 15) _WinAPI_SetFont($btn1, $fnt1) _WinAPI_SetFont($btn2, $fnt1) _WinAPI_SetFont($edit1, $fnt1) ; Set focus to edit _WinAPI_SetFocus($edit1) ; Show window _WinAPI_ShowWindow($hwnd) _WinAPI_UpdateWindow($hwnd) ; Main loop that keep application opened While 1 Sleep(100) WEnd ;=================================================================; ; WINDOW CALLBACK ... ;=================================================================; Func WindowCallback($_hwnd, $iMsg, $wParam, $lParam) Local $iNC, $iID Switch $iMsg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Case $WM_CLOSE ; Show message on closing If MsgBox(48 + 4, $WinTitle, "Do you want really exit?", 0, $hwnd) <> 6 Then Return 0 ; Call destructor and then exit main thread FinalizeApp() Exit ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Case $WM_COMMAND $iNC = _WinAPI_HiWord($wParam) $iID = _WinAPI_LoWord($lParam) Switch $iNC Case $BN_CLICKED ; When is control clicked Switch _WinAPI_GetDlgCtrlID($iID) Case _WinAPI_GetDlgCtrlID($btn1) BtnOpenFileClick() Case _WinAPI_GetDlgCtrlID($btn2) BtnExitClick() EndSwitch EndSwitch ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EndSwitch Return _WinAPI_DefWindowProc($_hwnd, $iMsg, $wParam, $lParam) EndFunc ;==>WindowCallback Func FinalizeApp() _WinAPI_DeleteObject($fnt1) _WinAPI_DestroyWindow($hwnd) __WinAPI_UnregisterClass($WinClass) EndFunc ;==>FinalizeApp Func _CreateFont($fontName, $height = 16, $style = $FW_NORMAL, $italic = False, $underline = False, $strikeout = False) Local $hFont = _WinAPI_CreateFont($height, 0, 0, 0, $style, $italic, $underline, $strikeout, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, $fontName) Return $hFont EndFunc ;==>_CreateFont ;=================================================================; ; WINDOW EVENTS ;=================================================================; Func BtnOpenFileClick() Local $ret = _WinAPI_GetOpenFileName("", "Text files (*.txt)|All files (*.*)", ".", "", "", 1, 0, 0, $hwnd) If ($ret > 0) Then Local $path = $ret & "\" & $ret Local $file = _WinAPI_CreateFile($path, 2, 2) Local $buf = DllStructCreate("byte[" & _WinAPI_GetFileSizeEx($file) & "]") Local $i = 0 _WinAPI_ReadFile($file, DllStructGetPtr($buf), _WinAPI_GetFileSizeEx($file), $i) ; Close file handle _WinAPI_CloseHandle($file) _WinAPI_SetWindowText($edit1, BinaryToString(DllStructGetData($buf, 1))) EndIf EndFunc ;==>BtnOpenFileClick Func BtnExitClick() FinalizeApp() Exit EndFunc ;==>BtnExitClick
I'm hoping to create a way of copying and renaming a specific file off of a company Sharepoint site.
For local files I've always used the method of using FileExists( "path") then FileCopy ( "source", "dest" [, flag = 0] )
#include <WinAPIFiles.au3> Copy_File() Func Copy_File() local $source = "C:\Users\auser\Documents\test.xls" Local $dest = "C:\Users\auser\Documents\test" Local $iFileExists = FileExists($source) If $iFileExists Then FileCopy($source,$dest);copy file to new location MsgBox($MB_SYSTEMMODAL, "", "File was copied") Else MsgBox($MB_SYSTEMMODAL, "", "File doesn't exist") EndIf EndFunc However with the file location provided by sharepoint, it seems autoIt isn't able to find it. File path provided by sharepoint looks something like this:
https://workspace.company.com/Folder/Folder%20B/File%20Name.xls I know if I have excel open and paste the link into the excel file name open box, it will open the file just fine. Also I know I can create shortcuts to these links, and when I click on them it will open the file just fine too. So I'm not sure how I have to refer to these files for AutoIT to recognize it and copy it to the folder location I want.
I don't really have a good understanding on how this stuff works, but I was hoping the solution wasn't too complicated, and could use some help.
Any help is appreciated, thanks in advance.
hello sirs, please help me
i tried to create a function that read a folder files to 3d array
$array[n] = ctName
$array[n] = ctFilePath
$array[n] = crtsections number
$array[n][m] = KeyName
$array[n][m] = KeyVal
$array[n][m] = keySectionName
that the array
when i put one file into the folder all things work fine
but when i put more than one file
the last file worked fine but the others only the first key is showing
please can you help me to correct this problem
here is the example with the folder
please accept my greetings
and thanks in advance
Our Microsoft Office Templates shared folder was changed from a DFS share to an Isilon share. example:
Old Server: \\Domain.com\Office\Templates
New Server: \\Templates.domain.com\Office\Templates
The team making the changes overlooked that several hundred thousand documents, had been attached to the old template documents. So when you open a document which has been attached, it will take a couple of minutes to open, while it tries to locate the old server path. I've been asked to come in and fix it, so after several hours found that the data is being held in document.zip\word\_rels\settings.xml.rels, I now need to replace the old server path with the new server path. I didn't want to use dom as that would take too long and found a tool wtc https://github.com/NeosIT/wtc which works perfectly, takes about 8 minutes to scan a single directory with 4000 documents and fix them. The problem is the documents are all held on sharepoint and they want to retain the file timestamp, which is easy enough, but they also don't want to keep the "Modified By" apparently they don't like seeing all the documents appearing as "Modified by: Subz" Anyone know of way to retain the "Modified By" info,
Hello my friends
I have an inquiry and I hope to find the answer here
I want to create a graphical user interface
but I want to hide the system menu
I mean the window menu
Is this possible?
If is possible please give me how to do that
Thanks in advance